From 04809ae91168796f927248e664de94f32946d8d2 Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Wed, 18 Feb 2009 14:33:47 +0100 Subject: [PATCH] Version 2009-02-18 14:33 M src/hostinfo/ifconfig.py M src/hostinfo/util.py --- src/hostinfo/ifconfig.py | 12 ++++++++++-- src/hostinfo/util.py | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/hostinfo/ifconfig.py b/src/hostinfo/ifconfig.py index 24c83cd..49d5e65 100755 --- a/src/hostinfo/ifconfig.py +++ b/src/hostinfo/ifconfig.py @@ -19,6 +19,14 @@ def generate(tree, host): s = subnet(tree, i.ip[0]) else: s = i._static_[0] + if s and s.name_servers[0]: + name_servers = re.split("[, ]+", s.name_servers[0]) + else: + name_servers = [] + if s: + for n in i._nameserver_: + if n.domain[0] == s.domain[0]: + name_servers = [i.ip[0]] + name_servers config += "BOOTPROTO=none\n" config += "IPADDR=%s\n" % i.ip[0] @@ -30,9 +38,9 @@ def generate(tree, host): config += "NETWORK=%s\n" % s.network[0] if s and s.broadcast[0]: config += "BROADCAST=%s\n" % s.broadcast[0] - if s and s.name_servers[0]: + if s and name_servers: ni = 0 - for n in re.split("[, ]+", s.name_servers[0]): + for n in name_servers: ni += 1 config += "DNS%d=%s\n" % (ni, n) if s and s.domain[0]: diff --git a/src/hostinfo/util.py b/src/hostinfo/util.py index 5867ac3..19f1048 100755 --- a/src/hostinfo/util.py +++ b/src/hostinfo/util.py @@ -17,6 +17,8 @@ def fqn(tree, host): if (s.network[0] and aton(host.ip[0:]) & aton(s.netmask[0]) == aton(s.network[0])): return "%s.%s." % (host.name[1:],s.domain[0]) + raise Exception("No subnet declaration for %s (%s)" % + (host.name[0:], host.ip[0:])) else: raise Exception("'%s' not FQN, but has no ip" % host.name[0:]) -- GitLab