diff --git a/vmware_nsx/api_replay/client.py b/vmware_nsx/api_replay/client.py index 4408353b3c..0b395dfde5 100644 --- a/vmware_nsx/api_replay/client.py +++ b/vmware_nsx/api_replay/client.py @@ -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: diff --git a/vmware_nsx/api_replay/utils.py b/vmware_nsx/api_replay/utils.py index 988dab6178..e5848dc091 100644 --- a/vmware_nsx/api_replay/utils.py +++ b/vmware_nsx/api_replay/utils.py @@ -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