summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schweikert <rjschwei@suse.com>2019-03-25 15:53:12 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2019-03-25 15:53:12 +0000
commitbb0b6f1d4e587d74a6e8fe17fa1c4dc3cf5287f7 (patch)
tree934fd50d3bd4a538420d97265cead4521c42a27e
parentdfe50e300882e3affcb02e686578807aea921b99 (diff)
downloadvyos-cloud-init-bb0b6f1d4e587d74a6e8fe17fa1c4dc3cf5287f7.tar.gz
vyos-cloud-init-bb0b6f1d4e587d74a6e8fe17fa1c4dc3cf5287f7.zip
net/sysconfig: write out SUSE-compatible IPv6 config
For writing IPv6 addresses to ifcfg-* the name "IPV6ADDR" is used. For secondary IPs the value for "IPV6ADDR_SECONDARIES" is set. On SUSE based distributions the names "IPADDR6" and "IPADDR6_$SOMELABEL" need to be used.
-rw-r--r--cloudinit/net/sysconfig.py3
-rw-r--r--tests/unittests/test_distros/test_netconfig.py2
-rw-r--r--tests/unittests/test_net.py14
3 files changed, 19 insertions, 0 deletions
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index e59753d5..09983929 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -386,10 +386,13 @@ class Renderer(renderer.Renderer):
ipv6_cidr = "%s/%s" % (subnet['address'], subnet['prefix'])
if ipv6_index == 0:
iface_cfg['IPV6ADDR'] = ipv6_cidr
+ iface_cfg['IPADDR6'] = ipv6_cidr
elif ipv6_index == 1:
iface_cfg['IPV6ADDR_SECONDARIES'] = ipv6_cidr
+ iface_cfg['IPADDR6_0'] = ipv6_cidr
else:
iface_cfg['IPV6ADDR_SECONDARIES'] += " " + ipv6_cidr
+ iface_cfg['IPADDR6_%d' % ipv6_index] = ipv6_cidr
else:
ipv4_index = ipv4_index + 1
suff = "" if ipv4_index == 0 else str(ipv4_index)
diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py
index e4530408..c3c0c8c5 100644
--- a/tests/unittests/test_distros/test_netconfig.py
+++ b/tests/unittests/test_distros/test_netconfig.py
@@ -496,6 +496,7 @@ class TestNetCfgDistroRedhat(TestNetCfgDistroBase):
BOOTPROTO=none
DEFROUTE=yes
DEVICE=eth0
+ IPADDR6=2607:f0d0:1002:0011::2/64
IPV6ADDR=2607:f0d0:1002:0011::2/64
IPV6INIT=yes
IPV6_DEFAULTGW=2607:f0d0:1002:0011::1
@@ -588,6 +589,7 @@ class TestNetCfgDistroOpensuse(TestNetCfgDistroBase):
BOOTPROTO=none
DEFROUTE=yes
DEVICE=eth0
+ IPADDR6=2607:f0d0:1002:0011::2/64
IPV6ADDR=2607:f0d0:1002:0011::2/64
IPV6INIT=yes
IPV6_DEFAULTGW=2607:f0d0:1002:0011::1
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index 1b415b00..fd03deb6 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -691,6 +691,9 @@ DEVICE=eth0
GATEWAY=172.19.3.254
HWADDR=fa:16:3e:ed:9a:59
IPADDR=172.19.1.34
+IPADDR6=2001:DB8::10/64
+IPADDR6_0=2001:DB9::10/64
+IPADDR6_2=2001:DB10::10/64
IPV6ADDR=2001:DB8::10/64
IPV6ADDR_SECONDARIES="2001:DB9::10/64 2001:DB10::10/64"
IPV6INIT=yes
@@ -729,6 +732,9 @@ DEVICE=eth0
GATEWAY=172.19.3.254
HWADDR=fa:16:3e:ed:9a:59
IPADDR=172.19.1.34
+IPADDR6=2001:DB8::10/64
+IPADDR6_0=2001:DB9::10/64
+IPADDR6_2=2001:DB10::10/64
IPV6ADDR=2001:DB8::10/64
IPV6ADDR_SECONDARIES="2001:DB9::10/64 2001:DB10::10/64"
IPV6INIT=yes
@@ -980,6 +986,7 @@ NETWORK_CONFIGS = {
BOOTPROTO=none
DEVICE=iface0
IPADDR=192.168.14.2
+ IPADDR6=2001:1::1/64
IPV6ADDR=2001:1::1/64
IPV6INIT=yes
NETMASK=255.255.255.0
@@ -1249,6 +1256,7 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true
DEFROUTE=yes
DEVICE=br0
IPADDR=192.168.14.2
+ IPADDR6=2001:1::1/64
IPV6ADDR=2001:1::1/64
IPV6INIT=yes
IPV6_DEFAULTGW=2001:4800:78ff:1b::1
@@ -1690,6 +1698,7 @@ iface bond0 inet6 static
MACADDR=aa:bb:cc:dd:e8:ff
IPADDR=192.168.0.2
IPADDR1=192.168.1.2
+ IPADDR6=2001:1::1/92
IPV6ADDR=2001:1::1/92
IPV6INIT=yes
MTU=9000
@@ -1745,6 +1754,7 @@ iface bond0 inet6 static
MACADDR=aa:bb:cc:dd:e8:ff
IPADDR=192.168.0.2
IPADDR1=192.168.1.2
+ IPADDR6=2001:1::1/92
IPV6ADDR=2001:1::1/92
IPV6INIT=yes
MTU=9000
@@ -1835,6 +1845,7 @@ iface bond0 inet6 static
GATEWAY=192.168.1.1
IPADDR=192.168.2.2
IPADDR1=192.168.1.2
+ IPADDR6=2001:1::bbbb/96
IPV6ADDR=2001:1::bbbb/96
IPV6INIT=yes
IPV6_DEFAULTGW=2001:1::1
@@ -1896,6 +1907,7 @@ iface bond0 inet6 static
BRIDGE=br0
DEVICE=eth0
HWADDR=52:54:00:12:34:00
+ IPADDR6=2001:1::100/96
IPV6ADDR=2001:1::100/96
IPV6INIT=yes
NM_CONTROLLED=no
@@ -1909,6 +1921,7 @@ iface bond0 inet6 static
BRIDGE=br0
DEVICE=eth1
HWADDR=52:54:00:12:34:01
+ IPADDR6=2001:1::101/96
IPV6ADDR=2001:1::101/96
IPV6INIT=yes
NM_CONTROLLED=no
@@ -2743,6 +2756,7 @@ USERCTL=no
GATEWAY=192.168.42.1
HWADDR=52:54:00:ab:cd:ef
IPADDR=192.168.42.100
+ IPADDR6=2001:db8::100/32
IPV6ADDR=2001:db8::100/32
IPV6INIT=yes
IPV6_DEFAULTGW=2001:db8::1