Merge "MP2P migration: Fix custom switching profiles migrations" into stable/train
This commit is contained in:
commit
6d322d603a
|
@ -201,12 +201,16 @@ def wait_on_overall_migration_status_to_pause(nsxlib):
|
||||||
|
|
||||||
|
|
||||||
def printable_resource_name(resource):
|
def printable_resource_name(resource):
|
||||||
name_or_id = resource.get('display_name', resource['id'])
|
name = resource.get('display_name')
|
||||||
try:
|
if name:
|
||||||
name_or_id = str(name_or_id)
|
try:
|
||||||
except UnicodeEncodeError:
|
name = str(name)
|
||||||
name_or_id = name_or_id.encode('ascii', 'ignore')
|
except UnicodeEncodeError:
|
||||||
return name_or_id
|
name = name.encode('ascii', 'ignore')
|
||||||
|
res_id = resource.get('id')
|
||||||
|
if name == res_id:
|
||||||
|
return name
|
||||||
|
return "%s (%s)" % (name, resource.get('id'))
|
||||||
|
|
||||||
|
|
||||||
def get_resource_migration_data(nsxlib_resource, neutron_id_tags,
|
def get_resource_migration_data(nsxlib_resource, neutron_id_tags,
|
||||||
|
@ -225,7 +229,7 @@ def get_resource_migration_data(nsxlib_resource, neutron_id_tags,
|
||||||
resources = resources.get('results', [])
|
resources = resources.get('results', [])
|
||||||
entries = []
|
entries = []
|
||||||
for resource in resources:
|
for resource in resources:
|
||||||
name_or_id = printable_resource_name(resource)
|
name_and_id = printable_resource_name(resource)
|
||||||
policy_id = resource['id']
|
policy_id = resource['id']
|
||||||
# Go over tags and find the neutron id
|
# Go over tags and find the neutron id
|
||||||
neutron_id = None
|
neutron_id = None
|
||||||
|
@ -238,19 +242,19 @@ def get_resource_migration_data(nsxlib_resource, neutron_id_tags,
|
||||||
neutron_id = tag['tag']
|
neutron_id = tag['tag']
|
||||||
if not skip_policy_path_check and found_policy_path:
|
if not skip_policy_path_check and found_policy_path:
|
||||||
LOG.debug("Skipping %s %s as it is already a policy "
|
LOG.debug("Skipping %s %s as it is already a policy "
|
||||||
"resource", printable_name, name_or_id)
|
"resource", printable_name, name_and_id)
|
||||||
continue
|
continue
|
||||||
if neutron_id_tags:
|
if neutron_id_tags:
|
||||||
if not neutron_id:
|
if not neutron_id:
|
||||||
# Not a neutron resource
|
# Not a neutron resource
|
||||||
LOG.debug("Skipping %s %s as it is not a neutron resource",
|
LOG.debug("Skipping %s %s as it is not a neutron resource",
|
||||||
printable_name, name_or_id)
|
printable_name, name_and_id)
|
||||||
continue
|
continue
|
||||||
policy_id = neutron_id
|
policy_id = neutron_id
|
||||||
if resource_condition:
|
if resource_condition:
|
||||||
if not resource_condition(resource):
|
if not resource_condition(resource):
|
||||||
LOG.debug("Skipping %s %s as it does not match the neutron "
|
LOG.debug("Skipping %s %s as it does not match the neutron "
|
||||||
"condition", printable_name, name_or_id)
|
"condition", printable_name, name_and_id)
|
||||||
continue
|
continue
|
||||||
if policy_id_callback:
|
if policy_id_callback:
|
||||||
# Callback to change the policy id
|
# Callback to change the policy id
|
||||||
|
@ -263,10 +267,10 @@ def get_resource_migration_data(nsxlib_resource, neutron_id_tags,
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
LOG.debug("Skipping %s %s as it already exists on the "
|
LOG.debug("Skipping %s %s as it already exists on the "
|
||||||
"policy backend", printable_name, name_or_id)
|
"policy backend", printable_name, name_and_id)
|
||||||
continue
|
continue
|
||||||
LOG.debug("Adding data for %s manager-id %s, policy-id %s",
|
LOG.debug("Adding data for %s %s, policy-id %s",
|
||||||
printable_name, resource['id'], policy_id)
|
printable_name, name_and_id, policy_id)
|
||||||
entry = {'manager_id': resource['id']}
|
entry = {'manager_id': resource['id']}
|
||||||
if policy_id:
|
if policy_id:
|
||||||
entry['policy_id'] = policy_id
|
entry['policy_id'] = policy_id
|
||||||
|
@ -384,7 +388,11 @@ def migrate_resource(nsxlib, resource_type, entries,
|
||||||
def get_configured_values(plugin, az_attribute):
|
def get_configured_values(plugin, az_attribute):
|
||||||
values = []
|
values = []
|
||||||
for az in plugin.get_azs_list():
|
for az in plugin.get_azs_list():
|
||||||
values.append(getattr(az, az_attribute))
|
az_values = getattr(az, az_attribute)
|
||||||
|
if isinstance(az_values, list):
|
||||||
|
values.extend(az_values)
|
||||||
|
else:
|
||||||
|
values.append(az_values)
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue