summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2015-06-17 17:05:22 +0530
committerVenky Shankar <vshankar@redhat.com>2015-06-23 23:16:21 -0700
commit0f6e81313048fb2be9b25765a45c612912fea123 (patch)
tree3a0d99496c42af6c2952ef50773e49d108c6800a /tools
parent386f8ff50c85807f19db8c1a29c67ce2d2cf4474 (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. BUG: 1233518 Change-Id: Ie01a87500578b9cc3eb72aabd0f24f632fbee58f Reviewed-on: http://review.gluster.org/11278 Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/11322 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Aravinda VK <avishwan@redhat.com>
Diffstat (limited to 'tools')
-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 29fa28b7a15..8d32295a78c 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,