Merge ~raharper/curtin:feature/enable-ovs into curtin:master

Proposed by Ryan Harper
Status: Merged
Approved by: Ryan Harper
Approved revision: 6814799023abe43bb60a4d2adc8eb95e029c2156
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~raharper/curtin:feature/enable-ovs
Merge into: curtin:master
Diff against target: 238 lines (+148/-10)
4 files modified
curtin/net/deps.py (+13/-2)
examples/tests/network_v2_ovs.yaml (+42/-0)
tests/unittests/test_curthooks.py (+48/-8)
tests/vmtests/test_network_ovs.py (+45/-0)
Reviewer Review Type Date Requested Status
Chad Smith Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+378680@code.launchpad.net

Commit message

net/deps.py: detect openvswitch cfg and install openvswitch packages

Scan the provided network-config and if openvswitch keywords are
present then install the require openvswitch packages into the
target system.

- Enable both version detections, top-level openvswitch and as
  renderer
- Also detect renderer values and install the required renderer
- Add vmtest to verify package is installed

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

This iteration looks good to me and is understandable.

I think we may have to circle back for a followup branch on whether DPDK type fields imply a different package name (like whether we need to additionally install openvswitch-switch-dpdk).

But, I think we can address that in a followup when we get more information.
+1 for now.

Revision history for this message
Chad Smith (chad.smith) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/net/deps.py b/curtin/net/deps.py
2index cbebae9..fd9e3c0 100644
3--- a/curtin/net/deps.py
4+++ b/curtin/net/deps.py
5@@ -27,8 +27,15 @@ def network_config_required_packages(network_config, mapping=None):
6 for device in network_config['config'])
7 else:
8 # v2 has no config key
9- dev_configs = set(cfgtype for (cfgtype, cfg) in
10- network_config.items() if cfgtype not in ['version'])
11+ dev_configs = set()
12+ for cfgtype, cfg in network_config.items():
13+ if cfgtype == 'version':
14+ continue
15+ dev_configs.add(cfgtype)
16+ # the renderer type may trigger package adds
17+ for entry, entry_cfg in cfg.items():
18+ if entry_cfg.get('renderer'):
19+ dev_configs.add(entry_cfg.get('renderer'))
20
21 needed_packages = []
22 for dev_type in dev_configs:
23@@ -50,6 +57,9 @@ def detect_required_packages_mapping(osfamily=DISTROS.debian):
24 'bonds': ['ifenslave'],
25 'bridge': ['bridge-utils'],
26 'bridges': ['bridge-utils'],
27+ 'openvswitch': ['openvswitch-switch'],
28+ 'networkd': ['systemd'],
29+ 'NetworkManager': ['network-manager'],
30 'vlan': ['vlan'],
31 'vlans': ['vlan']},
32 DISTROS.redhat: {
33@@ -57,6 +67,7 @@ def detect_required_packages_mapping(osfamily=DISTROS.debian):
34 'bonds': [],
35 'bridge': [],
36 'bridges': [],
37+ 'openvswitch': ['openvswitch-switch'],
38 'vlan': [],
39 'vlans': []},
40 }
41diff --git a/examples/tests/network_v2_ovs.yaml b/examples/tests/network_v2_ovs.yaml
42new file mode 100644
43index 0000000..6d1dc3d
44--- /dev/null
45+++ b/examples/tests/network_v2_ovs.yaml
46@@ -0,0 +1,42 @@
47+# example netplan config with openvswitch support
48+# showtrace: true
49+network:
50+ version: 2
51+ ethernets:
52+ eth0:
53+ dhcp4: true
54+ match:
55+ macaddress: '52:54:00:12:34:00'
56+ set-name: eth0
57+ eth1:
58+ match:
59+ macaddress: '52:54:00:12:34:02'
60+ set-name: eth1
61+ eth2:
62+ match:
63+ macaddress: '52:54:00:12:34:04'
64+ set-name: eth2
65+ openvswitch:
66+ bridges:
67+ br-int:
68+ fail-mode: secure
69+ datapath_type: system
70+ stp: false
71+ rstp: false
72+ mcast-snooping: false
73+ controller:
74+ addresses:
75+ - tcp:127.0.0.1:6653
76+ protocols:
77+ - OpenFlow10
78+ - OpenFlow12
79+ - OpenFlow13
80+ ports:
81+ patch-tun:
82+ type: patch
83+ options:
84+ peer: patch-int
85+ eth1:
86+ tag: 2
87+ eth2:
88+ tag: 2
89diff --git a/tests/unittests/test_curthooks.py b/tests/unittests/test_curthooks.py
90index 3fefd26..ff38240 100644
91--- a/tests/unittests/test_curthooks.py
92+++ b/tests/unittests/test_curthooks.py
93@@ -984,11 +984,24 @@ class TestDetectRequiredPackages(CiTestCase):
94 {'type': 'static', 'address': '192.168.14.2/24'},
95 {'type': 'static', 'address': '2001:1::1/64'}]}},
96 2: {
97- 'vlan': {
98+ 'openvswitch': {
99+ 'openvswitch': {
100+ 'bridges': {
101+ 'br-int': {'ports': {'eth15': {'tag': 2}}}}}},
102+ 'vlans': {
103 'vlans': {
104 'en-intra': {'id': 1, 'link': 'eno1', 'dhcp4': 'yes'},
105 'en-vpn': {'id': 2, 'link': 'eno1'}}},
106- 'bridge': {
107+ 'renderers': {
108+ 'bridges': {
109+ 'br-ext': {'renderer': 'openvswitch',
110+ 'ports': {'eth7': {'tag': 9}}}},
111+ 'wifis': {
112+ 'wlps0': {'renderer': 'NetworkManager',
113+ 'dhcp4': True}},
114+ 'ethernets': {
115+ 'ens7p0': {'renderer': 'networkd', 'dhcp6': True}}},
116+ 'bridges': {
117 'bridges': {
118 'br0': {
119 'interfaces': ['wlp1s0', 'switchports'],
120@@ -1014,6 +1027,8 @@ class TestDetectRequiredPackages(CiTestCase):
121 def _test_req_mappings(self, req_mappings):
122 for (config_items, expected_reqs) in req_mappings:
123 cfg = self._fmt_config(config_items)
124+ print('test_config:\n%s' % config.dump_config(cfg))
125+ print()
126 actual_reqs = curthooks.detect_required_packages(cfg)
127 self.assertEqual(set(actual_reqs), set(expected_reqs),
128 'failed for config: {}'.format(config_items))
129@@ -1084,27 +1099,52 @@ class TestDetectRequiredPackages(CiTestCase):
130 ('e2fsprogs', '^btrfs-(progs|tools)$', 'vlan', 'ifenslave')),
131 ))
132
133- def test_network_v2_detect(self):
134+ def test_network_v2_detect_bridges(self):
135 self._test_req_mappings((
136 ({'network': {
137 'version': 2,
138- 'items': ('bridge',)}},
139+ 'items': ('bridges',)}},
140 ('bridge-utils', )),
141+ ))
142+
143+ def test_network_v2_detect_vlan(self):
144+ self._test_req_mappings((
145 ({'network': {
146 'version': 2,
147- 'items': ('vlan',)}},
148+ 'items': ('vlans',)}},
149 ('vlan',)),
150+ ))
151+
152+ def test_network_v2_detect_openvswitch(self):
153+ self._test_req_mappings((
154+ ({'network': {
155+ 'version': 2,
156+ 'items': ('openvswitch',)}},
157+ ('openvswitch-switch', )),
158+ ))
159+
160+ def test_network_v2_detect_renderers(self):
161+ self._test_req_mappings((
162+ ({'network': {
163+ 'version': 2,
164+ 'items': ('renderers',)}},
165+ ('bridge-utils', 'openvswitch-switch',
166+ 'systemd', 'network-manager', )),
167+ ))
168+
169+ def test_network_v2_detect_all(self):
170+ self._test_req_mappings((
171 ({'network': {
172 'version': 2,
173- 'items': ('vlan', 'bridge')}},
174- ('bridge-utils', 'vlan')),
175+ 'items': ('vlans', 'bridges', 'openvswitch')}},
176+ ('bridge-utils', 'vlan', 'openvswitch-switch')),
177 ))
178
179 def test_mixed_storage_v1_network_v2_detect(self):
180 self._test_req_mappings((
181 ({'network': {
182 'version': 2,
183- 'items': ('bridge', 'vlan')},
184+ 'items': ('bridges', 'vlans')},
185 'storage': {
186 'version': 1,
187 'items': ('raid', 'bcache', 'ext4')}},
188diff --git a/tests/vmtests/test_network_ovs.py b/tests/vmtests/test_network_ovs.py
189new file mode 100644
190index 0000000..3e23bd0
191--- /dev/null
192+++ b/tests/vmtests/test_network_ovs.py
193@@ -0,0 +1,45 @@
194+# This file is part of curtin. See LICENSE file for copyright and license info.
195+
196+from .releases import base_vm_classes as relbase
197+from .test_network import TestNetworkBaseTestsAbs
198+
199+
200+class TestNetworkOvsAbs(TestNetworkBaseTestsAbs):
201+ """ This class only needs to verify that when provided a v2 config
202+ that on Bionic+ openvswitch packages are installed. """
203+ conf_file = "examples/tests/network_v2_ovs.yaml"
204+
205+ def test_openvswitch_package_status(self):
206+ """openvswitch-switch is expected installed in Ubuntu >= bionic."""
207+ rel = self.target_release
208+ pkg = "openvswitch-switch"
209+ self.assertIn(
210+ pkg, self.debian_packages,
211+ "%s package expected in %s but not found" % (pkg, rel))
212+
213+ def test_etc_network_interfaces(self):
214+ pass
215+
216+ def test_ip_output(self):
217+ pass
218+
219+ def test_etc_resolvconf(self):
220+ pass
221+
222+ def test_bridge_params(self):
223+ pass
224+
225+
226+class BionicTestNetworkOvs(relbase.bionic, TestNetworkOvsAbs):
227+ __test__ = True
228+
229+
230+class EoanTestNetworkOvs(relbase.eoan, TestNetworkOvsAbs):
231+ __test__ = True
232+
233+
234+class FocalTestNetworkOvs(relbase.focal, TestNetworkOvsAbs):
235+ __test__ = True
236+
237+
238+# vi: ts=4 expandtab syntax=python

Subscribers

People subscribed via source and target branches