summaryrefslogtreecommitdiffstats
path: root/tools/glusterfind
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2015-06-17 17:05:22 +0530
committerVenky Shankar <vshankar@redhat.com>2015-06-18 23:04:04 -0700
commita0e9c7d52dc43d30e1a2bd5567412a61b3c078fa (patch)
treeae8cad27b331d95878d93708c4e3c55fb8e2d9ea /tools/glusterfind
parentdda7608736857ac5fb539f2c04a1499999c984ed (diff)
tools/glusterfind: Fail glusterfind creation if volume is offline
Following two fixes are done. 1. Fail glusterfind session creation if volume is not online even before session directories are created. This avoids 'glusterfind list' to pick the session directories and show status as 'Session Corrupted'. 2. Check of '!Started' instead of wether the volume is 'Stopped'. It covers all the cases. Change-Id: I3e9cb384d978ada28f508c07e37d6ceb2272a731 BUG: 1232729 Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/11278 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Aravinda VK <avishwan@redhat.com>
Diffstat (limited to 'tools/glusterfind')
-rw-r--r--tools/glusterfind/src/main.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py
index 772562c24d1..18130e07aa6 100644
--- a/tools/glusterfind/src/main.py
+++ b/tools/glusterfind/src/main.py
@@ -31,7 +31,7 @@ ParseError = etree.ParseError if hasattr(etree, 'ParseError') else SyntaxError
logger = logging.getLogger()
node_outfiles = []
-vol_statusStr = "Stopped"
+vol_statusStr = ""
class StoreAbsPath(Action):
@@ -88,8 +88,8 @@ def run_cmd_nodes(task, args, **kwargs):
"tmp_output_%s" % num)
if task == "pre":
- if vol_statusStr == "Stopped":
- fail("Volume %s is in stopped state" % args.volume,
+ if vol_statusStr != "Started":
+ fail("Volume %s is not online" % args.volume,
logger=logger)
# If Full backup is requested or start time is zero, use brickfind
@@ -128,8 +128,8 @@ def run_cmd_nodes(task, args, **kwargs):
args.session,
args.volume] + (["--debug"] if args.debug else [])
elif task == "create":
- if vol_statusStr == "Stopped":
- fail("Volume %s is in stopped state" % args.volume,
+ if vol_statusStr != "Started":
+ fail("Volume %s is not online" % args.volume,
logger=logger)
# When glusterfind create, create session directory in
@@ -324,9 +324,18 @@ def mode_create(session_dir, args):
logger.debug("Init is called - Session: %s, Volume: %s"
% (args.session, args.volume))
- execute(["gluster", "volume", "info", args.volume],
- exit_msg="Unable to get volume details",
- logger=logger)
+ cmd = ["gluster", 'volume', 'info', args.volume, "--xml"]
+ _, data, _ = execute(cmd,
+ exit_msg="Failed to Run Gluster Volume Info",
+ logger=logger)
+ try:
+ tree = etree.fromstring(data)
+ statusStr = tree.find('volInfo/volumes/volume/statusStr').text
+ except (ParseError, AttributeError) as e:
+ fail("Invalid Volume: %s" % e, logger=logger)
+
+ if statusStr != "Started":
+ fail("Volume %s is not online" % args.volume, logger=logger)
mkdirp(session_dir, exit_on_err=True, logger=logger)
mkdirp(os.path.join(session_dir, args.volume), exit_on_err=True,