diff options
author | Ryan Harper <ryan.harper@canonical.com> | 2017-01-25 15:45:40 -0600 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2017-01-25 20:14:46 -0500 |
commit | 2de1c247e285cce0b25ab70abdc56ccd41019c27 (patch) | |
tree | 684d13eb904b3cb36c550b1f0530f16f449b0251 /tests | |
parent | dc6e7b49bac8b87a38fe57ee621177a8177fa2c0 (diff) | |
download | vyos-cloud-init-2de1c247e285cce0b25ab70abdc56ccd41019c27.tar.gz vyos-cloud-init-2de1c247e285cce0b25ab70abdc56ccd41019c27.zip |
Fix eni rendering of multiple IPs per interface
The iface:alias syntax for eni rendering is brittle with ipv6.
Replace it with using multiple iface stanzas with the same iface
name which is supported. Side-effect is that one can no longer
do 'ifup $iface:$alias' but requires instead use of ip address
{add|delete} instead.
LP: #1657940
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/test_net.py | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index 2c2bde96..b77d277a 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -219,11 +219,9 @@ NETWORK_CONFIGS = { auto eth99 iface eth99 inet dhcp - post-up ifup eth99:1 - - auto eth99:1 - iface eth99:1 inet static + # control-alias eth99 + iface eth99 inet static address 192.168.21.3/24 dns-nameservers 8.8.8.8 8.8.4.4 dns-search barley.maas sach.maas @@ -261,6 +259,27 @@ NETWORK_CONFIGS = { - wark.maas """), }, + 'v4_and_v6': { + 'expected_eni': textwrap.dedent("""\ + auto lo + iface lo inet loopback + + auto iface0 + iface iface0 inet dhcp + + # control-alias iface0 + iface iface0 inet6 dhcp + """).rstrip(' '), + 'yaml': textwrap.dedent("""\ + version: 1 + config: + - type: 'physical' + name: 'iface0' + subnets: + - {'type': 'dhcp4'} + - {'type': 'dhcp6'} + """).rstrip(' '), + }, 'all': { 'expected_eni': ("""\ auto lo @@ -298,11 +317,9 @@ iface br0 inet static address 192.168.14.2/24 bridge_ports eth3 eth4 bridge_stp off - post-up ifup br0:1 - -auto br0:1 -iface br0:1 inet6 static +# control-alias br0 +iface br0 inet6 static address 2001:1::1/64 auto bond0.200 @@ -319,11 +336,9 @@ iface eth0.101 inet static mtu 1500 vlan-raw-device eth0 vlan_id 101 - post-up ifup eth0.101:1 - -auto eth0.101:1 -iface eth0.101:1 inet static +# control-alias eth0.101 +iface eth0.101 inet static address 192.168.2.10/24 post-up route add -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true @@ -758,6 +773,13 @@ class TestEniRoundTrip(CiTestCase): entry['expected_eni'].splitlines(), files['/etc/network/interfaces'].splitlines()) + def testsimple_render_v4_and_v6(self): + entry = NETWORK_CONFIGS['v4_and_v6'] + files = self._render_and_read(network_config=yaml.load(entry['yaml'])) + self.assertEqual( + entry['expected_eni'].splitlines(), + files['/etc/network/interfaces'].splitlines()) + def test_routes_rendered(self): # as reported in bug 1649652 conf = [ |