Blob Blame History Raw
From 61521f2be99ec0a799efe02939cabce19a4510f6 Mon Sep 17 00:00:00 2001
From: Milind Changire <mchangir@redhat.com>
Date: Thu, 11 Jun 2015 20:39:36 +0530
Subject: [PATCH 59/73] tools/glusterfind: verifying volume presence

An invalid volume name passed to "pre", "post" and "delete"
operations throws up unfriendly errors. This patch presents
friendly error messages.

Change-Id: Ifa7e99d8bf9c54a818408640909d1531b2b66056
Signed-off-by: Milind Changire <mchangir@redhat.com>
Reviewed-On: http://review.gluster.org/#/c/10989/
Reviewed-On: http://review.gluster.org/#/c/10945/
BUG: 1224046
Reviewed-on: https://code.engineering.redhat.com/gerrit/50563
Reviewed-by: Aravinda Vishwanathapura Krishna Murthy <avishwan@redhat.com>
Tested-by: Aravinda Vishwanathapura Krishna Murthy <avishwan@redhat.com>
---
 tools/glusterfind/src/main.py |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py
index d9936ee..ccd2d22 100644
--- a/tools/glusterfind/src/main.py
+++ b/tools/glusterfind/src/main.py
@@ -179,6 +179,11 @@ def get_nodes(volume):
                          logger=logger)
     tree = etree.fromstring(data)
 
+    # Test to check if volume has been deleted after session creation
+    count_el = tree.find('volInfo/volumes/count')
+    if int(count_el.text) == 0:
+        fail("Unable to get volume details", logger=logger)
+
     nodes = []
     volume_el = tree.find('volInfo/volumes/volume')
     try:
@@ -506,6 +511,11 @@ def main():
     if not os.path.exists(session_dir) and args.mode not in ["create", "list"]:
         fail("Invalid session %s" % args.session)
 
+    vol_dir = os.path.join(session_dir, args.volume)
+    if not os.path.exists(vol_dir) and args.mode not in ["create", "list"]:
+        fail("Session %s not created with volume %s" %
+            (args.session, args.volume))
+
     mkdirp(os.path.join(conf.get_opt("log_dir"), args.session, args.volume),
            exit_on_err=True)
     log_file = os.path.join(conf.get_opt("log_dir"),
-- 
1.7.1