summaryrefslogtreecommitdiff
path: root/cloudinit/distros
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
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')
-rw-r--r--cloudinit/distros/net_util.py60
-rw-r--r--cloudinit/distros/rhel.py11
2 files changed, 51 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
diff --git a/cloudinit/distros/rhel.py b/cloudinit/distros/rhel.py
index 1a269e08..fa3ccb38 100644
--- a/cloudinit/distros/rhel.py
+++ b/cloudinit/distros/rhel.py
@@ -71,6 +71,7 @@ class Distro(distros.Distro):
nameservers = []
searchservers = []
dev_names = entries.keys()
+ use_ipv6 = False
for (dev, info) in entries.iteritems():
net_fn = self.network_script_tpl % (dev)
net_cfg = {
@@ -83,6 +84,13 @@ class Distro(distros.Distro):
'MACADDR': info.get('hwaddress'),
'ONBOOT': _make_sysconfig_bool(info.get('auto')),
}
+ if info.get('inet6'):
+ use_ipv6 = True
+ net_cfg.update({
+ 'IPV6INIT': _make_sysconfig_bool(True),
+ 'IPV6ADDR': info.get('ipv6').get('address'),
+ 'IPV6_DEFAULTGW': info.get('ipv6').get('gateway'),
+ })
rhel_util.update_sysconfig_file(net_fn, net_cfg)
if 'dns-nameservers' in info:
nameservers.extend(info['dns-nameservers'])
@@ -95,6 +103,9 @@ class Distro(distros.Distro):
net_cfg = {
'NETWORKING': _make_sysconfig_bool(True),
}
+ # If IPv6 interface present, enable ipv6 networking
+ if use_ipv6:
+ net_cfg['NETWORKING_IPV6'] = _make_sysconfig_bool(True)
rhel_util.update_sysconfig_file(self.network_conf_fn, net_cfg)
return dev_names