added a shell command with result, leveraged it usage to get output for failures during addfile and mounting within nodes

This commit is contained in:
Blake J. Harnden 2018-02-07 19:13:51 -08:00
parent 78537d8e95
commit 127d0b0666
3 changed files with 30 additions and 5 deletions

View file

@ -6,6 +6,7 @@ by invoking the vcmd shell command.
"""
import os
import shlex
import vcmd
@ -93,6 +94,10 @@ class VnodeClient(object):
"""
self._verify_connection()
# split shell string to shell array for convenience
if type(args) == str:
args = shlex.split(args)
p, stdin, stdout, stderr = self.popen(args)
output = stdout.read() + stderr.read()
stdin.close()
@ -184,6 +189,17 @@ class VnodeClient(object):
"""
return self.cmd([sh, "-c", cmdstr])
def shcmd_result(self, cmd, sh="/bin/sh"):
"""
Execute a shell command and return the exist status and combined output.
:param str cmd: shell command to run
:param str sh: shell to run command in
:return: exist status and combined output
:rtype: tuple[int, str]
"""
return self.cmdresult([sh, "-c", cmd])
def getaddr(self, ifname, rescan=False):
"""
Get address for interface on node.