Example #1
0
def sysguess(ipaddr):
    """ guess on system of remote target """
    out = __fapi.run(ipaddr, 'uname -s')
    if out.failed:
        raise RuntimeError('unable to guess system on %s' % (ipaddr))

    if out == "Linux":
        out = __fapi.run(ipaddr, 'cat /etc/issue')
        system = out.split()[0].lower()
    else: system = out.lower()

    hostname = __fapi.run(ipaddr, "hostname")

    return hostname, system
Example #2
0
def wget_file(self, target, storage, use_sudo = False):
    """ wget file or directory """

    cmd = "wget %s -O %s" % (target, storage)
    if use_sudo:
        return __fapi.sudo(self.srv_ip, cmd, nocheck = True)
    return __fapi.run(self.srv_ip, cmd, nocheck = True)
Example #3
0
def tar_extract(self, target, storage, files = list(),
                compr = True, use_sudo = False):
    """ extract files from tar archive """

    opts = "xf"
    if compr is True:
        opts = "xzf"

    cmd = "tar %s %s -C %s %s" % (opts, target, storage, " ".join(files))
    if use_sudo:
        return __fapi.sudo(self.srv_ip, cmd, nocheck = True)
    return __fapi.run(self.srv_ip, cmd, nocheck = True)
Example #4
0
def check_prerequisites(srv_ip):
    """ check prerequisites on remote host """
    ret = True

    __LOG.log_d("trying to run command")
    out = __fapi.run(srv_ip, 'whoami', nocheck=True)
    if out.failed:
        __LOG.log_c("unable to execute commands on remote host")
        ret = False

    __LOG.log_d("trying to run sudo command")
    out = __fapi.sudo(srv_ip, 'whoami', nocheck=True)
    if out.failed:
        __LOG.log_c("unable to execute commands with sudo on remote host")
        ret = False

    return ret
Example #5
0
def symlink(self, target, source, use_sudo = False):
    """ create symlink with 'ln' binary """
    if use_sudo:
        return __fapi.sudo(self.srv_ip, "ln -s %s %s" % (target, source))
    return __fapi.run(self.srv_ip, "ln -s %s %s" % (target, source))
Example #6
0
def chmod_file(self, filename, mode, use_sudo = False):
    """ chmod file with mode """
    if use_sudo:
        return __fapi.sudo(self.srv_ip, "chmod %s %s" % (mode, filename))
    return __fapi.run(self.srv_ip, "chmod %s %s" % (mode, filename))