Example #1
0
 def test_qcall(non_existing_file):
     """
     qcall()
     """
     ret = qcall(["ls", non_existing_file])
     assert ret > 0
     ret = qcall(None)
     assert ret > 0
     ret = qcall()
     assert ret > 0
     ret = qcall(Env.syspaths.true)
     assert ret == 0
Example #2
0
def try_umount(self):
    cmd = ['umount', self.mount_point]
    (ret, out, err) = self.vcall(cmd, err_to_info=True)
    if ret == 0:
        return 0
    """ don't try to kill process using the source of a
        protected bind mount
    """
    if protected_mount(self.mount_point):
        return 1
    """ best effort kill of all processes that might block
        the umount operation. The priority is given to mass
        action reliability, ie don't contest oprator's will
    """
    cmd = ['sync']
    (ret, out, err) = self.vcall(cmd, err_to_info=True)

    for i in range(4):
        cmd = ['fuser', '-kc', self.mount_point]
        (ret, out, err) = self.vcall(cmd, err_to_info=True)
        self.log.info('umount %s' % self.mount_point)
        cmd = ['umount', self.mount_point]
        ret = qcall(cmd)
        if ret == 0:
            break

    return ret
Example #3
0
 def presync(self):
     """ this one is exported as a service command line arg
     """
     cmd = ['vgexport', '-m', self.mapfile_name(), '-p', '-s', self.name]
     ret = qcall(cmd)
     if ret != 0:
         raise ex.Error
     self.write_mksf()
Example #4
0
 def operational(self):
     """
     Return status of: zlogin zone pwd
     """
     cmd = self.runmethod + ["pwd"]
     if qcall(cmd) == 0:
         return True
     return False
Example #5
0
 def has_it(self):
     """
     Return True if the vg is present
     """
     if not which("vxdg"):
         raise ex.Error("vxdg command not found")
     ret = qcall(["vxdg", "list", self.name])
     if ret == 0:
         return True
     else:
         return False
Example #6
0
 def container_start(self):
     cmd = ['jail', '-c', 'name='+self.name, 'path='+self.jailroot,
            'host.hostname='+self.name]
     if len(self.ips) > 0:
         cmd += ['ip4.addr='+','.join(self.ips)]
     if len(self.ip6s) > 0:
         cmd += ['ip6.addr='+','.join(self.ip6s)]
     cmd += ['command=/bin/sh', '/etc/rc']
     self.log.info(' '.join(cmd))
     ret = qcall(cmd)
     if ret != 0:
         raise ex.Error
Example #7
0
    def snapdestroykey(self, s):
        if protected_mount(self.snaps[s]['snap_mnt']):
            self.log.error("the snapshot is no longer mounted in %s. panic."%self.snaps[s]['snap_mnt'])
            raise ex.Error

        """ fuser on HP-UX outs to stderr ...
        """
        cmd = ['fuser', '-c', '-x', '-k', self.snaps[s]['snap_mnt']]
        ret = qcall(cmd)

        cmd = ['umount', self.snaps[s]['snap_mnt']]
        (ret, out, err) = self.vcall(cmd)
        cmd = ['snapshot', '-d', self.snaps[s]['snap_dev']]
        (ret, buff, err) = self.vcall(cmd)
Example #8
0
 def is_up(self):
     """Returns True if the vg is present and not disabled
     """
     if not which("vxdg"):
         self.status_log("vxdg command not found")
         return False
     if not self.has_it():
         return False
     cmd = ["vxprint", "-ng", self.name]
     ret = qcall(cmd)
     if ret == 0:
         return True
     else:
         return False
Example #9
0
    def try_umount(self, dev=None, mnt=None, fs_type=None):
        if dev is None:
            dev = self.device
        if mnt is None:
            mnt = self.mount_point
        if fs_type is None:
            fs_type = self.fs_type

        if fs_type == "zfs":
            ret, out, err = self.umount_zfs(dev, mnt)
        else:
            ret, out, err = self.umount_generic(mnt)

        if ret == 0:
            return 0

        if "not mounted" in err:
            return 0

        # don't try to kill process using the source of a
        # protected bind mount
        if protected_mount(mnt):
            return 1

        # best effort kill of all processes that might block
        # the umount operation. The priority is given to mass
        # action reliability, ie don't contest oprator's will
        cmd = ['sync']
        ret, out, err = self.vcall(cmd)

        if os.path.isdir(dev):
            fuser_opts = '-kv'
        else:
            fuser_opts = '-kmv'
        for _ in range(4):
            cmd = ['fuser', fuser_opts, mnt]
            (ret, out, err) = self.vcall(cmd, err_to_info=True)
            self.log.info('umount %s', mnt)
            cmd = ['umount', mnt]
            ret = qcall(cmd)
            if ret == 0:
                break

        return ret
Example #10
0
def try_umount(self):
    cmd = ['diskutil', 'umount', self.mount_point]
    (ret, out, err) = self.vcall(cmd, err_to_info=True)
    if ret == 0:
        return 0

    cmd = ['diskutil', 'umount', 'force', self.mount_point]
    (ret, out, err) = self.vcall(cmd, err_to_info=True)
    if ret == 0:
        return 0

    cmd = ['umount', self.mount_point]
    (ret, out, err) = self.vcall(cmd, err_to_info=True)
    if ret == 0:
        return 0
    """ don't try to kill process using the source of a
        protected bind mount
    """
    if protected_mount(self.mount_point):
        return 1
    """ best effort kill of all processes that might block
        the umount operation. The priority is given to mass
        action reliability, ie don't contest oprator's will
    """
    cmd = ['sync']
    (ret, out, err) = self.vcall(cmd, err_to_info=True)

    for i in range(4):
        nb_killed = self.killfuser(self.mount_point)
        self.log.info('umount %s' % self.mount_point)
        cmd = ['umount', self.mount_point]
        ret = qcall(cmd)
        if ret == 0 or nb_killed == 0:
            break

    if ret != 0:
        self.log.info(
            "no more process using %s, yet umount fails. try forced umount." %
            self.mount_point)
        cmd = ['umount', '-f', self.mount_point]
        (ret, out, err) = self.vcall(cmd, err_to_info=True)

    return ret
Example #11
0
 def operational(self):
     cmd = self.runmethod + ['/sbin/ifconfig', '-a']
     ret = qcall(cmd)
     if ret == 0:
         return True
     return False
Example #12
0
 def lv_exists(self, device):
     device = device.split("/")[-1]
     ret = qcall(['lslv', device])
     if ret == 0:
         return True
     return False
Example #13
0
def lv_exists(self, device):
    if qcall([Env.syspaths.lvs, device]) == 0:
        return True
    return False
Example #14
0
 def operational(self):
     cmd = self.runmethod + ['pwd']
     ret = qcall(cmd)
     if ret == 0:
         return True
     return False
Example #15
0
 def lv_exists(self, device):
     if qcall(['lvdisplay', device]) == 0:
         return True
     return False