summaryrefslogtreecommitdiffstats
path: root/libs/utils/serverutils.py
diff options
context:
space:
mode:
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