From 1ef65cea7b15357eba5a03dcbe9bdf44a2679b46 Mon Sep 17 00:00:00 2001 From: armando-migliaccio Date: Mon, 28 Apr 2014 14:18:06 -0700 Subject: [PATCH] NSX: do not raise on missing router during migration step Return None for missing router rather raising NotFound exception; this is what the client code was expected to handle in the first place. Closes-bug: 1313918 Change-Id: I573770a69d0170b027fc990c29aaa87b1fc8eccc (cherry picked from commit 5e843850527ede7a56fcc24753f87c1e9e3e8bed) --- neutron/plugins/vmware/dhcp_meta/migration.py | 2 -- neutron/tests/unit/vmware/test_dhcpmeta.py | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/neutron/plugins/vmware/dhcp_meta/migration.py b/neutron/plugins/vmware/dhcp_meta/migration.py index 992a88346..0f1b32b77 100644 --- a/neutron/plugins/vmware/dhcp_meta/migration.py +++ b/neutron/plugins/vmware/dhcp_meta/migration.py @@ -58,8 +58,6 @@ class DhcpMetadataBuilder(object): for port in ports: if port['fixed_ips'][0]['subnet_id'] == subnet['id']: return port['device_id'] - else: - raise n_exc.NotFound() def metadata_deallocate(self, context, router_id, subnet_id): """Deallocate metadata services for the subnet.""" diff --git a/neutron/tests/unit/vmware/test_dhcpmeta.py b/neutron/tests/unit/vmware/test_dhcpmeta.py index 088cb2ddf..ec1e408c1 100644 --- a/neutron/tests/unit/vmware/test_dhcpmeta.py +++ b/neutron/tests/unit/vmware/test_dhcpmeta.py @@ -71,6 +71,11 @@ class DhcpMetadataBuilderTestCase(base.BaseTestCase): def test_router_id_get_none_subnet(self): self.assertIsNone(self.builder.router_id_get(mock.ANY, None)) + def test_router_id_get_none_no_router(self): + self.builder.plugin.get_ports.return_value = [] + subnet = {'network_id': self.network_id} + self.assertIsNone(self.builder.router_id_get(mock.ANY, subnet)) + def test_metadata_deallocate(self): self.builder.metadata_deallocate( mock.ANY, self.router_id, self.subnet_id) -- 2.45.2