summaryrefslogtreecommitdiffstats
path: root/libs/utils/serverutils.py
diff options
context:
space:
mode:
authorShwetha-H-Panduranga <shwetha@gluster.com>2012-02-03 15:52:29 +0530
committerShwetha-H-Panduranga <shwetha@gluster.com>2012-02-06 21:08:26 +0530
commit2e06fd3e78331c0352fb9992a7ca3f49f86a2f54 (patch)
treeb61b1b25dca1a35a5acd12906d6d116b0d73498d /libs/utils/serverutils.py
parent39329e86b7cc99a5d44e88f53ffc60ac46d2879b (diff)
Changing the return value of all the libraries. The libraries will return a dictionary with 'exitstatus', 'stdoutdata', 'stderrdata' as keys. The value of 'exitstatus' is the exit status of the command execution. The 'stdoutdata' contains data written to the stdout during command execution. The 'stderrdata' contains data written to stderr during command execution.
Change-Id: Ib04062ab34ddf6cf1d8bde07716c4a3be1800ec5 Signed-off-by: Shwetha-H-Panduranga <shwetha@gluster.com>
Diffstat (limited to 'libs/utils/serverutils.py')
-rw-r--r--libs/utils/serverutils.py42
1 files changed, 18 insertions, 24 deletions
diff --git a/libs/utils/serverutils.py b/libs/utils/serverutils.py
index 10fe830..0cecee0 100644
--- a/libs/utils/serverutils.py
+++ b/libs/utils/serverutils.py
@@ -1,9 +1,9 @@
"""serverutils module
"""
import re
+import atfutils
import hostutils
from atfglobals import GlobalObj
-import atfutils
def md5sum_of_brick(brickkey):
"""
@@ -14,11 +14,8 @@ def md5sum_of_brick(brickkey):
stdoutdata: stdout data of arequal-checksum command execution
stderrdata: stderr data of arequal-checksum command execution
"""
- output = {}
- output["exitstatus"] = None
- output["stdoutdata"] = None
- output["stderrdata"] = None
logger = GlobalObj.getLoggerObj()
+ output = atfutils.get_new_output_obj()
env = GlobalObj.getTestenvObj()
raw_brick_obj = env.getRawBrick(brickkey)
@@ -27,7 +24,6 @@ def md5sum_of_brick(brickkey):
brickkey)
output["exitstatus"] = 1
return output
-
else:
serverkey = re.split("\.", raw_brick_obj.hostname, maxsplit=1)[0]
@@ -67,20 +63,11 @@ def md5sum_of_bricks(bricks):
def get_gfid_on_brick(brickkey, filename="."):
"""
"""
- output = {}
- output["exitstatus"] = None
- output["stdoutdata"] = None
- output["stderrdata"] = None
base_command = "getfattr -n 'trusted.gfid' -e hex"
command = ' '.join([base_command, filename])
output = execute_on_brick(brickkey, command)
- if atfutils.assert_success(output['exitstatus']):
- atfutils.print_stdout(output['stdoutdata'])
- atfutils.print_stderr(output['stderrdata'])
-
- elif output['stdoutdata'] is None or (not output['stdoutdata']):
+ if output['stdoutdata'] is None or (not output['stdoutdata']):
output['stdoutdata'] = ""
-
else:
output['stdoutdata'] = str(output['stdoutdata'])
@@ -99,12 +86,8 @@ def get_gfid_on_bricks(bricks, filename="."):
def execute_on_brick(brickkey, command, commandInput=None):
"""
"""
- output = {}
- output["exitstatus"] = None
- output["stdoutdata"] = None
- output["stderrdata"] = None
-
logger = GlobalObj.getLoggerObj()
+ output = atfutils.get_new_output_obj()
env = GlobalObj.getTestenvObj()
raw_brick_obj = env.getRawBrick(brickkey)
@@ -125,9 +108,20 @@ def execute_on_brick(brickkey, command, commandInput=None):
else:
exportdirpath = brick_obj.path
- command = "cd " + exportdirpath + ";" + command
+ command = "cd %s ; %s" % (exportdirpath , command)
output = hostutils.execute_command(serverkey, command, commandInput)
return output
-__all__ = ['execute_on_brick',
- 'md5sum_of_bricks']
+def execute_on_bricks(bricks, command, commandInput=None):
+ """
+ Parameters:
+ bricks: List of bricks (Ex: [brick1, brick2, brick3, ...])
+ command: Command to execute on brick
+ """
+ all_outputs = {}
+
+ for brickkey in bricks:
+ output = execute_on_brick(brickkey, command, commandInput)
+ all_outputs[brickkey] = output
+
+ return all_outputs