]> git.proxmox.com Git - ifupdown2.git/blame - debian/patches/extra/0003-ovs-multiple-ovsport.patch
add patch 0008-openvswitch-ovs-ports-condone-regex-exclude-tap-veth.patch
[ifupdown2.git] / debian / patches / extra / 0003-ovs-multiple-ovsport.patch
CommitLineData
6bf2953c
AD
1From 6cdb2b3d220fdf60ea8d0a2982a90c583dec467e Mon Sep 17 00:00:00 2001
2From: Alexandre Derumier <aderumier@odiso.com>
3Date: Thu, 28 May 2020 11:21:55 +0200
4Subject: [PATCH] addons: openvswitch: allow multiple ovs-ports + glob/regex
5
6---
7 ifupdown2/addons/openvswitch.py | 18 +++++++++++++++---
8 1 file changed, 15 insertions(+), 3 deletions(-)
9
10diff --git a/ifupdown2/addons/openvswitch.py b/ifupdown2/addons/openvswitch.py
11index 468d7df..936c871 100644
12--- a/ifupdown2/addons/openvswitch.py
13+++ b/ifupdown2/addons/openvswitch.py
14@@ -37,6 +37,12 @@ class openvswitch(Addon, moduleBase):
15 'help': 'Interfaces to be part of this ovs bridge.',
16 'validvals': ['<interface-list>'],
17 'required': False,
18+ "multivalue": True,
19+ "example": [
20+ "ovs-ports swp1.100 swp2.100 swp3.100",
21+ "ovs-ports glob swp1-3.100",
22+ "ovs-ports regex (swp[1|2|3].100)"
23+ ]
24 },
25 'ovs-type': {
26 'help': 'ovs interface type',
27@@ -87,10 +93,15 @@ def _is_ovs_bridge (self, ifaceobj):
28 return False
29
30 def _get_ovs_ports (self, ifaceobj):
31- ovs_ports = ifaceobj.get_attr_value_first('ovs-ports')
32+ ovs_ports = []
33+
34+ for port in ifaceobj.get_attr_value('ovs-ports') or []:
35+ ovs_ports.extend(port.split())
36+
37 if ovs_ports:
38- return sorted (ovs_ports.split ())
39- return None
40+ return self.parse_port_list(ifaceobj.name, ' '.join(ovs_ports))
41+ else:
42+ return None
43
44 def _get_running_ovs_ports (self, iface):
45 output = utils.exec_command("/usr/bin/ovs-vsctl list-ports %s" %iface)
46@@ -152,6 +163,7 @@ def _addbridge (self, ifaceobj):
47 ovs_ports = self._get_ovs_ports(ifaceobj)
48 running_ovs_ports = self._get_running_ovs_ports(iface)
49
50+ missingports = []
51 if running_ovs_ports is not None and ovs_ports is not None:
52 missingports = list(set(running_ovs_ports) - set(ovs_ports))
53