From 9d5f41ff5d799a4fe9f512840f35e2c1727ae488 Mon Sep 17 00:00:00 2001 From: mathieu-rohon Date: Mon, 19 Jan 2015 19:14:23 +0100 Subject: [PATCH] adapt UT to have a patch merge in Neutron This change is about to merge : Iae98f3fe89126a76f16ed9c5230ce299a09ce8d8 Since it modifies VMware NSX UT, I have to patch UT in both Neutron and stackforge/VMware-nsx projects Change-Id: I16199ee8d01036c435874ce7930f7c1e37af481c --- .../neutron/plugins/vmware/plugins/base.py | 20 +++++++++---------- .../tests/unit/vmware/apiclient/fake.py | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/vmware_nsx/neutron/plugins/vmware/plugins/base.py b/vmware_nsx/neutron/plugins/vmware/plugins/base.py index 34a1147658..6d4928413b 100644 --- a/vmware_nsx/neutron/plugins/vmware/plugins/base.py +++ b/vmware_nsx/neutron/plugins/vmware/plugins/base.py @@ -628,10 +628,10 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin, @lockutils.synchronized('vmware', 'neutron-') def _nsx_delete_ext_gw_port(self, context, port_data): - lr_port = self._find_router_gw_port(context, port_data) # TODO(salvatore-orlando): Handle NSX resource # rollback when something goes not quite as expected try: + lr_port = self._find_router_gw_port(context, port_data) # Delete is actually never a real delete, otherwise the NSX # logical router will stop working router_id = port_data['device_id'] @@ -651,19 +651,19 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin, lr_port['uuid'], "L3GatewayAttachment", self.cluster.default_l3_gw_service_uuid) - - except api_exc.ResourceNotFound: - raise nsx_exc.NsxPluginException( - err_msg=_("Logical router resource %s not found " - "on NSX platform") % router_id) + LOG.debug("_nsx_delete_ext_gw_port completed on external network " + "%(ext_net_id)s, attached to NSX router:%(router_id)s", + {'ext_net_id': port_data['network_id'], + 'router_id': nsx_router_id}) + except n_exc.NotFound: + LOG.debug("Logical router resource %s not found " + "on NSX platform : the router may have " + "already been deleted", + port_data['device_id']) except api_exc.NsxApiException: raise nsx_exc.NsxPluginException( err_msg=_("Unable to update logical router" "on NSX Platform")) - LOG.debug("_nsx_delete_ext_gw_port completed on external network " - "%(ext_net_id)s, attached to NSX router:%(router_id)s", - {'ext_net_id': port_data['network_id'], - 'router_id': nsx_router_id}) def _nsx_create_l2_gw_port(self, context, port_data): """Create a switch port, and attach it to a L2 gateway attachment.""" diff --git a/vmware_nsx/neutron/tests/unit/vmware/apiclient/fake.py b/vmware_nsx/neutron/tests/unit/vmware/apiclient/fake.py index dfe48cb9e7..0dbb69c6dc 100644 --- a/vmware_nsx/neutron/tests/unit/vmware/apiclient/fake.py +++ b/vmware_nsx/neutron/tests/unit/vmware/apiclient/fake.py @@ -412,7 +412,7 @@ class FakeClient: def _lrouter_match(res_uuid): # verify that the router exist if parent_uuid and parent_uuid not in self._fake_lrouter_dict: - raise Exception(_("lrouter:%s not found") % parent_uuid) + raise api_exc.ResourceNotFound() if (not parent_uuid or res_dict[res_uuid].get('lr_uuid') == parent_uuid): return True