fixes bug 919055 allowing interfaces to be retrieved without device id

Change-Id: Ief7c881d55094f65f874c902c0b3ab394abf5f31
This commit is contained in:
rajarammallya 2012-01-20 18:06:13 +05:30
parent 11478ef187
commit 6b86a3b840
2 changed files with 9 additions and 8 deletions

View File

@ -779,7 +779,6 @@ class Interface(ModelBase):
def find_or_configure(cls, virtual_interface_id=None, device_id=None,
tenant_id=None, mac_address=None):
interface = Interface.get_by(virtual_interface_id=virtual_interface_id,
device_id=device_id,
tenant_id=tenant_id)
if interface:
return interface

View File

@ -2176,16 +2176,18 @@ class TestInterface(tests.BaseTest):
self.assertEqual(existing_interface, interface_found)
def test_find_or_configure_fails_if_vif_exists_for_another_device(self):
def test_find_or_configure_finds_without_device_id(self):
existing_interface = factory_models.InterfaceFactory(
virtual_interface_id="vif", device_id="device1", tenant_id="tnt")
self.assertRaises(models.InvalidModelError,
models.Interface.find_or_configure,
virtual_interface_id="vif",
device_id="device2",
virtual_interface_id="11234",
device_id="huge_instance",
tenant_id="tnt")
interface_found = models.Interface.find_or_configure(
virtual_interface_id="11234",
tenant_id="tnt")
self.assertEqual(existing_interface, interface_found)
def test_find_or_configure_fails_if_vif_exists_for_another_tenant(self):
existing_interface = factory_models.InterfaceFactory(
virtual_interface_id="vif", device_id="device", tenant_id="tnt1")