Fix the cleanup issue of NeutronTrunk
Catch the exception in list(),otherwise break if neutron trunk is not found. Change-Id: Ied7d26c8e2d674601b2a5d83c5b9b5f7d60d3436
This commit is contained in:
parent
9ac1de7be4
commit
e4ee31047d
@ -390,7 +390,14 @@ class NeutronFloatingIP(NeutronMixin):
|
||||
tenant_resource=True)
|
||||
class NeutronTrunk(NeutronMixin):
|
||||
# Trunks must be deleted before the parent/subports are deleted
|
||||
pass
|
||||
|
||||
def list(self):
|
||||
try:
|
||||
return super(NeutronTrunk, self).list()
|
||||
except Exception as e:
|
||||
if getattr(e, "status_code", 400) == 404:
|
||||
return []
|
||||
raise
|
||||
|
||||
|
||||
@base.resource("neutron", "port", order=next(_neutron_order),
|
||||
|
@ -422,6 +422,31 @@ class NeutronFloatingIPTestCase(test.TestCase):
|
||||
tenant_id="foo")
|
||||
|
||||
|
||||
class NeutronTrunkTestcase(test.TestCase):
|
||||
|
||||
def test_list(self):
|
||||
user = mock.MagicMock()
|
||||
trunk = resources.NeutronTrunk(user=user)
|
||||
user.neutron().list_trunks.return_value = {
|
||||
"trunks": ["trunk"]}
|
||||
self.assertEqual(["trunk"], trunk.list())
|
||||
user.neutron().list_trunks.assert_called_once_with(
|
||||
tenant_id=None)
|
||||
|
||||
def test_list_with_not_found(self):
|
||||
|
||||
class NotFound(Exception):
|
||||
status_code = 404
|
||||
|
||||
user = mock.MagicMock()
|
||||
trunk = resources.NeutronTrunk(user=user)
|
||||
user.neutron().list_trunks.side_effect = NotFound()
|
||||
|
||||
self.assertEqual([], trunk.list())
|
||||
user.neutron().list_trunks.assert_called_once_with(
|
||||
tenant_id=None)
|
||||
|
||||
|
||||
class NeutronPortTestCase(test.TestCase):
|
||||
|
||||
def test_delete(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user