def umountSleepPath(self, rpath): """ Отмонтировать указанный путь, а также отключить используемые в этом пути loop устройства и raid """ # check for mount loops = getLoopFromPath(rpath) if loops: setLoops = set(map(lambda x:x.partition('/dev/')[2],loops)) mdInfo = getMdRaidDevices() for k,v in mdInfo.items(): if setLoops & set(v): self.umountSleepPath('/dev/%s'%k) process('/sbin/mdadm','--stop','/dev/%s'%k).success() for loop in loops: self.umountSleepPath(loop) process('/sbin/losetup','-d',loop).success() if isMount(rpath): for waittime in [0,0.5,1,2]: time.sleep(waittime) if not self.execProg("umount %s"%rpath) is False \ or not isMount(rpath): if not isMount(rpath): return True self.execProg("fuser -km %s"%rpath) for waittime in [0.5, 0.5, 0.5, 0.5, 0.5, 0.5]: time.sleep(waittime) if not self.execProg("umount %s"%rpath) is False \ or not isMount(rpath): if not isMount(rpath): return True self.execProg("umount -l %s"%rpath) else: if isMount(rpath): self.printERROR(_("Failed to unmount directory %s")%rpath) return False return True
def umountSleepPath(self, rpath): """ Unmount path, sleep by failed and repeat """ # check for mount if isMount(rpath): for waittime in [0,0.5,1,2]: time.sleep(waittime) if not self.execProg("umount %s"%rpath) is False \ or not isMount(rpath): if not isMount(rpath): return True self.execProg("fuser -km %s"%rpath) for waittime in [0.5, 0.5, 0.5, 0.5, 0.5, 0.5]: time.sleep(waittime) if not self.execProg("umount %s"%rpath) is False \ or not isMount(rpath): if not isMount(rpath): return True else: if isMount(rpath): self.printERROR(_("Failed to unmount directory %s")%rpath) return False return True
def get(self): """Current system is scratch""" if self.Get('os_root_type') == 'livecd': return "on" if isMount('/mnt/scratch/workspace') else "off" else: return "on" if isMount('/mnt/scratch') else "off"