From c0c2361b6e0bab4cea62cd011cdb13ef8760a000 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Tue, 22 Apr 2014 15:41:47 +0200 Subject: [PATCH] brag : implement --verbose on client Signed-off-by: Loic Dachary --- src/brag/client/ceph-brag | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/brag/client/ceph-brag b/src/brag/client/ceph-brag index 6cba99305caa3..2b8e607f920c9 100755 --- a/src/brag/client/ceph-brag +++ b/src/brag/client/ceph-brag @@ -12,7 +12,11 @@ from collections import Counter CLUSTER_UUID_NAME='cluster-uuid' CLUSTER_OWNERSHIP_NAME='cluster-ownership' +verbose = False + def run_command(cmd): + if verbose: + print "run_command: " + str(cmd) child = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (o, e) = child.communicate() @@ -223,9 +227,11 @@ def describe_usage(): print >> sys.stderr, "Usage:" print >> sys.stderr, "======\n" - print >> sys.stderr, sys.argv[0] + " [ [command-options]]\n" + print >> sys.stderr, sys.argv[0] + " [-v|--verbose] [ [command-options]]\n" print >> sys.stderr, "without any option, shows the data to be published and do nothing" print >> sys.stderr, "" + print >> sys.stderr, "-v|--verbose: toggle verbose output on stdout" + print >> sys.stderr, "" print >> sys.stderr, "commands:" print >> sys.stderr, "publish - publish the brag report to the server" print >> sys.stderr, "update-metadata - Update" @@ -280,6 +286,8 @@ def publish(): print >> sys.stderr, "Cannot publish until a URL is set using update-metadata" return 1 + if verbose: + print "PUT " + str(url) + " : " + str(data) req = requests.put(url, data=data) if req.status_code is not 201: print >> sys.stderr, "Failed to publish, server responded with code " + str(req.status_code) @@ -317,10 +325,14 @@ def unpublish(): return 0 def main(): + if len(sys.argv) > 1 and ( sys.argv[1] == '--verbose' or sys.argv[1] == '-v' ): + global verbose + verbose = True + sys.argv.pop(1) if len(sys.argv) is 1: print output_json()[0] return 0 - elif sys.argv[1] == 'update-metadata': + if sys.argv[1] == 'update-metadata': return update_metadata() elif sys.argv[1] == 'clear-metadata': return clear_metadata() -- 2.39.5