Ejemplo n.º 1
0
 def connect_localfs(self, remote_path):
     """
     Connect a local directory to repository.
     """
     local_path = fileUtils.transformPath(remote_path)
     dom_link = os.path.join(self.mnt_dir, local_path)
     os.symlink(remote_path, dom_link)
Ejemplo n.º 2
0
def fake_file_env(obj=None,
                  sd_version=3,
                  data_center=None,
                  remote_path="server:/path"):
    with temp_dir(path=data_center) as tmpdir:
        mnt_dir = os.path.join(tmpdir, "mnt")
        local_path = fileUtils.transformPath(remote_path)
        mountpoint = os.path.join(mnt_dir, local_path)
        os.makedirs(mountpoint)

        fake_sdc = FakeStorageDomainCache()
        with MonkeyPatchScope([
            [sc, 'REPO_DATA_CENTER', tmpdir],
            [sc, 'REPO_MOUNT_DIR', mnt_dir],
            [volume, 'sdCache', fake_sdc],
            [fileVolume, 'sdCache', fake_sdc],
            [hsm, 'sdCache', fake_sdc],
            [nbd, 'sdCache', fake_sdc],
        ]):
            sd_manifest = make_filesd_manifest(mountpoint,
                                               sd_version=sd_version)
            fake_sdc.domains[sd_manifest.sdUUID] = FakeSD(sd_manifest)
            try:
                yield FakeFileEnv(tmpdir, sd_manifest, fake_sdc)
            finally:
                oop.stop()
Ejemplo n.º 3
0
 def disconnect_localfs(self, remote_path):
     """
     Disconnect a local directory from the repository.
     """
     local_path = fileUtils.transformPath(remote_path)
     dom_link = os.path.join(self.mnt_dir, local_path)
     os.remove(dom_link)
Ejemplo n.º 4
0
def test_convert_from_v3_to_v4_localfs(tmp_repo, fake_access):
    # In a real domain this is a symlink to the domain directory.
    remote_path = "/data/domain"
    dom_dir = os.path.join(
        sc.REPO_MOUNT_DIR, fileUtils.transformPath(remote_path))
    os.makedirs(dom_dir)

    dom = localFsSD.LocalFsStorageDomain.create(
        sdUUID=str(uuid.uuid4()),
        domainName="domain",
        domClass=sd.DATA_DOMAIN,
        remotePath=remote_path,
        version=3,
        storageType=sd.LOCALFS_DOMAIN,
        block_size=sc.BLOCK_SIZE_512,
        alignment=sc.ALIGN_1M)

    assert dom.getVersion() == 3

    fc = formatconverter.DefaultFormatConverter()

    fc.convert(
        repoPath=tmp_repo.path,
        hostId=1,
        imageRepo=dom,
        isMsd=False,
        targetFormat='4')

    # LocalFS do not support external leases, so the only change is the
    # version.
    assert dom.getVersion() == 4
Ejemplo n.º 5
0
 def connect_localfs(self, remote_path):
     """
     Connect a local directory to repository.
     """
     local_path = fileUtils.transformPath(remote_path)
     dom_link = os.path.join(self.mnt_dir, local_path)
     os.symlink(remote_path, dom_link)
Ejemplo n.º 6
0
def add_filesd(repo, remote_path, sd_uuid, subdir=""):
    # Create mount directory in the repo
    mnt_dir = os.path.join(sc.REPO_MOUNT_DIR, subdir)
    local_path = fileUtils.transformPath(remote_path)
    mountpoint = os.path.join(mnt_dir, local_path)
    os.makedirs(mountpoint)
    return create_domain_structure(sd_uuid, remote_path, mountpoint)
Ejemplo n.º 7
0
def add_filesd(repo, remote_path, sd_uuid, subdir=""):
    # Create mount directory in the repo
    mnt_dir = os.path.join(sc.REPO_MOUNT_DIR, subdir)
    local_path = fileUtils.transformPath(remote_path)
    mountpoint = os.path.join(mnt_dir, local_path)
    os.makedirs(mountpoint)
    return create_domain_structure(sd_uuid, remote_path, mountpoint)
