Commit 5b4d6926 authored by David Johnson's avatar David Johnson

Actually write all host/ipv6 pairs.

parent 0b951e48
Pipeline #3059 passed with stages
in 15 seconds
...@@ -49,7 +49,6 @@ if not node: ...@@ -49,7 +49,6 @@ if not node:
print "Setting addresses for %s ..." % (hostname,) print "Setting addresses for %s ..." % (hostname,)
hostslines = []
for i in node.findall("g:interface",namespaces=nsmap): for i in node.findall("g:interface",namespaces=nsmap):
mac = i.get("mac_address") mac = i.get("mac_address")
dev = None dev = None
...@@ -61,9 +60,6 @@ for i in node.findall("g:interface",namespaces=nsmap): ...@@ -61,9 +60,6 @@ for i in node.findall("g:interface",namespaces=nsmap):
continue continue
(addr,prefixlen) = (a.get("address"),a.get("prefixlen")) (addr,prefixlen) = (a.get("address"),a.get("prefixlen"))
addrs.append("%s/%s" % (addr,prefixlen)) addrs.append("%s/%s" % (addr,prefixlen))
# Save for /etc/hosts
name = i.get("client_id").replace(':','-')
hostslines.append("%s\t%s\n" % (addr,name))
if dev and addrs: if dev and addrs:
print "Enabling overall ipv6 forwarding and segment routing..." print "Enabling overall ipv6 forwarding and segment routing..."
os.system("sysctl -w net.ipv6.conf.all.forwarding=1") os.system("sysctl -w net.ipv6.conf.all.forwarding=1")
...@@ -84,6 +80,17 @@ for i in node.findall("g:interface",namespaces=nsmap): ...@@ -84,6 +80,17 @@ for i in node.findall("g:interface",namespaces=nsmap):
print "Bringing up interface %s ..." % (dev,) print "Bringing up interface %s ..." % (dev,)
os.system("ip link set %s up" % (dev,)) os.system("ip link set %s up" % (dev,))
# Collect ipv6 addrs for /etc/hosts
hostslines = []
for n in x.findall("g:node",namespaces=nsmap):
for i in node.findall("g:interface",namespaces=nsmap):
for a in i.findall("c:ip",namespaces=nsmap):
if a.get("type") != "ipv6":
continue
(addr,prefixlen) = (a.get("address"),a.get("prefixlen"))
name = i.get("client_id").replace(':','-')
hostslines.append("%s\t%s\n" % (addr,name))
print "Writing to /etc/hosts..." print "Writing to /etc/hosts..."
fd = open("/etc/hosts","a") fd = open("/etc/hosts","a")
for line in hostslines: for line in hostslines:
......
Markdown is supported
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