diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-02-18 17:58:46 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-02-18 17:58:46 +0000 |
commit | 9e2b990f2260dbbe1b207e853b37f6261e594fbd (patch) | |
tree | 26e64da08707024eafdcc84fa1d5f0a5c0deaf4d /tools | |
parent | fbe79705eb6625e5cf5653eb342c5998f88fee5a (diff) | |
parent | cf51411531af49299be472e41b1c70aaaf6e5c3e (diff) | |
download | nova-9e2b990f2260dbbe1b207e853b37f6261e594fbd.tar.gz nova-9e2b990f2260dbbe1b207e853b37f6261e594fbd.tar.xz nova-9e2b990f2260dbbe1b207e853b37f6261e594fbd.zip |
Merge "Fix script argument parsing."
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/xenserver/vm_vdi_cleaner.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/xenserver/vm_vdi_cleaner.py b/tools/xenserver/vm_vdi_cleaner.py index 27b89d510..c9dc0b53d 100755 --- a/tools/xenserver/vm_vdi_cleaner.py +++ b/tools/xenserver/vm_vdi_cleaner.py @@ -40,8 +40,14 @@ cleaner_opts = [ default=172800, help='Number of seconds zombie instances are cleaned up.'), ] + +cli_opt = cfg.StrOpt('command', + default=None, + help='Cleaner command') + CONF = cfg.CONF CONF.register_opts(cleaner_opts) +CONF.register_cli_opt(cli_opt) CONF.import_opt('verbose', 'nova.openstack.common.log') CONF.import_opt("resize_confirm_window", "nova.compute.manager") @@ -279,14 +285,14 @@ def clean_orphaned_instances(xenapi, orphaned_instances): def main(): """Main loop.""" - args = CONF(args=sys.argv, - usage='%prog [options] [' + '|'.join(ALLOWED_COMMANDS) + ']') - if len(args) < 2: + args = CONF(args=sys.argv[1:], usage='%(prog)s [options] --command={' + + '|'.join(ALLOWED_COMMANDS) + '}') + + command = CONF.command + if not command or command not in ALLOWED_COMMANDS: CONF.print_usage() sys.exit(1) - command = args[1] - if CONF.zombie_instance_updated_at_window < CONF.resize_confirm_window: raise Exception("`zombie_instance_updated_at_window` has to be longer" " than `resize_confirm_window`.") |