V2T Migration: Fix pre-flight validation

- Use external networks from config for non-neutron validation
- Fix LB validations
- Do not report networks as both non-neutron and orphaned
- upport VXLAN provider networkss migration

Change-Id: I45525bfba7082184203a8789baed93a89c1cabd9
This commit is contained in:
asarfaty 2021-03-22 11:24:59 +02:00 committed by Adit Sarfaty
parent 789f2362b7
commit 8ddf9b156d
2 changed files with 42 additions and 6 deletions

View File

@ -197,6 +197,8 @@ class PrepareObjectForMigration(object):
body.get('provider:segmentation_id') is not None): body.get('provider:segmentation_id') is not None):
del body['provider:network_type'] del body['provider:network_type']
del body['provider:segmentation_id'] del body['provider:segmentation_id']
if 'provider:physical_network' in body:
del body['provider:physical_network']
# flat network should be translated to a regular network in nsx-v3/P. # flat network should be translated to a regular network in nsx-v3/P.
if (body.get('provider:network_type') == 'flat'): if (body.get('provider:network_type') == 'flat'):

View File

@ -141,11 +141,10 @@ def _validate_networks(plugin, admin_context, transit_networks):
if plugin._network_is_external(admin_context, net['id']): if plugin._network_is_external(admin_context, net['id']):
continue continue
# VXLAN or portgroup provider networks # portgroup provider networks are not ssupported
net_type = net.get(pnet.NETWORK_TYPE) net_type = net.get(pnet.NETWORK_TYPE)
overlay_net = bool(net_type != c_utils.NsxVNetworkTypes.VLAN) overlay_net = bool(net_type != c_utils.NsxVNetworkTypes.VLAN)
if (net_type == c_utils.NsxVNetworkTypes.VXLAN or if net_type == c_utils.NsxVNetworkTypes.PORTGROUP:
net_type == c_utils.NsxVNetworkTypes.PORTGROUP):
log_error("Network %s of type %s is not supported." % log_error("Network %s of type %s is not supported." %
(net['id'], net_type)) (net['id'], net_type))
@ -352,8 +351,17 @@ def _validate_loadbalancers(plugin, admin_context):
lb_subnets = list(set([port['fixed_ips'][0]['subnet_id'] lb_subnets = list(set([port['fixed_ips'][0]['subnet_id']
for port in lb_ports])) for port in lb_ports]))
# make sure all subnets are connected to the same router # make sure all subnets are connected to the same router
lb_routers = [lb_rtr_id] lb_routers = []
if lb_rtr_id:
lb_routers = [lb_rtr_id]
for sub_id in lb_subnets: for sub_id in lb_subnets:
# skip external subnets
network = lb_utils.get_network_from_subnet(
admin_context, plugin, sub_id)
if network.get('router:external'):
# Member on external subnet must have a fip but this cannot
# be checked here are the member ip is unknown
continue
router_id = _get_router_from_network( router_id = _get_router_from_network(
admin_context, plugin, sub_id) admin_context, plugin, sub_id)
if not router_id: if not router_id:
@ -370,6 +378,15 @@ def _validate_loadbalancers(plugin, admin_context):
lb_id) lb_id)
break break
# Make sure this router has a gateway
if lb_routers:
router_db = plugin._get_router(admin_context, lb_routers[0])
if not router_db.gw_port:
log_error("Loadbalancer's %s subnets are connected to a "
"router without a gateway. This is not "
"supported." % lb_id)
break
def _validate_security_groups(plugin, admin_context): def _validate_security_groups(plugin, admin_context):
# Security groups without policies # Security groups without policies
@ -380,27 +397,44 @@ def _validate_security_groups(plugin, admin_context):
"supported." % sg['id']) "supported." % sg['id'])
def _get_config_ext_nets():
config.register_nsxv_azs(cfg.CONF, cfg.CONF.nsxv.availability_zones)
zones = nsx_az.NsxVAvailabilityZones()
nets = []
for az in zones.list_availability_zones_objects():
nets.append(az.external_network)
return nets
def _validate_non_neutron_networks(admin_context): def _validate_non_neutron_networks(admin_context):
# Look for orphaned neutron networks and non neutron backend networks # Look for orphaned neutron networks and non neutron backend networks
backend_networks = utils.get_networks() backend_networks = utils.get_networks()
missing_networks = utils.get_orphaned_networks(backend_networks) missing_networks = utils.get_orphaned_networks(backend_networks)
config_networks = _get_config_ext_nets()
missing_morefs = []
for net in missing_networks: for net in missing_networks:
log_warning("NSX backend network %s:%s is missing from Neutron " log_warning("NSX backend network %s:%s is missing from Neutron "
"and is probably an orphaned. Please delete it." % "and is probably an orphaned. Please delete it." %
(net.get('moref'), net.get('name'))) (net.get('moref'), net.get('name')))
missing_morefs.append(net.get('moref'))
for net in backend_networks: for net in backend_networks:
moref = net['moref'] moref = net['moref']
name = net['name'] name = net['name']
net_type = net['type'] net_type = net['type']
if moref in missing_morefs:
# Already reported
continue
if ((len(name) < 36 or not uuidutils.is_uuid_like(name)) and if ((len(name) < 36 or not uuidutils.is_uuid_like(name)) and
net_type in ['DistributedVirtualPortgroup', 'VirtualWire']): net_type in ['DistributedVirtualPortgroup', 'VirtualWire']):
if (net_type == 'DistributedVirtualPortgroup' and if (net_type == 'DistributedVirtualPortgroup' and
name.startswith('edge-')): name.startswith('edge-')):
continue continue
if (name == 'DPortGroup' and net_type ==
'DistributedVirtualPortgroup'): if moref in config_networks:
continue continue
if name: if name: