def doUnmountMaster(cls, masterdir): """ Unmount the master metadata file system. Should be called only by SPM. """ # fuser processes holding mount point and validate that the umount succeeded cls.__handleStuckUmount(masterdir) if fileUtils.isMounted(mountPoint=masterdir): # Try umount, take 1 fileUtils.umount(mountPoint=masterdir) if fileUtils.isMounted(mountPoint=masterdir): # umount failed, try to kill that processes holding mount point fuser_cmd = [constants.EXT_FUSER, "-m", masterdir] (rc, out, err) = misc.execCmd(fuser_cmd) # It was unmounted while I was checking no need to do anything if not fileUtils.isMounted(mountPoint=masterdir): return cls.log.warn(out) if len(out) == 0: cls.log.warn( "Unmount failed because of errors that fuser can't solve" ) else: for match in out[0].split(): try: pid = int(match) except ValueError: # Match can be "kernel" continue try: cls.log.debug("Trying to kill pid %d", pid) os.kill(pid, signal.SIGKILL) except OSError, e: if e.errno == errno.ESRCH: # No such process pass elif e.errno == errno.EPERM: # Operation not permitted cls.log.warn( "Could not kill pid %d because operation was not permitted", pid) else: cls.log.warn( "Could not kill pid %d because an unexpected error", exc_info=True) except: cls.log.warn( "Could not kill pid %d because an unexpected error", exc_info=True)
def selftest(self): """ Run internal self test """ if not fileUtils.isMounted(mountPoint=self.mountpoint, mountType=fileUtils.FSTYPE_NFS): raise se.StorageDomainFSNotMounted # Run general part of selftest fileSD.FileStorageDomain.selftest(self)
def doUnmountMaster(cls, masterdir): """ Unmount the master metadata file system. Should be called only by SPM. """ # fuser processes holding mount point and validate that the umount succeeded cls.__handleStuckUmount(masterdir) if fileUtils.isMounted(mountPoint=masterdir): # Try umount, take 1 fileUtils.umount(mountPoint=masterdir) if fileUtils.isMounted(mountPoint=masterdir): # umount failed, try to kill that processes holding mount point fuser_cmd = [constants.EXT_FUSER, "-m", masterdir] (rc, out, err) = misc.execCmd(fuser_cmd) # It was unmounted while I was checking no need to do anything if not fileUtils.isMounted(mountPoint=masterdir): return cls.log.warn(out) if len(out) == 0: cls.log.warn("Unmount failed because of errors that fuser can't solve") else: for match in out[0].split(): try: pid = int(match) except ValueError: # Match can be "kernel" continue try: cls.log.debug("Trying to kill pid %d", pid) os.kill(pid, signal.SIGKILL) except OSError, e: if e.errno == errno.ESRCH: # No such process pass elif e.errno == errno.EPERM: # Operation not permitted cls.log.warn("Could not kill pid %d because operation was not permitted", pid) else: cls.log.warn("Could not kill pid %d because an unexpected error", exc_info = True) except: cls.log.warn("Could not kill pid %d because an unexpected error", exc_info = True)
def _preCreateValidation(cls, sdUUID, domPath, typeSpecificArg, version): # Some trivial resource validation if ":" not in typeSpecificArg: raise se.StorageDomainIllegalRemotePath(typeSpecificArg) sd.validateDomainVersion(version) # Make sure the underlying file system is mounted if not fileUtils.isMounted(mountPoint=domPath, mountType=fileUtils.FSTYPE_NFS): raise se.StorageDomainFSNotMounted(typeSpecificArg) validateDirAccess(domPath) # Make sure there are no remnants of other domain mdpat = os.path.join(domPath, "*", sd.DOMAIN_META_DATA) if len(oop.getProcessPool(sdUUID).glob.glob(mdpat)) > 0: raise se.StorageDomainNotEmpty(typeSpecificArg)
def validateMasterMount(self): return fileUtils.isMounted(mountPoint=self.getMasterDir())
try: cls.log.debug("Trying to kill pid %d", pid) os.kill(pid, signal.SIGKILL) except OSError, e: if e.errno == errno.ESRCH: # No such process pass elif e.errno == errno.EPERM: # Operation not permitted cls.log.warn("Could not kill pid %d because operation was not permitted", pid) else: cls.log.warn("Could not kill pid %d because an unexpected error", exc_info = True) except: cls.log.warn("Could not kill pid %d because an unexpected error", exc_info = True) # Try umount, take 2 fileUtils.umount(mountPoint=masterdir) if fileUtils.isMounted(mountPoint=masterdir): # We failed to umount masterFS # Forcibly rebooting the SPM host would be safer. ??? raise se.StorageDomainMasterUnmountError(masterdir, rc) def unmountMaster(self): """ Unmount the master metadata file system. Should be called only by SPM. """ masterdir = os.path.join(self.domaindir, sd.MASTER_FS_DIR) self.doUnmountMaster(masterdir) # It is time to deactivate the master LV now lvm.deactivateLVs(self.sdUUID, MASTERLV) def refreshDirTree(self):
elif e.errno == errno.EPERM: # Operation not permitted cls.log.warn( "Could not kill pid %d because operation was not permitted", pid) else: cls.log.warn( "Could not kill pid %d because an unexpected error", exc_info=True) except: cls.log.warn( "Could not kill pid %d because an unexpected error", exc_info=True) # Try umount, take 2 fileUtils.umount(mountPoint=masterdir) if fileUtils.isMounted(mountPoint=masterdir): # We failed to umount masterFS # Forcibly rebooting the SPM host would be safer. ??? raise se.StorageDomainMasterUnmountError(masterdir, rc) def unmountMaster(self): """ Unmount the master metadata file system. Should be called only by SPM. """ masterdir = os.path.join(self.domaindir, sd.MASTER_FS_DIR) self.doUnmountMaster(masterdir) # It is time to deactivate the master LV now lvm.deactivateLVs(self.sdUUID, MASTERLV) def refreshDirTree(self): # create domain images folder