Change order of MP2P migration

Ensure resources are migrated in the expected order.

Address global-variable-not-assigned (W0602) im migration.py
Also update .pylintrc for ignoring consider-using-f-string (C0209)

Change-Id: Ie8361af6a5bcecea0757c8c04fef85f548db3a06
This commit is contained in:
Salvatore Orlando 2021-09-08 06:32:46 -07:00
parent 586a98bf4e
commit c384960219
3 changed files with 16 additions and 10 deletions

View File

@ -53,6 +53,7 @@ disable=
# bad-continuation, # bad-continuation,
consider-iterating-dictionary, consider-iterating-dictionary,
consider-using-enumerate, consider-using-enumerate,
consider-using-f-string,
invalid-name, invalid-name,
len-as-condition, len-as-condition,
# misplaced-comparison-constant, # misplaced-comparison-constant,

View File

@ -69,7 +69,6 @@ n_warnings = 0
def log_error(msg): def log_error(msg):
global all_errors
global n_errors global n_errors
LOG.info("ERROR: %s", msg) LOG.info("ERROR: %s", msg)
all_errors.append(msg) all_errors.append(msg)
@ -77,7 +76,6 @@ def log_error(msg):
def log_warning(msg): def log_warning(msg):
global all_warnings
global n_warnings global n_warnings
LOG.info("WARNING: %s", msg) LOG.info("WARNING: %s", msg)
all_warnings.append(msg) all_warnings.append(msg)

View File

@ -1159,7 +1159,6 @@ def migrate_edge_firewalls(nsxlib, nsxpolicy, plugin):
plugin.nsxpolicy = nsxpolicy plugin.nsxpolicy = nsxpolicy
ctx = context.get_admin_context() ctx = context.get_admin_context()
routers = plugin.get_routers(ctx) routers = plugin.get_routers(ctx)
global NSX_ROUTER_SECTIONS
for rtr in routers: for rtr in routers:
nsx_router_id = db.get_nsx_router_id(ctx.session, rtr['id']) nsx_router_id = db.get_nsx_router_id(ctx.session, rtr['id'])
nsx_rtr = nsxlib.logical_router.get(nsx_router_id) nsx_rtr = nsxlib.logical_router.get(nsx_router_id)
@ -1320,19 +1319,29 @@ def migrate_t_resources_2_p(nsxlib, nsxpolicy, plugin,
start_migration_process(nsxlib) start_migration_process(nsxlib)
# Migration order derives from the dependencies between resources # Migration order derives from the dependencies between resources
public_switches, tier0s = migrate_tier0s(nsxlib, nsxpolicy, plugin) # Migrate DHCP server
migrate_md_proxies(nsxlib, nsxpolicy, plugin)
migrate_switch_profiles(nsxlib, nsxpolicy, plugin)
migrate_groups(nsxlib, nsxpolicy)
migrate_dhcp_servers(nsxlib, nsxpolicy) migrate_dhcp_servers(nsxlib, nsxpolicy)
# Migrate Tier0 routers
public_switches, tier0s = migrate_tier0s(nsxlib, nsxpolicy, plugin)
# Migrate Tier1 routers
mp_routers = migrate_routers(nsxlib, nsxpolicy) mp_routers = migrate_routers(nsxlib, nsxpolicy)
# Migrate switch profiles
migrate_switch_profiles(nsxlib, nsxpolicy, plugin)
# Migrate MD Proxies
migrate_md_proxies(nsxlib, nsxpolicy, plugin)
# Migrate logical switches
mp_networks = migrate_networks(nsxlib, nsxpolicy, plugin, mp_networks = migrate_networks(nsxlib, nsxpolicy, plugin,
public_switches) public_switches)
# Migrate logical ports including Tier1 router ports
migrate_ports(nsxlib, nsxpolicy, plugin, mp_networks) migrate_ports(nsxlib, nsxpolicy, plugin, mp_networks)
# Migrate static routes and NAT config
migrate_routers_config(nsxlib, nsxpolicy, plugin, mp_routers) migrate_routers_config(nsxlib, nsxpolicy, plugin, mp_routers)
# Migrate Tier0 router ports and configuration
migrate_tier0_config(nsxlib, nsxpolicy, tier0s) migrate_tier0_config(nsxlib, nsxpolicy, tier0s)
# Migrate NS groups
migrate_groups(nsxlib, nsxpolicy)
# Migrate Lb profiles, monitors, pools, virtual servers, and services
migrate_lb_resources(nsxlib, nsxpolicy) migrate_lb_resources(nsxlib, nsxpolicy)
# Migrate firewall sections last as those take the longest to rollback # Migrate firewall sections last as those take the longest to rollback
# in case of error # in case of error
migrate_dfw_sections(nsxlib, nsxpolicy, plugin) migrate_dfw_sections(nsxlib, nsxpolicy, plugin)
@ -1357,7 +1366,6 @@ def migrate_t_resources_2_p(nsxlib, nsxpolicy, plugin,
except Exception as e: except Exception as e:
LOG.error("Abort migration failed: %s", e) LOG.error("Abort migration failed: %s", e)
global ROLLBACK_DATA
if ROLLBACK_DATA: if ROLLBACK_DATA:
LOG.info("Rolling migration back %s", ROLLBACK_DATA) LOG.info("Rolling migration back %s", ROLLBACK_DATA)
send_rollback_request({'migration_data': ROLLBACK_DATA}) send_rollback_request({'migration_data': ROLLBACK_DATA})
@ -1539,7 +1547,6 @@ def post_migration_actions(nsxlib, nsxpolicy, nsxpolicy_admin, plugin):
break break
# -- Delete MP edge firewall rules # -- Delete MP edge firewall rules
global NSX_ROUTER_SECTIONS
for section in NSX_ROUTER_SECTIONS: for section in NSX_ROUTER_SECTIONS:
# make sure the policy section was already realized # make sure the policy section was already realized
# with runtime_status=SUCESS # with runtime_status=SUCESS