Ejemplo n.º 8
0
def add_filesd(repo, remote_path, sd_uuid, subdir=""):
    # Create mount direcotry in the repo
    mnt_dir = os.path.join(repo, sd.DOMAIN_MNT_POINT, subdir)
    local_path = fileUtils.transformPath(remote_path)
    mountpoint = os.path.join(mnt_dir, local_path)
    os.makedirs(mountpoint)
    return create_domain_structure(sd_uuid, remote_path, mountpoint)
Ejemplo n.º 9
0
def add_localsd(repo, tmpdir, sd_uuid):
    # Link local directory into the repo
    mnt_dir = os.path.join(repo, sd.DOMAIN_MNT_POINT)
    local_path = fileUtils.transformPath(tmpdir)
    mountpoint = os.path.join(mnt_dir, local_path)
    os.symlink(tmpdir, mountpoint)
    return create_domain_structure(sd_uuid, tmpdir, mountpoint)
Ejemplo n.º 10
0
def add_filesd(repo, remote_path, sd_uuid, subdir=""):
    # Create mount direcotry in the repo
    mnt_dir = os.path.join(repo, sd.DOMAIN_MNT_POINT, subdir)
    local_path = fileUtils.transformPath(remote_path)
    mountpoint = os.path.join(mnt_dir, local_path)
    os.makedirs(mountpoint)
    return create_domain_structure(sd_uuid, remote_path, mountpoint)
Ejemplo n.º 11
0
def add_localsd(repo, tmpdir, sd_uuid):
    # Link local directory into the repo
    mnt_dir = os.path.join(repo, sd.DOMAIN_MNT_POINT)
    local_path = fileUtils.transformPath(tmpdir)
    mountpoint = os.path.join(mnt_dir, local_path)
    os.symlink(tmpdir, mountpoint)
    return create_domain_structure(sd_uuid, tmpdir, mountpoint)
Ejemplo n.º 12
0
 def disconnect_localfs(self, remote_path):
     """
     Disconnect a local directory from the repository.
     """
     local_path = fileUtils.transformPath(remote_path)
     dom_link = os.path.join(self.mnt_dir, local_path)
     os.remove(dom_link)
Ejemplo n.º 13
0
Archivo: nfsSD.py Proyecto: oVirt/vdsm
    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
Ejemplo n.º 14
0
    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): /data
            storageType (int): LOCALFS_DOMAIN
            version (int): DOMAIN_VERSIONS
            block_size (int): Underlying storage block size.
                Supported value is BLOCK_SIZE_512
            alignment (int): Sanlock alignment 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)

        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)

        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
Ejemplo n.º 15
0
    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): /data
            storageType (int): LOCALFS_DOMAIN
            version (int): DOMAIN_VERSIONS
            block_size (int): Underlying storage block size.
                Supported value is BLOCK_SIZE_512
            alignment (int): Sanlock alignment 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)

        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)

        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
Ejemplo n.º 16
0
    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
Ejemplo n.º 17
0
    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' - /data2
            'storageType' - NFS_DOMAIN, LOCALFS_DOMAIN, &etc.
            'version' - DOMAIN_VERSIONS
        """
        cls.log.info("sdUUID=%s domainName=%s remotePath=%s "
                     "domClass=%s", sdUUID, domainName, remotePath, domClass)

        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)

        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)
        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
Ejemplo n.º 18
0
    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' - /data2
            'storageType' - NFS_DOMAIN, LOCALFS_DOMAIN, &etc.
            'version' - DOMAIN_VERSIONS
        """
        cls.log.info("sdUUID=%s domainName=%s remotePath=%s "
                     "domClass=%s", sdUUID, domainName, remotePath, domClass)

        if not misc.isAscii(domainName) and not sd.supportsUnicode(version):
            raise se.UnicodeArgumentException()

        # Create local path
        mntPath = fileUtils.transformPath(remotePath)

        mntPoint = os.path.join(cls.storage_repository,
                                sd.DOMAIN_MNT_POINT, mntPath)

        cls._preCreateValidation(sdUUID, mntPoint, remotePath, 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)
        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)
            fileUtils.createdir(isoDir)

        fsd = LocalFsStorageDomain(os.path.join(mntPoint, sdUUID))
        fsd.initSPMlease()

        return fsd
Ejemplo n.º 19
0
Archivo: nfsSD.py Proyecto: EdDev/vdsm
    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
