Merge ~smoser/cloud-init:feature/curtin-centos7 into cloud-init:master

Proposed by Scott Moser
Status: Merged
Merged at revision: 811ce49d74afb158b2626a201ef5c714d5c9b059
Proposed branch: ~smoser/cloud-init:feature/curtin-centos7
Merge into: cloud-init:master
Diff against target: 175 lines (+91/-1)
3 files modified
cloudinit/net/eni.py (+1/-1)
cloudinit/net/sysconfig.py (+5/-0)
tests/unittests/test_net.py (+85/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Ryan Harper Approve
Review via email: mp+327836@code.launchpad.net

Commit message

I plan to squash the
 tests: add tests for mtu for eni, netplan and sysconfig.
commit into
 sysconfig: enable mtu set per subnet, including ipv6 mtu
and then just pull the 2 commits into master.

To post a comment you must log in.
Revision history for this message
Ryan Harper (raharper) wrote :

ACK

review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:19f0f36d6cf2daeb91b0194157c7393383e4df57
https://jenkins.ubuntu.com/server/job/cloud-init-ci/69/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: CentOS 6 & 7: Build & Test
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/69/rebuild

review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:811ce49d74afb158b2626a201ef5c714d5c9b059
https://jenkins.ubuntu.com/server/job/cloud-init-ci/70/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: CentOS 6 & 7: Build & Test
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/70/rebuild

review: Approve (continuous-integration)

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 b707146..bb80ec0 100644
3--- a/cloudinit/net/eni.py
4+++ b/cloudinit/net/eni.py
5@@ -355,7 +355,7 @@ class Renderer(renderer.Renderer):
6 default_gw = " default gw %s" % route['gateway']
7 content.append(up + default_gw + or_true)
8 content.append(down + default_gw + or_true)
9- elif route['network'] == '::' and route['netmask'] == 0:
10+ elif route['network'] == '::' and route['prefix'] == 0:
11 # ipv6!
12 default_gw = " -A inet6 default gw %s" % route['gateway']
13 content.append(up + default_gw + or_true)
14diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
15index b0f2ccf..c7df36c 100644
16--- a/cloudinit/net/sysconfig.py
17+++ b/cloudinit/net/sysconfig.py
18@@ -273,6 +273,7 @@ class Renderer(renderer.Renderer):
19
20 # modifying base values according to subnets
21 for i, subnet in enumerate(subnets, start=len(iface_cfg.children)):
22+ mtu_key = 'MTU'
23 subnet_type = subnet.get('type')
24 if subnet_type == 'dhcp6':
25 iface_cfg['IPV6INIT'] = True
26@@ -292,7 +293,11 @@ class Renderer(renderer.Renderer):
27 # if iface_cfg['BOOTPROTO'] == 'none':
28 # iface_cfg['BOOTPROTO'] = 'static'
29 if subnet_is_ipv6(subnet):
30+ mtu_key = 'IPV6_MTU'
31 iface_cfg['IPV6INIT'] = True
32+
33+ if 'mtu' in subnet:
34+ iface_cfg[mtu_key] = subnet['mtu']
35 else:
36 raise ValueError("Unknown subnet type '%s' found"
37 " for interface '%s'" % (subnet_type,
38diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
39index e625934..d15cd1f 100644
40--- a/tests/unittests/test_net.py
41+++ b/tests/unittests/test_net.py
42@@ -482,6 +482,62 @@ NETWORK_CONFIGS = {
43 - {'type': 'dhcp6'}
44 """).rstrip(' '),
45 },
46+ 'v4_and_v6_static': {
47+ 'expected_eni': textwrap.dedent("""\
48+ auto lo
49+ iface lo inet loopback
50+
51+ auto iface0
52+ iface iface0 inet static
53+ address 192.168.14.2/24
54+ mtu 9000
55+
56+ # control-alias iface0
57+ iface iface0 inet6 static
58+ address 2001:1::1/64
59+ mtu 1500
60+ """).rstrip(' '),
61+ 'expected_netplan': textwrap.dedent("""
62+ network:
63+ version: 2
64+ ethernets:
65+ iface0:
66+ addresses:
67+ - 192.168.14.2/24
68+ - 2001:1::1/64
69+ mtu: 9000
70+ mtu6: 1500
71+ """).rstrip(' '),
72+ 'yaml': textwrap.dedent("""\
73+ version: 1
74+ config:
75+ - type: 'physical'
76+ name: 'iface0'
77+ subnets:
78+ - type: static
79+ address: 192.168.14.2/24
80+ mtu: 9000
81+ - type: static
82+ address: 2001:1::1/64
83+ mtu: 1500
84+ """).rstrip(' '),
85+ 'expected_sysconfig': {
86+ 'ifcfg-iface0': textwrap.dedent("""\
87+ BOOTPROTO=none
88+ DEVICE=iface0
89+ IPADDR=192.168.14.2
90+ IPV6ADDR=2001:1::1/64
91+ IPV6INIT=yes
92+ NETMASK=255.255.255.0
93+ NM_CONTROLLED=no
94+ ONBOOT=yes
95+ TYPE=Ethernet
96+ USERCTL=no
97+ MTU=9000
98+ IPV6_MTU=1500
99+ """),
100+ },
101+ },
102 'all': {
103 'expected_eni': ("""\
104 auto lo
105@@ -541,6 +597,8 @@ iface br0 inet static
106 # control-alias br0
107 iface br0 inet6 static
108 address 2001:1::1/64
109+ post-up route add -A inet6 default gw 2001:4800:78ff:1b::1 || true
110+ pre-down route del -A inet6 default gw 2001:4800:78ff:1b::1 || true
111
112 auto bond0.200
113 iface bond0.200 inet dhcp
114@@ -675,6 +733,9 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true
115 eth3: 50
116 eth4: 75
117 priority: 22
118+ routes:
119+ - to: ::/0
120+ via: 2001:4800:78ff:1b::1
121 vlans:
122 bond0.200:
123 dhcp4: true
124@@ -807,6 +868,10 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true
125 address: 192.168.14.2/24
126 - type: static
127 address: 2001:1::1/64 # default to /64
128+ routes:
129+ - gateway: 2001:4800:78ff:1b::1
130+ netmask: '::'
131+ network: '::'
132 # A global nameserver.
133 - type: nameserver
134 address: 8.8.8.8
135@@ -1499,6 +1564,12 @@ USERCTL=no
136 self._compare_files_to_expected(entry['expected_sysconfig'], found)
137 self._assert_headers(found)
138
139+ def test_v4_and_v6_static_config(self):
140+ entry = NETWORK_CONFIGS['v4_and_v6_static']
141+ found = self._render_and_read(network_config=yaml.load(entry['yaml']))
142+ self._compare_files_to_expected(entry['expected_sysconfig'], found)
143+ self._assert_headers(found)
144+
145
146 class TestEniNetRendering(CiTestCase):
147
148@@ -1892,6 +1963,13 @@ class TestNetplanRoundTrip(CiTestCase):
149 entry['expected_netplan'].splitlines(),
150 files['/etc/netplan/50-cloud-init.yaml'].splitlines())
151
152+ def testsimple_render_v4_and_v6_static(self):
153+ entry = NETWORK_CONFIGS['v4_and_v6_static']
154+ files = self._render_and_read(network_config=yaml.load(entry['yaml']))
155+ self.assertEqual(
156+ entry['expected_netplan'].splitlines(),
157+ files['/etc/netplan/50-cloud-init.yaml'].splitlines())
158+
159 def testsimple_render_all(self):
160 entry = NETWORK_CONFIGS['all']
161 files = self._render_and_read(network_config=yaml.load(entry['yaml']))
162@@ -1950,6 +2028,13 @@ class TestEniRoundTrip(CiTestCase):
163 entry['expected_eni'].splitlines(),
164 files['/etc/network/interfaces'].splitlines())
165
166+ def testsimple_render_v4_and_v6_static(self):
167+ entry = NETWORK_CONFIGS['v4_and_v6_static']
168+ files = self._render_and_read(network_config=yaml.load(entry['yaml']))
169+ self.assertEqual(
170+ entry['expected_eni'].splitlines(),
171+ files['/etc/network/interfaces'].splitlines())
172+
173 def testsimple_render_manual(self):
174 entry = NETWORK_CONFIGS['manual']
175 files = self._render_and_read(network_config=yaml.load(entry['yaml']))

Subscribers

People subscribed via source and target branches