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
diff --git a/curtin/net/deps.py b/curtin/net/deps.py
index cbebae9..fd9e3c0 100644
--- a/curtin/net/deps.py
+++ b/curtin/net/deps.py
@@ -27,8 +27,15 @@ def network_config_required_packages(network_config, mapping=None):
27 for device in network_config['config'])27 for device in network_config['config'])
28 else:28 else:
29 # v2 has no config key29 # v2 has no config key
30 dev_configs = set(cfgtype for (cfgtype, cfg) in30 dev_configs = set()
31 network_config.items() if cfgtype not in ['version'])31 for cfgtype, cfg in network_config.items():
32 if cfgtype == 'version':
33 continue
34 dev_configs.add(cfgtype)
35 # the renderer type may trigger package adds
36 for entry, entry_cfg in cfg.items():
37 if entry_cfg.get('renderer'):
38 dev_configs.add(entry_cfg.get('renderer'))
3239
33 needed_packages = []40 needed_packages = []
34 for dev_type in dev_configs:41 for dev_type in dev_configs:
@@ -50,6 +57,9 @@ def detect_required_packages_mapping(osfamily=DISTROS.debian):
50 'bonds': ['ifenslave'],57 'bonds': ['ifenslave'],
51 'bridge': ['bridge-utils'],58 'bridge': ['bridge-utils'],
52 'bridges': ['bridge-utils'],59 'bridges': ['bridge-utils'],
60 'openvswitch': ['openvswitch-switch'],
61 'networkd': ['systemd'],
62 'NetworkManager': ['network-manager'],
53 'vlan': ['vlan'],63 'vlan': ['vlan'],
54 'vlans': ['vlan']},64 'vlans': ['vlan']},
55 DISTROS.redhat: {65 DISTROS.redhat: {
@@ -57,6 +67,7 @@ def detect_required_packages_mapping(osfamily=DISTROS.debian):
57 'bonds': [],67 'bonds': [],
58 'bridge': [],68 'bridge': [],
59 'bridges': [],69 'bridges': [],
70 'openvswitch': ['openvswitch-switch'],
60 'vlan': [],71 'vlan': [],
61 'vlans': []},72 'vlans': []},
62 }73 }
diff --git a/examples/tests/network_v2_ovs.yaml b/examples/tests/network_v2_ovs.yaml
63new file mode 10064474new file mode 100644
index 0000000..6d1dc3d
--- /dev/null
+++ b/examples/tests/network_v2_ovs.yaml
@@ -0,0 +1,42 @@
1# example netplan config with openvswitch support
2# showtrace: true
3network:
4 version: 2
5 ethernets:
6 eth0:
7 dhcp4: true
8 match:
9 macaddress: '52:54:00:12:34:00'
10 set-name: eth0
11 eth1:
12 match:
13 macaddress: '52:54:00:12:34:02'
14 set-name: eth1
15 eth2:
16 match:
17 macaddress: '52:54:00:12:34:04'
18 set-name: eth2
19 openvswitch:
20 bridges:
21 br-int:
22 fail-mode: secure
23 datapath_type: system
24 stp: false
25 rstp: false
26 mcast-snooping: false
27 controller:
28 addresses:
29 - tcp:127.0.0.1:6653
30 protocols:
31 - OpenFlow10
32 - OpenFlow12
33 - OpenFlow13
34 ports:
35 patch-tun:
36 type: patch
37 options:
38 peer: patch-int
39 eth1:
40 tag: 2
41 eth2:
42 tag: 2
diff --git a/tests/unittests/test_curthooks.py b/tests/unittests/test_curthooks.py
index 3fefd26..ff38240 100644
--- a/tests/unittests/test_curthooks.py
+++ b/tests/unittests/test_curthooks.py
@@ -984,11 +984,24 @@ class TestDetectRequiredPackages(CiTestCase):
984 {'type': 'static', 'address': '192.168.14.2/24'},984 {'type': 'static', 'address': '192.168.14.2/24'},
985 {'type': 'static', 'address': '2001:1::1/64'}]}},985 {'type': 'static', 'address': '2001:1::1/64'}]}},
986 2: {986 2: {
987 'vlan': {987 'openvswitch': {
988 'openvswitch': {
989 'bridges': {
990 'br-int': {'ports': {'eth15': {'tag': 2}}}}}},
991 'vlans': {
988 'vlans': {992 'vlans': {
989 'en-intra': {'id': 1, 'link': 'eno1', 'dhcp4': 'yes'},993 'en-intra': {'id': 1, 'link': 'eno1', 'dhcp4': 'yes'},
990 'en-vpn': {'id': 2, 'link': 'eno1'}}},994 'en-vpn': {'id': 2, 'link': 'eno1'}}},
991 'bridge': {995 'renderers': {
996 'bridges': {
997 'br-ext': {'renderer': 'openvswitch',
998 'ports': {'eth7': {'tag': 9}}}},
999 'wifis': {
1000 'wlps0': {'renderer': 'NetworkManager',
1001 'dhcp4': True}},
1002 'ethernets': {
1003 'ens7p0': {'renderer': 'networkd', 'dhcp6': True}}},
1004 'bridges': {
992 'bridges': {1005 'bridges': {
993 'br0': {1006 'br0': {
994 'interfaces': ['wlp1s0', 'switchports'],1007 'interfaces': ['wlp1s0', 'switchports'],
@@ -1014,6 +1027,8 @@ class TestDetectRequiredPackages(CiTestCase):
1014 def _test_req_mappings(self, req_mappings):1027 def _test_req_mappings(self, req_mappings):
1015 for (config_items, expected_reqs) in req_mappings:1028 for (config_items, expected_reqs) in req_mappings:
1016 cfg = self._fmt_config(config_items)1029 cfg = self._fmt_config(config_items)
1030 print('test_config:\n%s' % config.dump_config(cfg))
1031 print()
1017 actual_reqs = curthooks.detect_required_packages(cfg)1032 actual_reqs = curthooks.detect_required_packages(cfg)
1018 self.assertEqual(set(actual_reqs), set(expected_reqs),1033 self.assertEqual(set(actual_reqs), set(expected_reqs),
1019 'failed for config: {}'.format(config_items))1034 'failed for config: {}'.format(config_items))
@@ -1084,27 +1099,52 @@ class TestDetectRequiredPackages(CiTestCase):
1084 ('e2fsprogs', '^btrfs-(progs|tools)$', 'vlan', 'ifenslave')),1099 ('e2fsprogs', '^btrfs-(progs|tools)$', 'vlan', 'ifenslave')),
1085 ))1100 ))
10861101
1087 def test_network_v2_detect(self):1102 def test_network_v2_detect_bridges(self):
1088 self._test_req_mappings((1103 self._test_req_mappings((
1089 ({'network': {1104 ({'network': {
1090 'version': 2,1105 'version': 2,
1091 'items': ('bridge',)}},1106 'items': ('bridges',)}},
1092 ('bridge-utils', )),1107 ('bridge-utils', )),
1108 ))
1109
1110 def test_network_v2_detect_vlan(self):
1111 self._test_req_mappings((
1093 ({'network': {1112 ({'network': {
1094 'version': 2,1113 'version': 2,
1095 'items': ('vlan',)}},1114 'items': ('vlans',)}},
1096 ('vlan',)),1115 ('vlan',)),
1116 ))
1117
1118 def test_network_v2_detect_openvswitch(self):
1119 self._test_req_mappings((
1120 ({'network': {
1121 'version': 2,
1122 'items': ('openvswitch',)}},
1123 ('openvswitch-switch', )),
1124 ))
1125
1126 def test_network_v2_detect_renderers(self):
1127 self._test_req_mappings((
1128 ({'network': {
1129 'version': 2,
1130 'items': ('renderers',)}},
1131 ('bridge-utils', 'openvswitch-switch',
1132 'systemd', 'network-manager', )),
1133 ))
1134
1135 def test_network_v2_detect_all(self):
1136 self._test_req_mappings((
1097 ({'network': {1137 ({'network': {
1098 'version': 2,1138 'version': 2,
1099 'items': ('vlan', 'bridge')}},1139 'items': ('vlans', 'bridges', 'openvswitch')}},
1100 ('bridge-utils', 'vlan')),1140 ('bridge-utils', 'vlan', 'openvswitch-switch')),
1101 ))1141 ))
11021142
1103 def test_mixed_storage_v1_network_v2_detect(self):1143 def test_mixed_storage_v1_network_v2_detect(self):
1104 self._test_req_mappings((1144 self._test_req_mappings((
1105 ({'network': {1145 ({'network': {
1106 'version': 2,1146 'version': 2,
1107 'items': ('bridge', 'vlan')},1147 'items': ('bridges', 'vlans')},
1108 'storage': {1148 'storage': {
1109 'version': 1,1149 'version': 1,
1110 'items': ('raid', 'bcache', 'ext4')}},1150 'items': ('raid', 'bcache', 'ext4')}},
diff --git a/tests/vmtests/test_network_ovs.py b/tests/vmtests/test_network_ovs.py
1111new file mode 1006441151new file mode 100644
index 0000000..3e23bd0
--- /dev/null
+++ b/tests/vmtests/test_network_ovs.py
@@ -0,0 +1,45 @@
1# This file is part of curtin. See LICENSE file for copyright and license info.
2
3from .releases import base_vm_classes as relbase
4from .test_network import TestNetworkBaseTestsAbs
5
6
7class TestNetworkOvsAbs(TestNetworkBaseTestsAbs):
8 """ This class only needs to verify that when provided a v2 config
9 that on Bionic+ openvswitch packages are installed. """
10 conf_file = "examples/tests/network_v2_ovs.yaml"
11
12 def test_openvswitch_package_status(self):
13 """openvswitch-switch is expected installed in Ubuntu >= bionic."""
14 rel = self.target_release
15 pkg = "openvswitch-switch"
16 self.assertIn(
17 pkg, self.debian_packages,
18 "%s package expected in %s but not found" % (pkg, rel))
19
20 def test_etc_network_interfaces(self):
21 pass
22
23 def test_ip_output(self):
24 pass
25
26 def test_etc_resolvconf(self):
27 pass
28
29 def test_bridge_params(self):
30 pass
31
32
33class BionicTestNetworkOvs(relbase.bionic, TestNetworkOvsAbs):
34 __test__ = True
35
36
37class EoanTestNetworkOvs(relbase.eoan, TestNetworkOvsAbs):
38 __test__ = True
39
40
41class FocalTestNetworkOvs(relbase.focal, TestNetworkOvsAbs):
42 __test__ = True
43
44
45# vi: ts=4 expandtab syntax=python

Subscribers

People subscribed via source and target branches