V2T: Handle external network mapping

Change-Id: Iefc7f133f94c02e844a1d29f8eb4a1da0cf6f7d0
This commit is contained in:
asarfaty 2019-12-22 13:54:00 +02:00 committed by Adit Sarfaty
parent dca6d52199
commit 7989d69c54
3 changed files with 27 additions and 3 deletions

View File

@ -44,6 +44,7 @@ class ApiReplayCli(object):
octavia_os_password=args.octavia_os_password,
octavia_os_auth_url=args.octavia_os_auth_url,
neutron_conf=args.neutron_conf,
ext_net_map=args.external_networks_map,
logfile=args.logfile,
max_retry=args.max_retry)
@ -158,6 +159,11 @@ class ApiReplayCli(object):
default='/etc/neutron/neutron.conf',
help="neutron config file path.")
parser.add_argument(
"--external-networks-map",
help="Path to a json file mapping external network neutron ID "
"to tier0 ID.")
parser.add_argument(
"--max-retry",
default=10,

View File

@ -24,6 +24,7 @@ from octaviaclient.api.v2 import octavia
from oslo_config import cfg
import oslo_messaging as messaging
from oslo_messaging.rpc import dispatcher
from oslo_serialization import jsonutils
from oslo_utils import excutils
from neutron.common import config as neutron_config
@ -53,7 +54,7 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
octavia_os_username, octavia_os_user_domain_id,
octavia_os_tenant_name, octavia_os_tenant_domain_id,
octavia_os_password, octavia_os_auth_url,
neutron_conf, logfile, max_retry):
neutron_conf, ext_net_map, logfile, max_retry):
# Init config and logging
if neutron_conf:
@ -116,6 +117,13 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
self.dest_plugin = dest_plugin
if ext_net_map:
with open(ext_net_map, 'r') as myfile:
data = myfile.read()
self.ext_net_map = jsonutils.loads(data)
else:
self.ext_net_map = None
LOG.info("Starting NSX migration to %s.", self.dest_plugin)
# Migrate all the objects
self.migrate_security_groups()
@ -468,7 +476,7 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
body = self.prepare_network(
network, remove_qos=remove_qos,
dest_default_public_net=dest_default_public_net,
dest_azs=dest_azs)
dest_azs=dest_azs, ext_net_map=self.ext_net_map)
# only create network if the dest server doesn't have it
if self.have_id(network['id'], dest_networks):

View File

@ -161,7 +161,8 @@ class PrepareObjectForMigration(object):
return self.drop_fields(pool, self.drop_subnetpool_fields)
def prepare_network(self, net, dest_default_public_net=True,
remove_qos=False, dest_azs=None, direct_call=False):
remove_qos=False, dest_azs=None, direct_call=False,
ext_net_map=None):
self.fix_description(net)
body = self.drop_fields(net, self.drop_network_fields)
@ -201,6 +202,15 @@ class PrepareObjectForMigration(object):
if fields_reset:
LOG.warning("Ignoring provider network fields while migrating "
"external network %s", body['id'])
# Get the tier0 into the physical_network
if ext_net_map and body['id'] in ext_net_map:
body['provider:physical_network'] = ext_net_map[body['id']]
else:
LOG.warning("Using default Tier0 as provider:physical_network "
"while migrating external network %s", body['id'])
if 'provider:physical_network' in body:
del body['provider:physical_network']
if body.get('is_default') and dest_default_public_net:
body['is_default'] = False
LOG.warning("Public network %s was set to non default network",