Browse Source

[API Replay] Fail fast by default

Add a --ignore-errors CLI options to preserve the current behaviour
where API replays completes all operations and then reports errors.

When --ignore-errors is not set, API replay will fail and quit
at the first error.

Also fixes help string for enable_barbican option.

Change-Id: Ic2f6f89060f26292b017b2b3defb488452ec1cb7
changes/65/816665/1
Salvatore Orlando 7 months ago committed by Salvatore Orlando
parent
commit
819a4f9364
  1. 10
      vmware_nsx/api_replay/cli.py
  2. 8
      vmware_nsx/api_replay/client.py

10
vmware_nsx/api_replay/cli.py

@ -64,7 +64,8 @@ class ApiReplayCli(object):
vif_ids_map=args.vif_ids_map,
logfile=args.logfile,
max_retry=args.max_retry,
cert_file=args.cert_file)
cert_file=args.cert_file,
ignore_errors=args.ignore_errors)
def _setup_argparse(self):
parser = argparse.ArgumentParser()
@ -206,7 +207,12 @@ class ApiReplayCli(object):
"--enable-barbican",
default=False,
action='store_true',
help="Meh")
help="Enable barbican connection for Octavia certificates")
parser.add_argument(
"--ignore-errors",
action='store_true',
default=False,
help="Continuing executing API replay even upon errors")
# NOTE: this will return an error message if any of the
# require options are missing.

8
vmware_nsx/api_replay/client.py

@ -60,7 +60,7 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
octavia_os_tenant_name, octavia_os_tenant_domain_id,
octavia_os_password, octavia_os_auth_url,
neutron_conf, ext_net_map, net_vni_map, int_vni_map,
vif_ids_map, logfile, max_retry, cert_file):
vif_ids_map, logfile, max_retry, cert_file, ignore_errors):
# Init config and logging
if neutron_conf:
@ -170,6 +170,7 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
self.n_errors = 0
self.errors = []
self.ignore_errors = ignore_errors
LOG.info("Starting NSX migration to %s.", self.dest_plugin)
# Migrate all the objects
@ -279,8 +280,11 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
return False
def add_error(self, msg):
self.n_errors = self.n_errors + 1
LOG.error(msg)
if not self.ignore_errors:
LOG.error("Error occurred during API replay: exiting")
sys.exit(1)
self.n_errors = self.n_errors + 1
self.errors.append(msg)
def migrate_quotas(self):

Loading…
Cancel
Save