From: Loic Dachary Date: Tue, 22 Apr 2014 13:41:47 +0000 (+0200) Subject: brag : implement --verbose on client X-Git-Tag: v0.81~106^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1709%2Fhead;p=ceph.git brag : implement --verbose on client Signed-off-by: Loic Dachary --- diff --git a/src/brag/client/ceph-brag b/src/brag/client/ceph-brag index 6cba99305caa..2b8e607f920c 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()