Ejemplo n.º 20
0
def test_create_domain_metadata(tmp_repo, fake_access, domain_version):
    # In a real domain this is a symlink to the domain directory.
    remote_path = "/data/domain"
    dom_dir = os.path.join(sc.REPO_MOUNT_DIR,
                           fileUtils.transformPath(remote_path))
    os.makedirs(dom_dir)

    sd_uuid = str(uuid.uuid4())
    domain_name = "domain"

    dom = localFsSD.LocalFsStorageDomain.create(sdUUID=sd_uuid,
                                                domainName=domain_name,
                                                domClass=sd.DATA_DOMAIN,
                                                remotePath=remote_path,
                                                version=domain_version,
                                                storageType=sd.LOCALFS_DOMAIN,
                                                block_size=sc.BLOCK_SIZE_512,
                                                alignment=sc.ALIGN_1M)

    lease = sd.DEFAULT_LEASE_PARAMS
    assert dom.getMetadata() == {
        sd.DMDK_CLASS: sd.DATA_DOMAIN,
        sd.DMDK_DESCRIPTION: domain_name,
        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: [],
        sd.DMDK_ROLE: sd.REGULAR_DOMAIN,
        sd.DMDK_SDUUID: sd_uuid,
        sd.DMDK_TYPE: sd.LOCALFS_DOMAIN,
        sd.DMDK_VERSION: domain_version,
        fileSD.REMOTE_PATH: remote_path
    }
Ejemplo n.º 21
0
def fake_file_env(obj=None, sd_version=3, data_center=None,
                  remote_path="server:/path"):
    with temp_dir(path=data_center) as tmpdir:
        mnt_dir = os.path.join(tmpdir, "mnt")
        local_path = fileUtils.transformPath(remote_path)
        mountpoint = os.path.join(mnt_dir, local_path)
        os.makedirs(mountpoint)

        fake_sdc = FakeStorageDomainCache()
        with MonkeyPatchScope([
            [sc, 'REPO_DATA_CENTER', tmpdir],
            [sc, 'REPO_MOUNT_DIR', mnt_dir],
            [volume, 'sdCache', fake_sdc],
            [fileVolume, 'sdCache', fake_sdc],
            [hsm, 'sdCache', fake_sdc],
            [nbd, 'sdCache', fake_sdc],
        ]):
            sd_manifest = make_filesd_manifest(
                mountpoint, sd_version=sd_version)
            fake_sdc.domains[sd_manifest.sdUUID] = FakeSD(sd_manifest)
            try:
                yield FakeFileEnv(tmpdir, sd_manifest, fake_sdc)
            finally:
                oop.stop()
Ejemplo n.º 22
0
 def _getLocalPath(self):
     return os.path.join(self.localPathBase,
                         fileUtils.transformPath(self._path))
Ejemplo n.º 23
0
 def _getLocalPath(self):
     path = fileUtils.transformPath(self._remotePath)
     return os.path.join(self.localPathBase, self.DIR, path)
Ejemplo n.º 24
0
    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
Ejemplo n.º 25
0
def add_localsd(repo, tmpdir, sd_uuid):
    # Link local directory into the repo
    local_path = fileUtils.transformPath(tmpdir)
    mountpoint = os.path.join(sc.REPO_MOUNT_DIR, local_path)
    os.symlink(tmpdir, mountpoint)
    return create_domain_structure(sd_uuid, tmpdir, mountpoint)
Ejemplo n.º 26
0
def add_localsd(repo, tmpdir, sd_uuid):
    # Link local directory into the repo
    local_path = fileUtils.transformPath(tmpdir)
    mountpoint = os.path.join(sc.REPO_MOUNT_DIR, local_path)
    os.symlink(tmpdir, mountpoint)
    return create_domain_structure(sd_uuid, tmpdir, mountpoint)
Ejemplo n.º 27
0
    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
Ejemplo n.º 28
0
 def _getLocalPath(self):
     path = fileUtils.transformPath(self._remotePath)
     return os.path.join(self.localPathBase, self.DIR, path)
Ejemplo n.º 29
0
 def _getLocalPath(self):
     return os.path.join(self.localPathBase,
                         fileUtils.transformPath(self._path))
Ejemplo n.º 30
0
    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)
        cls.validate_version(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