Merge "Fix script argument parsing."
This commit is contained in:
@@ -40,8 +40,14 @@ cleaner_opts = [
|
|||||||
default=172800,
|
default=172800,
|
||||||
help='Number of seconds zombie instances are cleaned up.'),
|
help='Number of seconds zombie instances are cleaned up.'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
cli_opt = cfg.StrOpt('command',
|
||||||
|
default=None,
|
||||||
|
help='Cleaner command')
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
CONF.register_opts(cleaner_opts)
|
CONF.register_opts(cleaner_opts)
|
||||||
|
CONF.register_cli_opt(cli_opt)
|
||||||
CONF.import_opt('verbose', 'nova.openstack.common.log')
|
CONF.import_opt('verbose', 'nova.openstack.common.log')
|
||||||
CONF.import_opt("resize_confirm_window", "nova.compute.manager")
|
CONF.import_opt("resize_confirm_window", "nova.compute.manager")
|
||||||
|
|
||||||
@@ -279,14 +285,14 @@ def clean_orphaned_instances(xenapi, orphaned_instances):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main loop."""
|
"""Main loop."""
|
||||||
args = CONF(args=sys.argv,
|
args = CONF(args=sys.argv[1:], usage='%(prog)s [options] --command={' +
|
||||||
usage='%prog [options] [' + '|'.join(ALLOWED_COMMANDS) + ']')
|
'|'.join(ALLOWED_COMMANDS) + '}')
|
||||||
if len(args) < 2:
|
|
||||||
|
command = CONF.command
|
||||||
|
if not command or command not in ALLOWED_COMMANDS:
|
||||||
CONF.print_usage()
|
CONF.print_usage()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
command = args[1]
|
|
||||||
|
|
||||||
if CONF.zombie_instance_updated_at_window < CONF.resize_confirm_window:
|
if CONF.zombie_instance_updated_at_window < CONF.resize_confirm_window:
|
||||||
raise Exception("`zombie_instance_updated_at_window` has to be longer"
|
raise Exception("`zombie_instance_updated_at_window` has to be longer"
|
||||||
" than `resize_confirm_window`.")
|
" than `resize_confirm_window`.")
|
||||||
|
|||||||
Reference in New Issue
Block a user