def __init__(self, spec, vfsType=None, options="", mountClass=mount.Mount): self._vfsType = vfsType # Note: must be normalized before we escape "/" in _getLocalPath. # See https://bugzilla.redhat.com/1300749 self._remotePath = fileUtils.normalize_path(spec) self._options = options self._mount = mountClass(self._remotePath, self._getLocalPath())
def create(cls, sdUUID, domainName, domClass, remotePath, storageType, version, block_size=sc.BLOCK_SIZE_512, alignment=sc.ALIGNMENT_1M): """ Create new storage domain Arguments: sdUUID (UUID): Storage Domain UUID domainName (str): Storage domain name domClass (int): Data/Iso remotePath (str): server:/export_path storageType (int): NFS_DOMAIN, GLUSTERFS_DOMAIN, &etc. version (int): DOMAIN_VERSIONS, block_size (int): Underlying storage block size. Supported value is BLOCK_SIZE_512 alignment (int): Sanlock alignment in bytes to use for this storage domain. Supported value is ALIGN_1M """ cls.log.info("sdUUID=%s domainName=%s remotePath=%s " "domClass=%s, block_size=%s, alignment=%s", sdUUID, domainName, remotePath, domClass, block_size, alignment) cls._validate_block_and_alignment(block_size, alignment, version) remotePath = fileUtils.normalize_path(remotePath) if not misc.isAscii(domainName) and not sd.supportsUnicode(version): raise se.UnicodeArgumentException() # Create local path mntPath = fileUtils.transformPath(remotePath) mntPoint = cls.getMountPoint(mntPath) cls._preCreateValidation(sdUUID, mntPoint, remotePath, storageType, version) domainDir = os.path.join(mntPoint, sdUUID) cls._prepareMetadata(domainDir, sdUUID, domainName, domClass, remotePath, storageType, version, alignment, block_size) # create domain images folder imagesDir = os.path.join(domainDir, sd.DOMAIN_IMAGES) cls.log.info("Creating domain images directory %r", imagesDir) oop.getProcessPool(sdUUID).fileUtils.createdir(imagesDir) # create special imageUUID for ISO/Floppy volumes if domClass is sd.ISO_DOMAIN: isoDir = os.path.join(imagesDir, sd.ISO_IMAGE_UUID) cls.log.info("Creating ISO domain images directory %r", isoDir) oop.getProcessPool(sdUUID).fileUtils.createdir(isoDir) fsd = cls(os.path.join(mntPoint, sdUUID)) fsd.initSPMlease() return fsd
def create(cls, sdUUID, domainName, domClass, remotePath, storageType, version): """ Create new storage domain. 'sdUUID' - Storage Domain UUID 'domainName' - storage domain name ("iso" or "data domain name") 'domClass' - Data/Iso 'remotePath' - server:/export_path 'storageType' - NFS_DOMAIN, LOCALFS_DOMAIN, &etc. 'version' - DOMAIN_VERSIONS """ cls.log.info("sdUUID=%s domainName=%s remotePath=%s " "domClass=%s", sdUUID, domainName, remotePath, domClass) remotePath = fileUtils.normalize_path(remotePath) if not misc.isAscii(domainName) and not sd.supportsUnicode(version): raise se.UnicodeArgumentException() # Create local path mntPath = fileUtils.transformPath(remotePath) mntPoint = cls.getMountPoint(mntPath) cls._preCreateValidation(sdUUID, mntPoint, remotePath, storageType, version) domainDir = os.path.join(mntPoint, sdUUID) cls._prepareMetadata(domainDir, sdUUID, domainName, domClass, remotePath, storageType, version) # create domain images folder imagesDir = os.path.join(domainDir, sd.DOMAIN_IMAGES) cls.log.info("Creating domain images directory %r", imagesDir) oop.getProcessPool(sdUUID).fileUtils.createdir(imagesDir) # create special imageUUID for ISO/Floppy volumes if domClass is sd.ISO_DOMAIN: isoDir = os.path.join(imagesDir, sd.ISO_IMAGE_UUID) cls.log.info("Creating ISO domain images directory %r", isoDir) oop.getProcessPool(sdUUID).fileUtils.createdir(isoDir) fsd = cls(os.path.join(mntPoint, sdUUID)) fsd.initSPMlease() return fsd
def _parseFstabLine(line): (fs_spec, fs_file, fs_vfstype, fs_mntops, fs_freq, fs_passno) = line.split()[:6] fs_mntops = fs_mntops.split(",") fs_freq = int(fs_freq) fs_passno = int(fs_passno) # Using NFS4 the kernel shows the mount path with double slashes, # regarless of the original (normalized) mount path. fs_spec = fileUtils.normalize_path(_unescape_spaces(fs_spec)) # We expect normalized fs_file from the kernel. fs_file = _unescape_spaces(fs_file) if fs_file.endswith(_DELETED_SUFFIX): fs_file = fs_file[:-len(_DELETED_SUFFIX)] return MountRecord(fs_spec, fs_file, fs_vfstype, fs_mntops, fs_freq, fs_passno)
def create(cls, sdUUID, domainName, domClass, remotePath, storageType, version): """ Create new storage domain. 'sdUUID' - Storage Domain UUID 'domainName' - storage domain name ("iso" or "data domain name") 'domClass' - Data/Iso 'remotePath' - server:/export_path 'storageType' - NFS_DOMAIN, LOCALFS_DOMAIN, &etc. 'version' - DOMAIN_VERSIONS """ cls.log.info("sdUUID=%s domainName=%s remotePath=%s " "domClass=%s", sdUUID, domainName, remotePath, domClass) remotePath = fileUtils.normalize_path(remotePath) if not misc.isAscii(domainName) and not sd.supportsUnicode(version): raise se.UnicodeArgumentException() # Create local path mntPath = fileUtils.transformPath(remotePath) mntPoint = cls.getMountPoint(mntPath) cls._preCreateValidation(sdUUID, mntPoint, remotePath, storageType, version) domainDir = os.path.join(mntPoint, sdUUID) cls._prepareMetadata(domainDir, sdUUID, domainName, domClass, remotePath, storageType, version) # create domain images folder imagesDir = os.path.join(domainDir, sd.DOMAIN_IMAGES) oop.getProcessPool(sdUUID).fileUtils.createdir(imagesDir) # create special imageUUID for ISO/Floppy volumes if domClass is sd.ISO_DOMAIN: isoDir = os.path.join(imagesDir, sd.ISO_IMAGE_UUID) oop.getProcessPool(sdUUID).fileUtils.createdir(isoDir) fsd = cls(os.path.join(mntPoint, sdUUID)) fsd.initSPMlease() return fsd
def _parseFstabLine(line): (fs_spec, fs_file, fs_vfstype, fs_mntops, fs_freq, fs_passno) = line.split()[:6] fs_mntops = fs_mntops.split(",") fs_freq = int(fs_freq) fs_passno = int(fs_passno) # Using NFS4 the kernel shows the mount path with double slashes, # regarless of the original (normalized) mount path. fs_spec = fileUtils.normalize_path(_parseFstabPath(fs_spec)) # We expect normalized fs_file from the kernel. fs_file = _parseFstabPath(fs_file) for suffix in (" (deleted)", ): if not fs_file.endswith(suffix): continue fs_file = fs_file[:-len(suffix)] break fs_mntops = [_parseFstabPath(item) for item in fs_mntops] return MountRecord(fs_spec, fs_file, fs_vfstype, fs_mntops, fs_freq, fs_passno)
def test_normalize_path_equals(self, path, normalized_path): self.assertEqual(normalized_path, fileUtils.normalize_path(path))
def test_normalize_path_equals(self, path, normalized_path): self.assertEquals(normalized_path, fileUtils.normalize_path(path))
def create(cls, sdUUID, domainName, domClass, remotePath, storageType, version, block_size=sc.BLOCK_SIZE_512, alignment=sc.ALIGN_1M): """ Create new storage domain Arguments: sdUUID (UUID): Storage Domain UUID domainName (str): Storage domain name domClass (int): Data/Iso remotePath (str): server:/export_path storageType (int): NFS_DOMAIN, GLUSTERFS_DOMAIN, &etc. version (int): DOMAIN_VERSIONS, block_size (int): Underlying storage block size. Supported value is BLOCK_SIZE_512 alignment (int): Sanlock alignment in bytes to use for this storage domain. Supported value is ALIGN_1M """ cls.log.info( "sdUUID=%s domainName=%s remotePath=%s " "domClass=%s, block_size=%s, alignment=%s", sdUUID, domainName, remotePath, domClass, block_size, alignment) cls._validate_block_and_alignment(block_size, alignment) remotePath = fileUtils.normalize_path(remotePath) if not misc.isAscii(domainName) and not sd.supportsUnicode(version): raise se.UnicodeArgumentException() # Create local path mntPath = fileUtils.transformPath(remotePath) mntPoint = cls.getMountPoint(mntPath) cls._preCreateValidation(sdUUID, mntPoint, remotePath, storageType, version) domainDir = os.path.join(mntPoint, sdUUID) cls._prepareMetadata(domainDir, sdUUID, domainName, domClass, remotePath, storageType, version) # create domain images folder imagesDir = os.path.join(domainDir, sd.DOMAIN_IMAGES) cls.log.info("Creating domain images directory %r", imagesDir) oop.getProcessPool(sdUUID).fileUtils.createdir(imagesDir) # create special imageUUID for ISO/Floppy volumes if domClass is sd.ISO_DOMAIN: isoDir = os.path.join(imagesDir, sd.ISO_IMAGE_UUID) cls.log.info("Creating ISO domain images directory %r", isoDir) oop.getProcessPool(sdUUID).fileUtils.createdir(isoDir) fsd = cls(os.path.join(mntPoint, sdUUID)) fsd.initSPMlease() return fsd
def create(cls, sdUUID, domainName, domClass, remotePath, storageType, version, block_size=sc.BLOCK_SIZE_512, max_hosts=sc.HOSTS_4K_1M): """ Create new storage domain Arguments: sdUUID (UUID): Storage Domain UUID domainName (str): Storage domain name domClass (int): Data/Iso remotePath (str): server:/export_path storageType (int): NFS_DOMAIN, GLUSTERFS_DOMAIN, &etc. version (int): DOMAIN_VERSIONS, block_size (int): Underlying storage block size. Supported value is BLOCK_SIZE_512 max_hosts (int): Maximum number of hosts accessing this domain, default to sc.HOSTS_4K_1M. """ cls._validate_block_size(block_size, version) remotePath = fileUtils.normalize_path(remotePath) if not misc.isAscii(domainName) and not sd.supportsUnicode(version): raise se.UnicodeArgumentException() # Create local path mntPath = fileUtils.transformPath(remotePath) mntPoint = cls.getMountPoint(mntPath) cls._preCreateValidation(sdUUID, mntPoint, remotePath, storageType, version) storage_block_size = cls._detect_block_size(sdUUID, mntPoint) block_size = cls._validate_storage_block_size(block_size, storage_block_size) alignment = clusterlock.alignment(block_size, max_hosts) domainDir = os.path.join(mntPoint, sdUUID) cls._prepareMetadata(domainDir, sdUUID, domainName, domClass, remotePath, storageType, version, alignment, block_size) # create domain images folder imagesDir = os.path.join(domainDir, sd.DOMAIN_IMAGES) cls.log.info("Creating domain images directory %r", imagesDir) oop.getProcessPool(sdUUID).fileUtils.createdir(imagesDir) # create special imageUUID for ISO/Floppy volumes if domClass is sd.ISO_DOMAIN: isoDir = os.path.join(imagesDir, sd.ISO_IMAGE_UUID) cls.log.info("Creating ISO domain images directory %r", isoDir) oop.getProcessPool(sdUUID).fileUtils.createdir(isoDir) fsd = cls(os.path.join(mntPoint, sdUUID)) fsd.initSPMlease() return fsd
def test_normalize_path_equals(path, normalized_path): assert normalized_path == fileUtils.normalize_path(path)