# rows since the interface identifier is unique
data = json_result['data'][0]
port_name = data[name_idx]
+ switch = get_bridge_for_iface(self.root_helper, port_name)
+ if switch != self.br_name:
+ LOG.info(_("Port: %(port_name)s is on %(switch)s,"
+ " not on %(br_name)s"), {'port_name': port_name,
+ 'switch': switch,
+ 'br_name': self.br_name})
+ return
ofport = data[ofport_idx]
# ofport must be integer otherwise return None
if not isinstance(ofport, int) or ofport == -1:
with testtools.ExpectedException(Exception):
self.br.get_local_port_mac()
- def _test_get_vif_port_by_id(self, iface_id, data):
+ def _test_get_vif_port_by_id(self, iface_id, data, br_name=None):
headings = ['external_ids', 'name', 'ofport']
# Each element is a tuple of (expected mock call, return_value)
expected_calls_and_values = [
'external_ids:iface-id="%s"' % iface_id],
root_helper=self.root_helper),
self._encode_ovs_json(headings, data))]
+ if data:
+ if not br_name:
+ br_name = self.BR_NAME
+ expected_calls_and_values.append(
+ (mock.call(["ovs-vsctl", self.TO,
+ "iface-to-br", data[0][headings.index('name')]],
+ root_helper=self.root_helper),
+ br_name))
tools.setup_mock_calls(self.execute, expected_calls_and_values)
vif_port = self.br.get_vif_port_by_id(iface_id)
def test_get_vif_by_port_id_with_no_data(self):
self.assertIsNone(self._test_get_vif_port_by_id('whatever', []))
+
+ def test_get_vif_by_port_id_different_bridge(self):
+ external_ids = [["iface-id", "tap99id"],
+ ["iface-status", "active"]]
+ data = [[["map", external_ids], "tap99", 1]]
+ self.assertIsNone(self._test_get_vif_port_by_id('tap99id', data,
+ "br-ext"))