MP2P migration; Send END api without retries
Change-Id: Ia1eba63f0a0a937f64cd68735a20983e5605c7e0
This commit is contained in:
parent
d95cdd80b9
commit
dae2b9ac5c
@ -93,6 +93,8 @@ DFW_SEQ = 1
|
|||||||
NSX_ROUTER_SECTIONS = []
|
NSX_ROUTER_SECTIONS = []
|
||||||
SERVICE_UP_RETRIES = 30
|
SERVICE_UP_RETRIES = 30
|
||||||
|
|
||||||
|
END_API_TIMEOUT = 30 * 60
|
||||||
|
|
||||||
|
|
||||||
def start_migration_process(nsxlib):
|
def start_migration_process(nsxlib):
|
||||||
"""Notify the manager that the migration process is starting"""
|
"""Notify the manager that the migration process is starting"""
|
||||||
@ -100,8 +102,10 @@ def start_migration_process(nsxlib):
|
|||||||
"migration/mp-to-policy/workflow?action=INITIATE", None)
|
"migration/mp-to-policy/workflow?action=INITIATE", None)
|
||||||
|
|
||||||
|
|
||||||
def end_migration_process(nsxlib):
|
def end_migration_process():
|
||||||
"""Notify the manager that the migration process has ended"""
|
"""Notify the manager that the migration process has ended"""
|
||||||
|
# Using a new nsxlib instance to avoid retries, and add a long timeout
|
||||||
|
nsxlib = _get_nsxlib_from_config(verbose=True, for_end_api=True)
|
||||||
return nsxlib.client.url_post(
|
return nsxlib.client.url_post(
|
||||||
"migration/mp-to-policy/workflow?action=DONE", None)
|
"migration/mp-to-policy/workflow?action=DONE", None)
|
||||||
|
|
||||||
@ -1248,7 +1252,7 @@ def migrate_t_resources_2_p(nsxlib, nsxpolicy, plugin):
|
|||||||
migrate_edge_firewalls(nsxlib, nsxpolicy, plugin)
|
migrate_edge_firewalls(nsxlib, nsxpolicy, plugin)
|
||||||
|
|
||||||
# Finalize the migration (cause policy realization)
|
# Finalize the migration (cause policy realization)
|
||||||
end_migration_process(nsxlib)
|
end_migration_process()
|
||||||
|
|
||||||
# Stop the migration service
|
# Stop the migration service
|
||||||
change_migration_service_status(start=False)
|
change_migration_service_status(start=False)
|
||||||
@ -1271,7 +1275,7 @@ def migrate_t_resources_2_p(nsxlib, nsxpolicy, plugin):
|
|||||||
send_rollback_request(nsxlib,
|
send_rollback_request(nsxlib,
|
||||||
{'migration_data': ROLLBACK_DATA})
|
{'migration_data': ROLLBACK_DATA})
|
||||||
# Finalize the migration (Also needed after rollback)
|
# Finalize the migration (Also needed after rollback)
|
||||||
end_migration_process(nsxlib)
|
end_migration_process()
|
||||||
# Stop the migration service
|
# Stop the migration service
|
||||||
change_migration_service_status(start=False)
|
change_migration_service_status(start=False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -1495,7 +1499,7 @@ def MP2Policy_pre_migration_check(resource, event, trigger, **kwargs):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def _get_nsxlib_from_config(verbose):
|
def _get_nsxlib_from_config(verbose, for_end_api=False):
|
||||||
"""Update the current config and return a working nsxlib
|
"""Update the current config and return a working nsxlib
|
||||||
or exit with error
|
or exit with error
|
||||||
"""
|
"""
|
||||||
@ -1509,6 +1513,12 @@ def _get_nsxlib_from_config(verbose):
|
|||||||
retriables = [nsxlib_exc.APITransactionAborted,
|
retriables = [nsxlib_exc.APITransactionAborted,
|
||||||
nsxlib_exc.ServerBusy]
|
nsxlib_exc.ServerBusy]
|
||||||
|
|
||||||
|
if for_end_api:
|
||||||
|
# enlarge timeouts and disable retries
|
||||||
|
cfg.CONF.set_override('http_read_timeout', END_API_TIMEOUT, 'nsx_v3')
|
||||||
|
cfg.CONF.set_override('http_retries', 0, 'nsx_v3')
|
||||||
|
cfg.CONF.set_override('retries', 0, 'nsx_v3')
|
||||||
|
|
||||||
# Initialize the nsxlib objects, using just one of the managers because
|
# Initialize the nsxlib objects, using just one of the managers because
|
||||||
# the migration will be enabled only on one
|
# the migration will be enabled only on one
|
||||||
nsx_api_managers = copy.copy(cfg.CONF.nsx_v3.nsx_api_managers)
|
nsx_api_managers = copy.copy(cfg.CONF.nsx_v3.nsx_api_managers)
|
||||||
@ -1531,7 +1541,8 @@ def _get_nsxlib_from_config(verbose):
|
|||||||
else:
|
else:
|
||||||
cfg.CONF.set_override(
|
cfg.CONF.set_override(
|
||||||
'nsx_api_password', [nsx_api_password[0]], 'nsx_v3')
|
'nsx_api_password', [nsx_api_password[0]], 'nsx_v3')
|
||||||
utils.reset_global_nsxlib()
|
|
||||||
|
utils.reset_global_nsxlib()
|
||||||
nsxlib = utils.get_connected_nsxlib(verbose=verbose,
|
nsxlib = utils.get_connected_nsxlib(verbose=verbose,
|
||||||
allow_overwrite_header=True,
|
allow_overwrite_header=True,
|
||||||
retriable_exceptions=retriables)
|
retriable_exceptions=retriables)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user