Merge ~wesley-wiedenmeier/cloud-init:net-update into cloud-init:master

Proposed by Wesley Wiedenmeier
Status: Rejected
Rejected by: Scott Moser
Proposed branch: ~wesley-wiedenmeier/cloud-init:net-update
Merge into: cloud-init:master
Diff against target: 115 lines (+77/-2)
2 files modified
cloudinit/net/eni.py (+1/-1)
tests/unittests/test_net.py (+76/-1)
Reviewer Review Type Date Requested Status
cloud-init Commiters Pending
Review via email: mp+316422@code.launchpad.net

Description of the change

Update unit tests for network and make minor updates to network features based on curtin.net

To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

We now have better test coverage in cloud-init including the multiple addresses
for both ipv4 and ipv6 and ENI rendering.

the only thing left is 'hwaddress ether'.
And everything I read in interfaces(5) does not idnicate 'ether' is needed.
also, we do support *reading* ENI that has 'hwadress ether', but unless there is an example of why we need this, i think its best to ignore that part for now.

so i'm going to mark this 'rejected'. I hate how harsh that word sounds.
please feel free to re-submit and justfify.

Revision history for this message
Scott Moser (smoser) wrote :

We now have better test coverage in cloud-init including the multiple addresses
for both ipv4 and ipv6 and ENI rendering.

the only thing left is 'hwaddress ether'.
And everything I read in interfaces(5) does not idnicate 'ether' is needed.
also, we do support *reading* ENI that has 'hwadress ether', but unless there is an example of why we need this, i think its best to ignore that part for now.

so i'm going to mark this 'rejected'. I hate how harsh that word sounds.
please feel free to re-submit and justfify.

Unmerged commits

7fe4c44... by Wesley Wiedenmeier

Substitute 'hwaddress ether' rather than 'hwaddress' for 'mac_address'

56a288b... by Wesley Wiedenmeier

Updated networking unit tests based on newer curtin tests

 - add test for ipv6 aliases
 - add tests for multiple ipv4 aliases
 - substitution for mac_address should be 'hwaddress ether', not hwaddress

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/net/eni.py b/cloudinit/net/eni.py
2index 5b249f1..6bee905 100644
3--- a/cloudinit/net/eni.py
4+++ b/cloudinit/net/eni.py
5@@ -74,7 +74,7 @@ def _iface_add_attrs(iface, index):
6 'subnets',
7 'type',
8 ]
9- renames = {'mac_address': 'hwaddress'}
10+ renames = {'mac_address': 'hwaddress ether'}
11 if iface['type'] not in ['bond', 'bridge', 'vlan']:
12 ignore_map.append('mac_address')
13
14diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
15index b77d277..c3a675e 100644
16--- a/tests/unittests/test_net.py
17+++ b/tests/unittests/test_net.py
18@@ -280,6 +280,67 @@ NETWORK_CONFIGS = {
19 - {'type': 'dhcp6'}
20 """).rstrip(' '),
21 },
22+ 'ipv6_aliases': {
23+ 'expected_eni': textwrap.dedent("""\
24+ auto lo
25+ iface lo inet loopback
26+
27+ auto eth0
28+ iface eth0 inet6 static
29+ address fde9:8f83:4a81:1:0:1:0:6/64
30+
31+ # control-alias eth0
32+ iface eth0 inet static
33+ address 192.168.0.1/24
34+ """).rstrip(' '),
35+ 'yaml': textwrap.dedent("""\
36+ version: 1
37+ config:
38+ - type: physical
39+ name: eth0
40+ mac_address: "c0:d6:9f:2c:e8:80"
41+ subnets:
42+ - type: static
43+ address: fde9:8f83:4a81:1:0:1:0:6/64
44+ - type: static
45+ address: 192.168.0.1/24
46+ """).rstrip(' '),
47+ },
48+ 'ipv4_multiple_aliases': {
49+ 'expected_eni': textwrap.dedent("""\
50+ auto lo
51+ iface lo inet loopback
52+
53+ auto interface1
54+ iface interface1 inet dhcp
55+
56+ # control-alias interface1
57+ iface interface1 inet static
58+ address 192.168.2.2/22
59+ gateway 192.168.2.1
60+
61+ # control-alias interface1
62+ iface interface1 inet static
63+ address 10.23.23.7/23
64+ gateway 10.23.23.1
65+ """).rstrip(' '),
66+ 'yaml': textwrap.dedent("""\
67+ version: 1
68+ config:
69+ # multi_v4_aliases: multiple v4 addrs on same interface
70+ - type: physical
71+ name: interface1
72+ mac_address: "52:54:00:12:34:02"
73+ subnets:
74+ - type: dhcp
75+ - type: static
76+ address: 192.168.2.2/22
77+ gateway: 192.168.2.1
78+ - type: static
79+ address: 10.23.23.7/23
80+ gateway: 10.23.23.1
81+ """).rstrip(' '),
82+ },
83 'all': {
84 'expected_eni': ("""\
85 auto lo
86@@ -310,7 +371,7 @@ auto bond0
87 iface bond0 inet6 dhcp
88 bond-mode active-backup
89 bond-slaves none
90- hwaddress aa:bb:cc:dd:ee:ff
91+ hwaddress ether aa:bb:cc:dd:ee:ff
92
93 auto br0
94 iface br0 inet static
95@@ -780,6 +841,20 @@ class TestEniRoundTrip(CiTestCase):
96 entry['expected_eni'].splitlines(),
97 files['/etc/network/interfaces'].splitlines())
98
99+ def testsimple_render_interfaces_ipv6_aliases(self):
100+ entry = NETWORK_CONFIGS['ipv6_aliases']
101+ files = self._render_and_read(network_config=yaml.load(entry['yaml']))
102+ self.assertEqual(
103+ entry['expected_eni'].splitlines(),
104+ files['/etc/network/interfaces'].splitlines())
105+
106+ def testsimple_render_interfaces_ipv4_multiple_aliases(self):
107+ entry = NETWORK_CONFIGS['ipv4_multiple_aliases']
108+ files = self._render_and_read(network_config=yaml.load(entry['yaml']))
109+ self.assertEqual(
110+ entry['expected_eni'].splitlines(),
111+ files['/etc/network/interfaces'].splitlines())
112+
113 def test_routes_rendered(self):
114 # as reported in bug 1649652
115 conf = [

Subscribers

People subscribed via source and target branches