summaryrefslogtreecommitdiff
path: root/cloudinit/distros/net_util.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2014-11-24 16:30:00 -0800
committerJoshua Harlow <harlowja@yahoo-inc.com>2014-11-24 16:30:00 -0800
commit033eb26e698ebe6d003732ac4a64cefbdbf45f4e (patch)
tree5e4557300b72e7a2f3aaef3c7450eae47edb36a2 /cloudinit/distros/net_util.py
parent17fef56ab4d1235fb08cae824139b2a7cb6801f4 (diff)
parenta2915dae58bb735a0033b3575db6540b8fee4a4e (diff)
downloadvyos-cloud-init-033eb26e698ebe6d003732ac4a64cefbdbf45f4e.tar.gz
vyos-cloud-init-033eb26e698ebe6d003732ac4a64cefbdbf45f4e.zip
IPv6 support for rhel distro
When the ubuntu networking info file has ipv6 addresses inside it we need to make sure that we parse that information out and place it (at least) in the rhel network configuration writing. In later patches the other distros that use this parsed network configuration will likely also need to be updated (ubuntu and debian already should function as expected with regard to ipv6 support).
Diffstat (limited to 'cloudinit/distros/net_util.py')
-rw-r--r--cloudinit/distros/net_util.py68
1 files changed, 44 insertions, 24 deletions
diff --git a/cloudinit/distros/net_util.py b/cloudinit/distros/net_util.py
index b9bcfd8b..dd63a6a3 100644
--- a/cloudinit/distros/net_util.py
+++ b/cloudinit/distros/net_util.py
@@ -114,6 +114,10 @@ def translate_network(settings):
if 'iface' not in info:
continue
iface_details = info['iface'].split(None)
+ # Check if current device *may* have an ipv6 IP
+ use_ipv6 = False
+ if 'inet6' in iface_details:
+ use_ipv6 = True
dev_name = None
if len(iface_details) >= 1:
dev = iface_details[0].strip().lower()
@@ -122,6 +126,7 @@ def translate_network(settings):
if not dev_name:
continue
iface_info = {}
+ iface_info['ipv6'] = {}
if len(iface_details) >= 3:
proto_type = iface_details[2].strip().lower()
# Seems like this can be 'loopback' which we don't
@@ -129,35 +134,50 @@ def translate_network(settings):
if proto_type in ['dhcp', 'static']:
iface_info['bootproto'] = proto_type
# These can just be copied over
- for k in ['netmask', 'address', 'gateway', 'broadcast']:
- if k in info:
- val = info[k].strip().lower()
- if val:
- iface_info[k] = val
- # Name server info provided??
- if 'dns-nameservers' in info:
- iface_info['dns-nameservers'] = info['dns-nameservers'].split()
- # Name server search info provided??
- if 'dns-search' in info:
- iface_info['dns-search'] = info['dns-search'].split()
- # Is any mac address spoofing going on??
- if 'hwaddress' in info:
- hw_info = info['hwaddress'].lower().strip()
- hw_split = hw_info.split(None, 1)
- if len(hw_split) == 2 and hw_split[0].startswith('ether'):
- hw_addr = hw_split[1]
- if hw_addr:
- iface_info['hwaddress'] = hw_addr
- real_ifaces[dev_name] = iface_info
+ if use_ipv6:
+ for k in ['address', 'gateway']:
+ if k in info:
+ val = info[k].strip().lower()
+ if val:
+ iface_info['ipv6'][k] = val
+ else:
+ for k in ['netmask', 'address', 'gateway', 'broadcast']:
+ if k in info:
+ val = info[k].strip().lower()
+ if val:
+ iface_info[k] = val
+ # Name server info provided??
+ if 'dns-nameservers' in info:
+ iface_info['dns-nameservers'] = info['dns-nameservers'].split()
+ # Name server search info provided??
+ if 'dns-search' in info:
+ iface_info['dns-search'] = info['dns-search'].split()
+ # Is any mac address spoofing going on??
+ if 'hwaddress' in info:
+ hw_info = info['hwaddress'].lower().strip()
+ hw_split = hw_info.split(None, 1)
+ if len(hw_split) == 2 and hw_split[0].startswith('ether'):
+ hw_addr = hw_split[1]
+ if hw_addr:
+ iface_info['hwaddress'] = hw_addr
+ # If ipv6 is enabled, device will have multiple IPs, so we need to
+ # update the dictionary instead of overwriting it...
+ if dev_name in real_ifaces:
+ real_ifaces[dev_name].update(iface_info)
+ else:
+ real_ifaces[dev_name] = iface_info
# Check for those that should be started on boot via 'auto'
for (cmd, args) in entries:
+ args = args.split(None)
+ if not args:
+ continue
+ dev_name = args[0].strip().lower()
if cmd == 'auto':
# Seems like auto can be like 'auto eth0 eth0:1' so just get the
# first part out as the device name
- args = args.split(None)
- if not args:
- continue
- dev_name = args[0].strip().lower()
if dev_name in real_ifaces:
real_ifaces[dev_name]['auto'] = True
+ if cmd == 'iface' and 'inet6' in args:
+ real_ifaces[dev_name]['inet6'] = True
return real_ifaces
+