Commit 57581457 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Don't emit duplicates in netgroup

parent 3ed3b917
......@@ -48,11 +48,8 @@ def ethers(tree):
def adjust_netgroup(netgroup):
limit = 1000
result = {}
keys = netgroup.keys()
keys.sort()
for g in keys:
entries = netgroup[g]
entries.sort()
for g in sorted(netgroup):
entries = sorted(netgroup[g])
length = sum(map(len, entries)) + len(entries) * 5
if length < limit:
# group is less than max YP length (1024)
......@@ -83,9 +80,9 @@ def netgroup(tree):
entry = "(%s,,)" % m.host[0]
pass
if not m.name[1] in netgroup:
netgroup[m.name[1]] = [ ]
netgroup[m.name[1]] = set()
pass
netgroup[m.name[1]].append(entry)
netgroup[m.name[1]].add(entry)
pass
def exclude(ip):
if not util.address(ip):
......@@ -97,10 +94,10 @@ def netgroup(tree):
for ip in filter(exclude,
list(g._parent._ip_) + list(g._parent._ipv6_)):
if not g.name[0:] in netgroup:
netgroup[g.name[0:]] = [ ]
netgroup[g.name[0:]] = set()
pass
entry = "(%s,,)" % util.fqn(tree, ip)[0:-1]
netgroup[g.name[0:]].append(entry)
netgroup[g.name[0:]].add(entry)
pass
pass
for k in tree._host_._interface_._kickstart_:
......@@ -109,9 +106,9 @@ def netgroup(tree):
entry = "(%s,,)" % util.fqn(tree, ip)[0:-1]
key = "ks-%s" % k.file[0:]
if not key in netgroup:
netgroup[key] = []
netgroup[key] = set()
pass
netgroup[key].append(entry)
netgroup[key].add(entry)
pass
pass
netgroup = adjust_netgroup(netgroup)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment