cb8e9e
From 1db921d548904e2382e52c67538928d8ea6d66d3 Mon Sep 17 00:00:00 2001
cb8e9e
From: Milind Changire <mchangir@redhat.com>
cb8e9e
Date: Thu, 11 Jun 2015 20:58:00 +0530
cb8e9e
Subject: [PATCH 72/73] tools/glusterfind: print message for good cases
cb8e9e
cb8e9e
Added messages for printing status of good or default cases
cb8e9e
for 'create', 'list', 'post' and 'delete' commands
cb8e9e
cb8e9e
Change-Id: I86d8aeacc8e3729256d76608e6c006e763f56511
cb8e9e
BUG: 1229674
cb8e9e
Reviewed-On: http://review.gluster.org/11208
cb8e9e
Reviewed-On: http://review.gluster.org/11189
cb8e9e
Signed-off-by: Milind Changire <mchangir@redhat.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/50570
cb8e9e
Reviewed-by: Aravinda Vishwanathapura Krishna Murthy <avishwan@redhat.com>
cb8e9e
Tested-by: Aravinda Vishwanathapura Krishna Murthy <avishwan@redhat.com>
cb8e9e
---
cb8e9e
 tools/glusterfind/src/main.py |   22 ++++++++++++++++------
cb8e9e
 1 files changed, 16 insertions(+), 6 deletions(-)
cb8e9e
cb8e9e
diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py
cb8e9e
index 5d5058f..29fa28b 100644
cb8e9e
--- a/tools/glusterfind/src/main.py
cb8e9e
+++ b/tools/glusterfind/src/main.py
cb8e9e
@@ -90,7 +90,7 @@ def run_cmd_nodes(task, args, **kwargs):
cb8e9e
         if task == "pre":
cb8e9e
             if vol_statusStr == "Stopped":
cb8e9e
                 fail("Volume %s is in stopped state" % args.volume,
cb8e9e
-                    logger=logger)
cb8e9e
+                     logger=logger)
cb8e9e
 
cb8e9e
             # If Full backup is requested or start time is zero, use brickfind
cb8e9e
             change_detector = conf.get_change_detector("changelog")
cb8e9e
@@ -130,7 +130,7 @@ def run_cmd_nodes(task, args, **kwargs):
cb8e9e
         elif task == "create":
cb8e9e
             if vol_statusStr == "Stopped":
cb8e9e
                 fail("Volume %s is in stopped state" % args.volume,
cb8e9e
-                    logger=logger)
cb8e9e
+                     logger=logger)
cb8e9e
 
cb8e9e
             # When glusterfind create, create session directory in
cb8e9e
             # each brick nodes
cb8e9e
@@ -182,7 +182,7 @@ def get_nodes(volume):
cb8e9e
     Get the gluster volume info xml output and parse to get
cb8e9e
     the brick details.
cb8e9e
     """
cb8e9e
-    global vol_statusStr;
cb8e9e
+    global vol_statusStr
cb8e9e
 
cb8e9e
     cmd = ["gluster", 'volume', 'info', volume, "--xml"]
cb8e9e
     _, data, _ = execute(cmd,
cb8e9e
@@ -370,6 +370,9 @@ def mode_create(session_dir, args):
cb8e9e
         with open(status_file, "w", buffering=0) as f:
cb8e9e
             f.write(str(time_to_update))
cb8e9e
 
cb8e9e
+    sys.stdout.write("Session %s created with volume %s\n" %
cb8e9e
+                     (args.session, args.volume))
cb8e9e
+
cb8e9e
     sys.exit(0)
cb8e9e
 
cb8e9e
 
cb8e9e
@@ -451,6 +454,8 @@ def mode_post(session_dir, args):
cb8e9e
     if os.path.exists(status_file_pre):
cb8e9e
         run_cmd_nodes("post", args)
cb8e9e
         os.rename(status_file_pre, status_file)
cb8e9e
+        sys.stdout.write("Session %s with volume %s updated\n" %
cb8e9e
+                         (args.session, args.volume))
cb8e9e
         sys.exit(0)
cb8e9e
     else:
cb8e9e
         fail("Pre script is not run", logger=logger)
cb8e9e
@@ -460,6 +465,8 @@ def mode_delete(session_dir, args):
cb8e9e
     run_cmd_nodes("delete", args)
cb8e9e
     shutil.rmtree(os.path.join(session_dir, args.volume),
cb8e9e
                   onerror=handle_rm_error)
cb8e9e
+    sys.stdout.write("Session %s with volume %s deleted\n" %
cb8e9e
+                     (args.session, args.volume))
cb8e9e
 
cb8e9e
     # If the session contains only this volume, then cleanup the
cb8e9e
     # session directory. If a session contains multiple volumes
cb8e9e
@@ -524,8 +531,11 @@ def mode_list(session_dir, args):
cb8e9e
                                          volname.ljust(25),
cb8e9e
                                          sess_time.ljust(25)))
cb8e9e
 
cb8e9e
-    if not output and (args.session or args.volume):
cb8e9e
-        fail("Invalid Session", logger=logger)
cb8e9e
+    if not output:
cb8e9e
+        if args.session or args.volume:
cb8e9e
+            fail("Invalid Session", logger=logger)
cb8e9e
+        else:
cb8e9e
+            sys.stdout.write("No sessions found\n")
cb8e9e
 
cb8e9e
 
cb8e9e
 def main():
cb8e9e
@@ -544,7 +554,7 @@ def main():
cb8e9e
     vol_dir = os.path.join(session_dir, args.volume)
cb8e9e
     if not os.path.exists(vol_dir) and args.mode not in ["create", "list"]:
cb8e9e
         fail("Session %s not created with volume %s" %
cb8e9e
-            (args.session, args.volume))
cb8e9e
+             (args.session, args.volume))
cb8e9e
 
cb8e9e
     mkdirp(os.path.join(conf.get_opt("log_dir"), args.session, args.volume),
cb8e9e
            exit_on_err=True)
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e