summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Mick <dan.mick@inktank.com>2013-07-18 14:39:51 -0700
committerDan Mick <dan.mick@inktank.com>2013-07-26 13:51:09 -0700
commit67eb7de42f40eb080438a2f22303265c987a4b27 (patch)
tree38c05126f0c1549bc8fe5538bd12e2e42753425e
parentba6ca5829a6ec20c4cdbc990f1e27a0709ec5a41 (diff)
downloadceph-67eb7de42f40eb080438a2f22303265c987a4b27.tar.gz
ceph_argparse.py, ceph.in: validate_command: stop handling format
We were passing the entire parsed_args Namespace just to look at and tack on 'format', and that's kinda silly; do it in the callers instead. Signed-off-by: Dan Mick <dan.mick@inktank.com>
-rwxr-xr-xsrc/ceph.in9
-rw-r--r--src/pybind/ceph_argparse.py6
2 files changed, 7 insertions, 8 deletions
diff --git a/src/ceph.in b/src/ceph.in
index 0d361e1c76c..90795058127 100755
--- a/src/ceph.in
+++ b/src/ceph.in
@@ -344,10 +344,11 @@ def new_style_command(parsed_args, cmdargs, target, sigdict, inbuf, verbose):
if not got_command:
if cmdargs:
# Validate input args against list of sigs
- valid_dict = validate_command(parsed_args, sigdict, cmdargs,
- verbose)
+ valid_dict = validate_command(sigdict, cmdargs, verbose)
if valid_dict:
got_command = True
+ if parsed_args.output_format:
+ valid_dict['format'] = parsed_args.output_format
else:
return -errno.EINVAL, '', 'invalid command'
else:
@@ -360,8 +361,10 @@ def new_style_command(parsed_args, cmdargs, target, sigdict, inbuf, verbose):
return 0, '', ''
cmdargs = parse_cmdargs(interactive_input.split())[2]
target = find_cmd_target(cmdargs)
- valid_dict = validate_command(parsed_args, sigdict, cmdargs)
+ valid_dict = validate_command(sigdict, cmdargs, verbose)
if valid_dict:
+ if parsed_args.output_format:
+ valid_dict['format'] = parsed_args.output_format
if verbose:
print >> sys.stderr, "Submitting command ", valid_dict
ret, outbuf, outs = json_command(cluster_handle,
diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py
index b82cc833ba6..b014d7d626c 100644
--- a/src/pybind/ceph_argparse.py
+++ b/src/pybind/ceph_argparse.py
@@ -820,11 +820,10 @@ def validate(args, signature, partial=False):
raise ArgumentError("unused arguments: " + str(myargs))
return d
-def validate_command(parsed_args, sigdict, args, verbose=False):
+def validate_command(sigdict, args, verbose=False):
"""
turn args into a valid dictionary ready to be sent off as JSON,
validated against sigdict.
- parsed_args is the namespace back from argparse
"""
found = []
valid_dict = {}
@@ -882,9 +881,6 @@ def validate_command(parsed_args, sigdict, args, verbose=False):
print >> sys.stderr, concise_sig(cmd['sig'])
return None
- if parsed_args.output_format:
- valid_dict['format'] = parsed_args.output_format
-
return valid_dict
def find_cmd_target(childargs):