From 6532c7d13f43748bed51f28e6a03e0e6605b76fd Mon Sep 17 00:00:00 2001 From: Milind Changire Date: Fri, 12 Jun 2015 15:24:11 +0530 Subject: [PATCH 66/73] tools/glusterfind: verifying volume is online Volume needs to be online (Started) to perform meaningful operations i.e. for "create" and "pre". This is now verified. Change-Id: I4677780e22ad35ae82eae0765feb605cba69e437 BUG: 1224236 Reviewed-on: http://review.gluster.org/#/c/10955/ Reviewed-on: http://review.gluster.org/#/c/11187/ Signed-off-by: Milind Changire Reviewed-on: https://code.engineering.redhat.com/gerrit/50619 Reviewed-by: Saravanakumar Arumugam Reviewed-by: Aravinda Vishwanathapura Krishna Murthy Tested-by: Aravinda Vishwanathapura Krishna Murthy --- tools/glusterfind/src/main.py | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py index 4c1686c..850024b 100644 --- a/tools/glusterfind/src/main.py +++ b/tools/glusterfind/src/main.py @@ -31,6 +31,7 @@ ParseError = etree.ParseError if hasattr(etree, 'ParseError') else SyntaxError logger = logging.getLogger() node_outfiles = [] +vol_statusStr = "Stopped" class StoreAbsPath(Action): @@ -87,6 +88,10 @@ 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, + logger=logger) + # If Full backup is requested or start time is zero, use brickfind change_detector = conf.get_change_detector("changelog") if args.full: @@ -123,6 +128,10 @@ 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, + logger=logger) + # When glusterfind create, create session directory in # each brick nodes cmd = [conf.get_opt("nodeagent"), @@ -173,6 +182,8 @@ def get_nodes(volume): Get the gluster volume info xml output and parse to get the brick details. """ + global vol_statusStr; + cmd = ["gluster", 'volume', 'info', volume, "--xml"] _, data, _ = execute(cmd, exit_msg="Failed to Run Gluster Volume Info", @@ -184,6 +195,9 @@ def get_nodes(volume): if int(count_el.text) == 0: fail("Unable to get volume details", logger=logger) + # this status is used in caller: run_cmd_nodes + vol_statusStr = tree.find('volInfo/volumes/volume/statusStr').text + nodes = [] volume_el = tree.find('volInfo/volumes/volume') try: -- 1.7.1