summaryrefslogtreecommitdiffstats
path: root/cns-libs/cnslibs/common/command.py
diff options
context:
space:
mode:
authorValerii Ponomarov <kiparis.kh@gmail.com>2018-07-18 17:41:26 +0530
committerValerii Ponomarov <vponomar@redhat.com>2018-09-10 21:15:39 +0530
commit77a65dab844055fef3a043d40dc3b35f71a7d84f (patch)
tree090b23232ec538301f1c1da9a283ba96cc732350 /cns-libs/cnslibs/common/command.py
parent1c378d2f3f5d97583ec3310a14679035a967a9e3 (diff)
[CNS-944] Add test with arbiter volume creation
Change-Id: I257f3e6a7389c9f15a4388c241e787782c186d14
Diffstat (limited to 'cns-libs/cnslibs/common/command.py')
-rw-r--r--cns-libs/cnslibs/common/command.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/cns-libs/cnslibs/common/command.py b/cns-libs/cnslibs/common/command.py
new file mode 100644
index 00000000..e2c41545
--- /dev/null
+++ b/cns-libs/cnslibs/common/command.py
@@ -0,0 +1,20 @@
+from glusto.core import Glusto as g
+
+
+def cmd_run(cmd, hostname, raise_on_error=True):
+ """Glusto's command runner wrapper.
+
+ Args:
+ cmd (str): Shell command to run on the specified hostname.
+ hostname (str): hostname where Glusto should run specified command.
+ raise_on_error (bool): defines whether we should raise exception
+ in case command execution failed.
+ Returns:
+ str: Stripped shell command's stdout value.
+ """
+ ret, out, err = g.run(hostname, cmd, "root")
+ if raise_on_error:
+ msg = ("Failed to execute command '%s' on '%s' node. Got non-zero "
+ "return code '%s'. Err: %s" % (cmd, hostname, ret, err))
+ assert int(ret) == 0, msg
+ return out.strip()