From b115d88326a6d9552356cf8964e2451bb7259774 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Wed, 26 Mar 2014 16:49:24 +0100 Subject: [PATCH] Add --quiet option to neutron-ha-tool To disable all logging except for warnings in errors. Increase log level of "router needs migration" message from info to warning and also use logging for printing exceptions in __main__. Change-Id: Iedf2d15b1ad98050913730cdd703720c09ebd339 --- files/default/neutron-ha-tool.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/files/default/neutron-ha-tool.py b/files/default/neutron-ha-tool.py index b83d7ac0..1f0a6942 100755 --- a/files/default/neutron-ha-tool.py +++ b/files/default/neutron-ha-tool.py @@ -45,6 +45,8 @@ def parse_args(): ap = argparse.ArgumentParser(description=DESCRIPTION) ap.add_argument('-d', '--debug', action='store_true', default=False, help='Show debugging output') + ap.add_argument('-q', '--quiet', action='store_true', + default=False, help='Only show error and warning messages') ap.add_argument('-n', '--noop', action='store_true', default=False, help='Do not do any modifying operations (dry-run)') ap.add_argument('--l3-agent-check', action='store_true', @@ -62,6 +64,8 @@ def parse_args(): def setup_logging(args): level = logging.INFO + if args.quiet: + level = logging.WARN if args.debug: level = logging.DEBUG logging.basicConfig(level=level, format=LOG_FORMAT, date_fmt=LOG_DATE) @@ -191,7 +195,7 @@ def l3_agent_check(qclient): target_id = None migration_count += 1 - LOG.info("Would like to migrate router=%s to agent=%s", + LOG.warn("Would like to migrate router=%s to agent=%s", router_id, target_id) if migration_count > 0: @@ -479,7 +483,7 @@ if __name__ == '__main__': run(args) sys.exit(0) except Exception as err: - print "ERROR: %s" % err + LOG.error(err) sys.exit(1) except KeyboardInterrupt: sys.exit(1)