diff --git a/vmware_nsx/api_replay/client.py b/vmware_nsx/api_replay/client.py index e491f64177..475ecc195a 100644 --- a/vmware_nsx/api_replay/client.py +++ b/vmware_nsx/api_replay/client.py @@ -487,7 +487,7 @@ class ApiReplayClient(utils.PrepareObjectForMigration): # If its a distributed router, we may also need to create its # internal network if self.int_vni_map and router['id'] in self.int_vni_map: - net_name = ("Internal network for distributed router %s" % + net_name = ("Internal network for router %s migration" % router['id']) net_body = {'tenant_id': nsxv_constants.INTERNAL_TENANT_ID, 'id': router['id'], diff --git a/vmware_nsx/api_replay/utils.py b/vmware_nsx/api_replay/utils.py index 210e2d90e6..12b0326331 100644 --- a/vmware_nsx/api_replay/utils.py +++ b/vmware_nsx/api_replay/utils.py @@ -19,6 +19,7 @@ from oslo_config import cfg from oslo_utils import uuidutils import webob.exc +from vmware_nsx.common import nsxv_constants from vmware_nsxlib.v3 import nsx_constants as nsxlib_consts logging.basicConfig(level=logging.INFO) @@ -251,6 +252,11 @@ class PrepareObjectForMigration(object): if net_vni_map and body['id'] in net_vni_map: body['vni'] = net_vni_map[body['id']] + if (body.get('project_id') == nsxv_constants.INTERNAL_TENANT_ID and + body.get('name').startswith('inter-edge-net')): + # rename the internal network + body['name'] = "Internal network for mdproxy migration" + return body def prepare_subnet(self, subnet, direct_call=False): diff --git a/vmware_nsx/plugins/nsx_p/plugin.py b/vmware_nsx/plugins/nsx_p/plugin.py index 5ba01f8af9..3c07781b6b 100644 --- a/vmware_nsx/plugins/nsx_p/plugin.py +++ b/vmware_nsx/plugins/nsx_p/plugin.py @@ -68,6 +68,7 @@ from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import l3_rpc_agent_api from vmware_nsx.common import locking from vmware_nsx.common import managers +from vmware_nsx.common import nsxv_constants from vmware_nsx.common import utils from vmware_nsx.db import db as nsx_db from vmware_nsx.extensions import api_replay @@ -821,15 +822,22 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base): return created_net + def _check_internal_network(self, net): + if net.get('tenant_id') == nsxv_constants.INTERNAL_TENANT_ID: + msg = _("This network was created during the migration for " + "internal usage and cannot be deleted") + raise n_exc.InvalidInput(error_message=msg) + def delete_network(self, context, network_id): is_external_net = self._network_is_external(context, network_id) + network = self._get_network(context, network_id) + self._check_internal_network(network) if not is_external_net: # First disable DHCP & delete its port if self.use_policy_dhcp: lock = 'nsxp_network_' + network_id with locking.LockManager.get_lock(lock): - network = self._get_network(context, network_id) if not self._has_active_port(context, network_id): self._disable_network_dhcp(context, network) elif cfg.CONF.nsx_p.allow_passthrough: