From fee2d2d2b242c2423a8fa8c6f79db8d99082ac3e Mon Sep 17 00:00:00 2001 From: Arjun Sharma Date: Fri, 19 Jul 2019 14:23:29 +0530 Subject: Cthon test case for NFS Ganesha Change-Id: I3fb826bd0ecbe46bee4b9f8594b23f16921adbec Signed-off-by: Arjun Sharma --- glustolibs-misc/glustolibs/misc/misc_libs.py | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'glustolibs-misc') 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 -- cgit