def test_is_mounted_deleted(self): with fake_mounts([ b"server:/path " br"/rhev/data-center/mnt/server:_path\040(deleted) " b"nfs4 defaults 0 0" ]): self.assertTrue( mount.isMounted(b"/rhev/data-center/mnt/server:_path"))
def findDomainPath(sdUUID): for tmpSdUUID, domainPath in fileSD.scanDomains("*"): if tmpSdUUID == sdUUID: mountpoint = os.path.dirname(domainPath) if mount.isMounted(mountpoint): return domainPath raise se.StorageDomainDoesNotExist(sdUUID)
def test_is_not_mounted(self): with fake_mounts([ b"server:/path " b"/rhev/data-center/mnt/server:_path " b"nfs4 defaults 0 0" ]): self.assertFalse( mount.isMounted(b"/rhev/data-center/mnt/server:_other_path"))
def test_is_mounted(self): with fake_mounts([ "server:/path " "/rhev/data-center/mnt/server:_path " "nfs4 defaults 0 0" ]): self.assertTrue( mount.isMounted("/rhev/data-center/mnt/server:_path"))
def findDomainPath(sdUUID): glusterDomPath = os.path.join(sd.GLUSTERSD_DIR, "*") for tmpSdUUID, domainPath in fileSD.scanDomains(glusterDomPath): if tmpSdUUID == sdUUID: mountpoint = os.path.dirname(domainPath) if mount.isMounted(mountpoint): return domainPath raise se.StorageDomainDoesNotExist(sdUUID)
def _preCreateValidation(cls, sdUUID, domPath, typeSpecificArg, storageType, version): # Some trivial resource validation # TODO Checking storageType==nfs in the nfs class is not clean if storageType == sd.NFS_DOMAIN and ":" not in typeSpecificArg: raise se.StorageDomainIllegalRemotePath(typeSpecificArg) sd.validateDomainVersion(version) # Make sure the underlying file system is mounted if not mount.isMounted(domPath): raise se.StorageDomainFSNotMounted(domPath) fileSD.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 _preCreateValidation(cls, sdUUID, domPath, typeSpecificArg, storageType, version): # Some trivial resource validation # TODO Checking storageType==nfs in the nfs class is not clean if storageType == sd.NFS_DOMAIN and ":" not in typeSpecificArg: raise se.StorageDomainIllegalRemotePath(typeSpecificArg) sd.validateDomainVersion(version) # Make sure the underlying file system is mounted if not mount.isMounted(domPath): raise se.StorageDomainFSNotMounted(domPath) fileSD.validateDirAccess(domPath) fileSD.validateFileSystemFeatures(sdUUID, 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 test_is_mounted(self, count): server = b"foobar.baz.qux.com:/var/lib/exports/%04d" mountpoint = (b"/rhev/data-center/mnt/foobar.baz.qux.com:_var_lib" b"_exports_%04d") options = (b"rw,relatime,vers=3,rsize=524288,wsize=524288,namlen=255," b"soft,nosharecache,proto=tcp,timeo=600,retrans=6,sec=sys," b"mountaddr=10.35.0.102,mountvers=3,mountport=892," b"mountproto=udp,local_lock=none,addr=10.35.0.102") version = b"nfs" freq = b"0" passno = b"0" lines = [] for i in range(count): line = b" ".join((server % i, mountpoint % i, options, version, freq, passno)) lines.append(line) with fake_mounts(lines): start = time.time() self.assertTrue(mount.isMounted(mountpoint % i)) elapsed = time.time() - start print("%4d mounts: %f seconds" % (count, elapsed))
def test_is_mounted(self, count): server = b"foobar.baz.qux.com:/var/lib/exports/%04d" mountpoint = (b"/rhev/data-center/mnt/foobar.baz.qux.com:_var_lib" b"_exports_%04d") options = (b"rw,relatime,vers=3,rsize=524288,wsize=524288,namlen=255," b"soft,nosharecache,proto=tcp,timeo=600,retrans=6,sec=sys," b"mountaddr=10.35.0.102,mountvers=3,mountport=892," b"mountproto=udp,local_lock=none,addr=10.35.0.102") version = b"nfs" freq = b"0" passno = b"0" lines = [] for i in range(count): line = b" ".join( (server % i, mountpoint % i, options, version, freq, passno)) lines.append(line) with fake_mounts(lines): start = time.time() self.assertTrue(mount.isMounted(mountpoint % i)) elapsed = time.time() - start print("%4d mounts: %f seconds" % (count, elapsed))
def test_is_not_mounted(self): with fake_mounts([b"server:/path " b"/rhev/data-center/mnt/server:_path " b"nfs4 defaults 0 0"]): self.assertFalse(mount.isMounted( b"/rhev/data-center/mnt/server:_other_path"))
def test_path_with_backslash(self): with fake_mounts( [br"server:/a\134040b /mnt/server:_a\134040b nfs4 opts 0 0"]): self.assertTrue(mount.isMounted(br"/mnt/server:_a\040b")) self.assertFalse(mount.isMounted(br"/mnt/server:_a\134040b"))
def test_is_mounted_deleted(self): with fake_mounts([b"server:/path " br"/rhev/data-center/mnt/server:_path\040(deleted) " b"nfs4 defaults 0 0"]): self.assertTrue(mount.isMounted( b"/rhev/data-center/mnt/server:_path"))
def test_path_with_spaces(self): with fake_mounts( [u"server:/a\\040b /mnt/server:_a\\040b nfs4 opts 0 0"]): self.assertTrue(mount.isMounted("/mnt/server:_a b")) self.assertFalse(mount.isMounted(u"/mnt/server:_a\\040b"))