From 59f6d3b63b3a32875a1835cb3ff9bbddf2b192ee Mon Sep 17 00:00:00 2001 From: Joe Gordon Date: Fri, 16 Nov 2012 14:48:45 -0800 Subject: Improve nova-manage usability Prevent nova-manage from stack tracing when the wrong number of arguments are passed in. Fixes bug 1083315 Change-Id: I7b9a237a82b4255d88c01c6a56ad0ccd4a6ee984 --- bin/nova-manage | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index 6e90e2e00..aa92d5ef0 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -79,6 +79,7 @@ from nova import db from nova.db import migration from nova import exception from nova.openstack.common import cfg +from nova.openstack.common import cliutils from nova.openstack.common import importutils from nova.openstack.common import log as logging from nova.openstack.common import rpc @@ -1160,15 +1161,18 @@ def main(): fn_args = [arg.decode('utf-8') for arg in fn_args] # call the action with the remaining arguments + # check arguments + try: + cliutils.validate_args(fn, *fn_args, **fn_kwargs) + except cliutils.MissingArgs as e: + print fn.__doc__ + parser.print_help() + print e + sys.exit(1) try: fn(*fn_args, **fn_kwargs) rpc.cleanup() sys.exit(0) - except TypeError: - print _("Possible wrong number of arguments supplied") - print fn.__doc__ - parser.print_help() - raise except Exception: print _("Command failed, please check log for more info") raise -- cgit