diff options
| author | Sulochan Acharya <sulochan@gmail.com> | 2012-09-17 11:42:07 -0500 |
|---|---|---|
| committer | Sulochan Acharya <sulochan@gmail.com> | 2012-09-20 04:47:10 -0500 |
| commit | 9a303f2cc231f5d43257ebced5b1167c08d32648 (patch) | |
| tree | a2dac926358190a8208c6bfdf0686cd819d7d11b /nova/tests | |
| parent | 9536b3fa9861e4b9c93b5cf0a91451a92c5df92c (diff) | |
Catch NotFound exception in FloatingIP add/remove
Catch the FloatingIPNotFoundForAddress exception for add/remove
operations in floating ip extension for non existing floating ips.
Fixes bug 977536
Change-Id: Ied450aa56ef7a52a015c6d78a099d445ab6258b6
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/api/openstack/compute/contrib/test_floating_ips.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/nova/tests/api/openstack/compute/contrib/test_floating_ips.py b/nova/tests/api/openstack/compute/contrib/test_floating_ips.py index f7788101c..e9cfc2b9e 100644 --- a/nova/tests/api/openstack/compute/contrib/test_floating_ips.py +++ b/nova/tests/api/openstack/compute/contrib/test_floating_ips.py @@ -328,6 +328,39 @@ class FloatingIpTest(test.TestCase): rsp = self.manager._remove_floating_ip(req, 'test_inst', body) self.assertTrue(rsp.status_int == 404) + def test_floating_ip_associate_non_existent_ip(self): + def fake_network_api_associate(self, context, instance, + floating_address=None, + fixed_address=None): + floating_ips = ["10.10.10.10", "10.10.10.11"] + if floating_address not in floating_ips: + raise exception.FloatingIpNotFoundForAddress() + + self.stubs.Set(network.api.API, "associate_floating_ip", + fake_network_api_associate) + + body = dict(addFloatingIp=dict(address='1.1.1.1')) + req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action') + self.assertRaises(webob.exc.HTTPNotFound, + self.manager._add_floating_ip, + req, 'test_inst', body) + + def test_floating_ip_disassociate_non_existent_ip(self): + def network_api_get_floating_ip_by_address(self, context, + floating_address): + floating_ips = ["10.10.10.10", "10.10.10.11"] + if floating_address not in floating_ips: + raise exception.FloatingIpNotFoundForAddress() + + self.stubs.Set(network.api.API, "get_floating_ip_by_address", + network_api_get_floating_ip_by_address) + + body = dict(removeFloatingIp=dict(address='1.1.1.1')) + req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action') + self.assertRaises(webob.exc.HTTPNotFound, + self.manager._remove_floating_ip, + req, 'test_inst', body) + def test_floating_ip_disassociate_wrong_instance_uuid(self): def get_instance_by_floating_ip_addr(self, context, address): if address == '10.10.10.10': |
