get_vif_ports: ignore non-Interface ports
This patch updates get_vif_ports so that it skips ports which aren't in the 'Interfaces' table. This fixes an issue where neutron-ovs-cleanup would fail if any sort of OVS bond was on the bridge getting cleaned up. This is because bonds don't have the same attributes as ports, and thus fail subsequent ovs-vsctl queries. Change-Id: Ic9d30e5916122ce23c5dc8631fbb71115ae8a960 Closes-bug: #1473179
This commit is contained in:
parent
c499fe5019
commit
dfbe804994
|
@ -329,6 +329,10 @@ class OVSBridge(BaseOVS):
|
||||||
'Interface', columns=['name', 'external_ids', 'ofport'])
|
'Interface', columns=['name', 'external_ids', 'ofport'])
|
||||||
by_name = {x['name']: x for x in port_info}
|
by_name = {x['name']: x for x in port_info}
|
||||||
for name in port_names:
|
for name in port_names:
|
||||||
|
if not by_name.get(name):
|
||||||
|
#NOTE(dprince): some ports (like bonds) won't have all
|
||||||
|
# these attributes so we skip them entirely
|
||||||
|
continue
|
||||||
external_ids = by_name[name]['external_ids']
|
external_ids = by_name[name]['external_ids']
|
||||||
ofport = by_name[name]['ofport']
|
ofport = by_name[name]['ofport']
|
||||||
if "iface-id" in external_ids and "attached-mac" in external_ids:
|
if "iface-id" in external_ids and "attached-mac" in external_ids:
|
||||||
|
|
|
@ -577,6 +577,23 @@ class OVS_Lib_Test(base.BaseTestCase):
|
||||||
def test_get_vif_ports_xen(self):
|
def test_get_vif_ports_xen(self):
|
||||||
self._test_get_vif_ports(is_xen=True)
|
self._test_get_vif_ports(is_xen=True)
|
||||||
|
|
||||||
|
def test_get_vif_ports_with_bond(self):
|
||||||
|
pname = "bond0"
|
||||||
|
#NOTE(dprince): bond ports don't have records in the Interface table
|
||||||
|
external_ids = ('{"data":[], "headings":[]}')
|
||||||
|
|
||||||
|
# Each element is a tuple of (expected mock call, return_value)
|
||||||
|
expected_calls_and_values = [
|
||||||
|
(self._vsctl_mock("list-ports", self.BR_NAME), "%s\n" % pname),
|
||||||
|
(self._vsctl_mock("--columns=name,external_ids,ofport", "list",
|
||||||
|
"Interface"), external_ids),
|
||||||
|
]
|
||||||
|
tools.setup_mock_calls(self.execute, expected_calls_and_values)
|
||||||
|
|
||||||
|
ports = self.br.get_vif_ports()
|
||||||
|
self.assertEqual(0, len(ports))
|
||||||
|
tools.verify_mock_calls(self.execute, expected_calls_and_values)
|
||||||
|
|
||||||
def test_get_vif_port_set_nonxen(self):
|
def test_get_vif_port_set_nonxen(self):
|
||||||
self._test_get_vif_port_set(False)
|
self._test_get_vif_port_set(False)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue