res_dict = getattr(self, '_fake_%s_dict' % resource_type)
if parent_uuid == '*':
parent_uuid = None
+ # NSX raises ResourceNotFound if lswitch doesn't exist and is not *
+ elif not res_dict and resource_type == self.LSWITCH_LPORT_RESOURCE:
+ raise api_exc.ResourceNotFound()
def _attr_match(res_uuid):
if not attr_filter:
self.assertIsNotNone(lport2)
self.assertEqual(lport['uuid'], lport2['uuid'])
- def test_get_port_by_tag_not_found_returns_None(self):
+ def test_get_port_by_tag_not_found_with_switch_id_raises_not_found(self):
tenant_id = 'pippo'
neutron_port_id = 'whatever'
transport_zones_config = [{'zone_uuid': _uuid(),
lswitch = switchlib.create_lswitch(
self.fake_cluster, tenant_id, _uuid(),
'fake-switch', transport_zones_config)
+ self.assertRaises(exceptions.NotFound,
+ switchlib.get_port_by_neutron_tag,
+ self.fake_cluster, lswitch['uuid'],
+ neutron_port_id)
+
+ def test_get_port_by_tag_not_find_wildcard_lswitch_returns_none(self):
+ tenant_id = 'pippo'
+ neutron_port_id = 'whatever'
+ transport_zones_config = [{'zone_uuid': _uuid(),
+ 'transport_type': 'stt'}]
+ switchlib.create_lswitch(
+ self.fake_cluster, tenant_id, _uuid(),
+ 'fake-switch', transport_zones_config)
lport = switchlib.get_port_by_neutron_tag(
- self.fake_cluster, lswitch['uuid'], neutron_port_id)
+ self.fake_cluster, '*', neutron_port_id)
self.assertIsNone(lport)
def test_get_port_status(self):