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', '-k', '-x', '-c', 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
def try_umount(self): cmd = ['umount', self.mount_point] (ret, out, err) = self.vcall(cmd, err_to_warn=True) if ret == 0: return 0 if "not currently mounted" in err: 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) for i in range(4): cmd = ['fuser', '-kcv', 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
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): 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
def boot_and_wait_reboot(self): """ Boot zone, then wait for automatic zone reboot boot zone wait for zone init process end wait for zone running wait for zone operational """ self.log.info("wait for zone boot and reboot...") self.zone_boot() if self.is_running is False: raise ex.excError("zone is not running") cmd = [PGREP, "-z", self.name, "-f", INIT] out, err, st = justcall(cmd) if st != 0: raise ex.excError("fail to detect zone init process") pids = " ".join(out.split("\n")).rstrip() cmd = [PWAIT, pids] self.log.info("wait for zone init process %s termination" % (pids)) if qcall(cmd) != 0: raise ex.excError("failed " + " ".join(cmd)) self.log.info("wait for zone running again") self.wait_for_fn(self.is_up, self.start_timeout, 2) self.log.info("wait for zone operational") self.wait_for_fn(self.operational, self.start_timeout, 2)
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.excError self.write_mksf()
def operational(self): """ Return status of: zlogin zone pwd """ cmd = self.runmethod + ["pwd"] if qcall(cmd) == 0: return True return False
def has_it(self): """ Return True if the vg is present """ if not which("vxdg"): raise ex.excError("vxdg command not found") ret = qcall(["vxdg", "list", self.name]) if ret == 0: return True else: return False
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.excError
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.excError """ 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)
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
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
def operational(self): cmd = self.runmethod + ['/sbin/ifconfig', '-a'] ret = qcall(cmd) if ret == 0: return True return False
def operational(self): cmd = self.runmethod + ['pwd'] ret = qcall(cmd) if ret == 0: return True return False
def lv_exists(self, device): device = device.split("/")[-1] ret = qcall(['lslv', device]) if ret == 0: return True return False
def lv_exists(self, device): if qcall([rcEnv.syspaths.lvs, device]) == 0: return True return False
def lv_exists(self, device): if qcall(['lvdisplay', device]) == 0: return True return False