7f4c2a
From 61521f2be99ec0a799efe02939cabce19a4510f6 Mon Sep 17 00:00:00 2001
7f4c2a
From: Milind Changire <mchangir@redhat.com>
7f4c2a
Date: Thu, 11 Jun 2015 20:39:36 +0530
7f4c2a
Subject: [PATCH 59/73] tools/glusterfind: verifying volume presence
7f4c2a
7f4c2a
An invalid volume name passed to "pre", "post" and "delete"
7f4c2a
operations throws up unfriendly errors. This patch presents
7f4c2a
friendly error messages.
7f4c2a
7f4c2a
Change-Id: Ifa7e99d8bf9c54a818408640909d1531b2b66056
7f4c2a
Signed-off-by: Milind Changire <mchangir@redhat.com>
7f4c2a
Reviewed-On: http://review.gluster.org/#/c/10989/
7f4c2a
Reviewed-On: http://review.gluster.org/#/c/10945/
7f4c2a
BUG: 1224046
7f4c2a
Reviewed-on: https://code.engineering.redhat.com/gerrit/50563
7f4c2a
Reviewed-by: Aravinda Vishwanathapura Krishna Murthy <avishwan@redhat.com>
7f4c2a
Tested-by: Aravinda Vishwanathapura Krishna Murthy <avishwan@redhat.com>
7f4c2a
---
7f4c2a
 tools/glusterfind/src/main.py |   10 ++++++++++
7f4c2a
 1 files changed, 10 insertions(+), 0 deletions(-)
7f4c2a
7f4c2a
diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py
7f4c2a
index d9936ee..ccd2d22 100644
7f4c2a
--- a/tools/glusterfind/src/main.py
7f4c2a
+++ b/tools/glusterfind/src/main.py
7f4c2a
@@ -179,6 +179,11 @@ def get_nodes(volume):
7f4c2a
                          logger=logger)
7f4c2a
     tree = etree.fromstring(data)
7f4c2a
 
7f4c2a
+    # Test to check if volume has been deleted after session creation
7f4c2a
+    count_el = tree.find('volInfo/volumes/count')
7f4c2a
+    if int(count_el.text) == 0:
7f4c2a
+        fail("Unable to get volume details", logger=logger)
7f4c2a
+
7f4c2a
     nodes = []
7f4c2a
     volume_el = tree.find('volInfo/volumes/volume')
7f4c2a
     try:
7f4c2a
@@ -506,6 +511,11 @@ def main():
7f4c2a
     if not os.path.exists(session_dir) and args.mode not in ["create", "list"]:
7f4c2a
         fail("Invalid session %s" % args.session)
7f4c2a
 
7f4c2a
+    vol_dir = os.path.join(session_dir, args.volume)
7f4c2a
+    if not os.path.exists(vol_dir) and args.mode not in ["create", "list"]:
7f4c2a
+        fail("Session %s not created with volume %s" %
7f4c2a
+            (args.session, args.volume))
7f4c2a
+
7f4c2a
     mkdirp(os.path.join(conf.get_opt("log_dir"), args.session, args.volume),
7f4c2a
            exit_on_err=True)
7f4c2a
     log_file = os.path.join(conf.get_opt("log_dir"),
7f4c2a
-- 
7f4c2a
1.7.1
7f4c2a