NSX|V3+P migration: Fix different issues

1. Skip illegal allowed-address-pairs
2. Ignore internal nsxv ports
3. Get port ip carefully

Change-Id: I4f166c0cdc668671a66659e0528de87d7343c2ab
(cherry picked from commit 5b85d2fb51)
This commit is contained in:
Adit Sarfaty 2019-07-08 11:59:02 +03:00
parent 177246709d
commit 72b37729f1
2 changed files with 24 additions and 6 deletions

View File

@ -493,6 +493,12 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
ports = self.get_ports_on_network(network['id'], source_ports)
for port in ports:
# Ignore internal NSXV objects
if port['project_id'] == nsxv_constants.INTERNAL_TENANT_ID:
LOG.info("Skip router %s: Internal NSX-V port",
port['id'])
continue
body = self.prepare_port(port, remove_qos=remove_qos)
# specify the network_id that we just created above
@ -586,12 +592,15 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
LOG.error("Failed to create port (%(port)s) : %(e)s",
{'port': port, 'e': e})
else:
ip_addr = None
if created_port.get('fixed_ips'):
ip_addr = created_port['fixed_ips'][0].get(
'ip_address')
LOG.info("Created port %(port)s (subnet "
"%(subnet)s, ip %(ip)s, mac %(mac)s)",
{'port': created_port['id'],
'subnet': subnet_id,
'ip': created_port['fixed_ips'][0][
'ip_address'],
'ip': ip_addr,
'mac': created_port['mac_address']})
# Enable dhcp on the relevant subnets:

View File

@ -219,10 +219,19 @@ class PrepareObjectForMigration(object):
if remove_qos:
body = self.drop_fields(body, ['qos_policy_id'])
# remove allowed_address_pairs if empty:
if ('allowed_address_pairs' in body and
not body['allowed_address_pairs']):
del body['allowed_address_pairs']
if 'allowed_address_pairs' in body:
if not body['allowed_address_pairs']:
# remove allowed_address_pairs if empty:
del body['allowed_address_pairs']
else:
# remove unsupported allowed_address_pairs
for pair in body['allowed_address_pairs']:
ip = pair.get('ip_address')
if len(ip.split('/')) > 1:
LOG.warning("ignoring allowed_address_pair %s for "
"port %s as cidr is not supported",
pair, port['id'])
body['allowed_address_pairs'].remove(pair)
# remove port security if mac learning is enabled
if (body.get('mac_learning_enabled') and