summaryrefslogtreecommitdiff
path: root/cloudinit/distros/net_util.py
diff options
context:
space:
mode:
authorShraddha Pandhe <shraddha.pandhe@yahoo.com>2014-11-21 18:32:30 +0000
committerShraddha Pandhe <shraddha.pandhe@yahoo.com>2014-11-21 18:32:30 +0000
commitbfbe8099b98bb97cfd96385fe31c023548734cbf (patch)
tree64763abe1f4ac33d58365f3d6b2bc68d2861c290 /cloudinit/distros/net_util.py
parent3efc7142a6ca72bfb40e63c49ed64e2e04837c51 (diff)
downloadvyos-cloud-init-bfbe8099b98bb97cfd96385fe31c023548734cbf.tar.gz
vyos-cloud-init-bfbe8099b98bb97cfd96385fe31c023548734cbf.zip
Add IPv6 Support for Rhel.
This patch does the following: 1. Adds support to process network config with IPv6 2. Adds support to display 'ifconfig -a' information for IPv6 3. Adds support to display routing information for IPv6
Diffstat (limited to 'cloudinit/distros/net_util.py')
-rw-r--r--cloudinit/distros/net_util.py60
1 files changed, 40 insertions, 20 deletions
diff --git a/cloudinit/distros/net_util.py b/cloudinit/distros/net_util.py
index b9bcfd8b..f56f6ccd 100644
--- a/cloudinit/distros/net_util.py
+++ b/cloudinit/distros/net_util.py
@@ -113,6 +113,10 @@ def translate_network(settings):
for info in ifaces:
if 'iface' not in info:
continue
+ use_ipv6 = False
+ # Check if current device has an ipv6 IP
+ if 'inet6' in info['iface']:
+ use_ipv6 = True
iface_details = info['iface'].split(None)
dev_name = None
if len(iface_details) >= 1:
@@ -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,26 +134,39 @@ 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.
+ # 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:
if cmd == 'auto':
@@ -160,4 +178,6 @@ def translate_network(settings):
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