def test_create_domain_metadata_v5( user_mount_v5, tmp_repo, fake_access, detect_block_size): if detect_block_size: block_size = sc.BLOCK_SIZE_AUTO else: block_size = user_mount_v5.block_size dom = tmp_repo.create_localfs_domain( name="domain", version=5, block_size=block_size, max_hosts=user_mount_v5.max_hosts, remote_path=user_mount_v5.path) alignment = clusterlock.alignment( user_mount_v5.block_size, user_mount_v5.max_hosts) lease = sd.DEFAULT_LEASE_PARAMS expected = { fileSD.REMOTE_PATH: user_mount_v5.path, sd.DMDK_ALIGNMENT: alignment, sd.DMDK_BLOCK_SIZE: user_mount_v5.block_size, sd.DMDK_CLASS: sd.DATA_DOMAIN, sd.DMDK_DESCRIPTION: "domain", sd.DMDK_IO_OP_TIMEOUT_SEC: lease[sd.DMDK_IO_OP_TIMEOUT_SEC], sd.DMDK_LEASE_RETRIES: lease[sd.DMDK_LEASE_RETRIES], sd.DMDK_LEASE_TIME_SEC: lease[sd.DMDK_LEASE_TIME_SEC], sd.DMDK_LOCK_POLICY: "", sd.DMDK_LOCK_RENEWAL_INTERVAL_SEC: lease[sd.DMDK_LOCK_RENEWAL_INTERVAL_SEC], sd.DMDK_POOLS: [tmp_repo.pool_id], sd.DMDK_ROLE: sd.REGULAR_DOMAIN, sd.DMDK_SDUUID: dom.sdUUID, sd.DMDK_TYPE: sd.LOCALFS_DOMAIN, sd.DMDK_VERSION: 5, } actual = dom.getMetadata() assert expected == actual # Tests also alignment and block size properties here. assert dom.alignment == alignment assert dom.block_size == user_mount_v5.block_size
def test_domain_lease_v5(user_mount_v5, tmp_repo, fake_access, detect_block_size): if detect_block_size: block_size = sc.BLOCK_SIZE_AUTO else: block_size = user_mount_v5.block_size dom = tmp_repo.create_localfs_domain(name="domain", version=5, block_size=block_size, max_hosts=user_mount_v5.max_hosts, remote_path=user_mount_v5.path) alignment = clusterlock.alignment(user_mount_v5.block_size, user_mount_v5.max_hosts) lease = dom.getClusterLease() assert lease.name == "SDM" assert lease.path == dom.getLeasesFilePath() assert lease.offset == alignment
def test_sanlock_invalid_max_hosts(block_size, max_hosts): with pytest.raises(se.InvalidParameterException) as e: clusterlock.alignment(block_size, max_hosts) error_str = str(e) assert "max_hosts" in error_str assert str(max_hosts) in error_str
def test_sanlock_alignment(block_size, max_hosts, alignment): assert clusterlock.alignment(block_size, max_hosts) == alignment
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_sanlock_invalid_alignment(block_size, max_hosts): with pytest.raises(se.InvalidParameterException): clusterlock.alignment(block_size, max_hosts)
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): /data storageType (int): LOCALFS_DOMAIN 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) if not misc.isAscii(domainName) and not sd.supportsUnicode(version): raise se.UnicodeArgumentException() # Create local path mntPath = fileUtils.transformPath(remotePath) mntPoint = os.path.join(sc.REPO_MOUNT_DIR, mntPath) cls._preCreateValidation(sdUUID, mntPoint, remotePath, 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) fileUtils.createdir(imagesDir) # create special imageUUID for ISO/Floppy volumes # Actually the local domain shouldn't be ISO, but # we can allow it for systems without NFS at all 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) fileUtils.createdir(isoDir) fsd = LocalFsStorageDomain(os.path.join(mntPoint, sdUUID)) fsd.initSPMlease() return fsd