diff options
| author | Jenkins <jenkins@review.openstack.org> | 2011-10-27 14:51:34 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2011-10-27 14:51:34 +0000 |
| commit | 6c039120f54e4d8fa99f9e09148879de4dc04bb2 (patch) | |
| tree | 773d4f2a3cb8e72f210f7786a4841eb297108ea4 | |
| parent | 1b7fba648aa3eb4cdda345237c9f77dc0b229329 (diff) | |
| parent | 636c70c3c990d0405c7e05a428d78908dc8b4317 (diff) | |
Merge "Fix deletion of instances without fixed ips."
| -rw-r--r-- | Authors | 1 | ||||
| -rw-r--r-- | nova/network/manager.py | 5 | ||||
| -rw-r--r-- | nova/tests/test_network.py | 27 |
3 files changed, 32 insertions, 1 deletions
@@ -12,6 +12,7 @@ Anthony Young <sleepsonthefloor@gmail.com> Antony Messerli <ant@openstack.org> Armando Migliaccio <Armando.Migliaccio@eu.citrix.com> Arvind Somya <asomya@cisco.com> +Asbjørn Sannes <asbjorn.sannes@interhost.no> Ben McGraw <ben@pistoncloud.com> Bilal Akhtar <bilalakhtar@ubuntu.com> Brad Hall <brad@nicira.com> diff --git a/nova/network/manager.py b/nova/network/manager.py index f1070f960..ea6bdb5d4 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -250,7 +250,10 @@ class FloatingIP(object): LOG.debug(_("floating IP deallocation for instance |%s|"), instance_id, context=context) - fixed_ips = self.db.fixed_ip_get_by_instance(context, instance_id) + try: + fixed_ips = self.db.fixed_ip_get_by_instance(context, instance_id) + except exception.FixedIpNotFoundForInstance: + fixed_ips = [] # add to kwargs so we can pass to super to save a db lookup there kwargs['fixed_ips'] = fixed_ips for fixed_ip in fixed_ips: diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py index e3d27e091..17e79f39a 100644 --- a/nova/tests/test_network.py +++ b/nova/tests/test_network.py @@ -972,3 +972,30 @@ class CommonNetworkTestCase(test.TestCase): self.assertTrue(res) self.assertEqual(len(res), 1) self.assertEqual(res[0]['instance_id'], _vifs[2]['instance_id']) + + +class TestFloatingIPManager(network_manager.FloatingIP, + network_manager.NetworkManager): + """Dummy manager that implements FloatingIP""" + + +class FloatingIPTestCase(test.TestCase): + """Tests nova.network.manager.FloatingIP""" + def setUp(self): + super(FloatingIPTestCase, self).setUp() + self.network = TestFloatingIPManager() + self.network.db = db + self.project_id = 'testproject' + self.context = context.RequestContext('testuser', self.project_id, + is_admin=False) + + def test_double_deallocation(self): + instance_ref = db.api.instance_create(self.context, + {"project_id": self.project_id}) + # Run it twice to make it fault if it does not handle + # instances without fixed networks + # If this fails in either, it does not handle having no addresses + self.network.deallocate_for_instance(self.context, + instance_id=instance_ref['id']) + self.network.deallocate_for_instance(self.context, + instance_id=instance_ref['id']) |
