summaryrefslogtreecommitdiffstats
path: root/glustolibs-misc
diff options
context:
space:
mode:
authorArjun Sharma <arjsharm@redhat.com>2019-07-19 14:23:29 +0530
committerArjun Sharma <arjsharm@redhat.com>2019-09-12 13:01:08 +0530
commitfee2d2d2b242c2423a8fa8c6f79db8d99082ac3e (patch)
treecc4e31e174fe89e614232f7fc8cf2e1ee6ce5a70 /glustolibs-misc
parent32623566f1a12b9b6f22300b76f5941c5e8b8c75 (diff)
Cthon test case for NFS Ganesha
Change-Id: I3fb826bd0ecbe46bee4b9f8594b23f16921adbec Signed-off-by: Arjun Sharma <arjsharm@redhat.com>
Diffstat (limited to 'glustolibs-misc')
-rwxr-xr-xglustolibs-misc/glustolibs/misc/misc_libs.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/glustolibs-misc/glustolibs/misc/misc_libs.py b/glustolibs-misc/glustolibs/misc/misc_libs.py
index ee6c74c6d..7b8010cd9 100755
--- a/glustolibs-misc/glustolibs/misc/misc_libs.py
+++ b/glustolibs-misc/glustolibs/misc/misc_libs.py
@@ -590,3 +590,38 @@ def daemon_reload(node):
g.log.error("Failed to reload the daemon")
return False
return True
+
+
+def git_clone_and_compile(hosts, link, dir_name,
+ compile_option='False'):
+ """This function clones a repo and depending
+ on kwargs compiles it.
+ Args:
+ hosts (list|str): List of hosts where the repo needs to be cloned.
+ link (str): Link to the repo that needs to be cloned.
+ dir_name (str): Directory where the repo is to be cloned.
+
+ Kwargs:
+ compile_option (bool): If this option is set to True
+ then the cloned repo will be compiled otherwise
+ the repo is only cloned on the hosts.
+
+ Returns:
+ bool : True on successfull cloning (and compilation)
+ False otherwise.
+ """
+ if isinstance(hosts, str):
+ hosts = [hosts]
+
+ cmd = ("cd /root; git clone %s %s;" % (link, dir_name))
+ if compile_option:
+ cmd = cmd + (("cd /root/%s; make") % dir_name)
+
+ for host in hosts:
+ ret, _, _ = g.run(host, cmd)
+ if ret:
+ g.log.error("Cloning/Compiling repo failed on %s" % host)
+ return False
+ else:
+ g.log.info("Successfully cloned/compiled repo on %s" % host)
+ return True