]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
brag : implement --verbose on client 1709/head
authorLoic Dachary <loic@dachary.org>
Tue, 22 Apr 2014 13:41:47 +0000 (15:41 +0200)
committerLoic Dachary <loic@dachary.org>
Thu, 24 Apr 2014 08:29:26 +0000 (10:29 +0200)
Signed-off-by: Loic Dachary <loic@dachary.org>
src/brag/client/ceph-brag

index 6cba99305caa3aa528acb6da861dabd3224ec962..2b8e607f920c96028b30d66bba8d5f29a517d66a 100755 (executable)
@@ -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] + " [<commands> [command-options]]\n"
+  print >> sys.stderr, sys.argv[0] + " [-v|--verbose] [<commands> [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-metadata-options> - 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()