当前位置: 首页>>代码示例>>Python>>正文


Python outOfProcess.getProcessPool函数代码示例

本文整理汇总了Python中vdsm.storage.outOfProcess.getProcessPool函数的典型用法代码示例。如果您正苦于以下问题:Python getProcessPool函数的具体用法?Python getProcessPool怎么用?Python getProcessPool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getProcessPool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createVolumeMetadataRollback

 def createVolumeMetadataRollback(cls, taskObj, volPath):
     cls.log.info("createVolumeMetadataRollback: volPath=%s" % (volPath))
     metaPath = cls.manifestClass.metaVolumePath(volPath)
     sdUUID = getDomUuidFromVolumePath(volPath)
     if oop.getProcessPool(sdUUID).os.path.lexists(metaPath):
         cls.log.info("Unlinking metadata volume %r", metaPath)
         oop.getProcessPool(sdUUID).os.unlink(metaPath)
开发者ID:nirs,项目名称:vdsm,代码行数:7,代码来源:fileVolume.py

示例2: create

    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
开发者ID:oVirt,项目名称:vdsm,代码行数:59,代码来源:nfsSD.py

示例3: file_setrw

 def file_setrw(cls, volPath, rw):
     sdUUID = getDomUuidFromVolumePath(volPath)
     mode = 0o440
     if rw:
         mode |= 0o220
     if oop.getProcessPool(sdUUID).os.path.isdir(volPath):
         mode |= 0o110
     oop.getProcessPool(sdUUID).os.chmod(volPath, mode)
开发者ID:EdDev,项目名称:vdsm,代码行数:8,代码来源:fileVolume.py

示例4: _create

    def _create(cls, dom, imgUUID, volUUID, size, volFormat, preallocate,
                volParent, srcImgUUID, srcVolUUID, volPath,
                initialSize=None):
        """
        Class specific implementation of volumeCreate. All the exceptions are
        properly handled and logged in volume.create()
        """
        if initialSize:
            cls.log.error("initialSize is not supported for file-based "
                          "volumes")
            raise se.InvalidParameterException("initial size",
                                               initialSize)

        sizeBytes = size * BLOCK_SIZE
        truncSize = sizeBytes if volFormat == sc.RAW_FORMAT else 0

        try:
            oop.getProcessPool(dom.sdUUID).truncateFile(
                volPath, truncSize, mode=sc.FILE_VOLUME_PERMISSIONS,
                creatExcl=True)
        except OSError as e:
            if e.errno == errno.EEXIST:
                raise se.VolumeAlreadyExists(volUUID)
            raise

        if preallocate == sc.PREALLOCATED_VOL:
            try:
                operation = fallocate.allocate(volPath,
                                               sizeBytes)
                with vars.task.abort_callback(operation.abort):
                    with utils.stopwatch("Preallocating volume %s" % volPath):
                        operation.run()
            except exception.ActionStopped:
                raise
            except Exception:
                cls.log.error("Unexpected error", exc_info=True)
                raise se.VolumesZeroingError(volPath)

        if not volParent:
            cls.log.info("Request to create %s volume %s with size = %s "
                         "sectors", sc.type2name(volFormat), volPath,
                         size)
            if volFormat == sc.COW_FORMAT:
                qemuimg.create(volPath,
                               size=sizeBytes,
                               format=sc.fmt2str(volFormat),
                               qcow2Compat=dom.qcow2_compat())
        else:
            # Create hardlink to template and its meta file
            cls.log.info("Request to create snapshot %s/%s of volume %s/%s",
                         imgUUID, volUUID, srcImgUUID, srcVolUUID)
            volParent.clone(volPath, volFormat)

        # Forcing the volume permissions in case one of the tools we use
        # (dd, qemu-img, etc.) will mistakenly change the file permissiosn.
        dom.oop.os.chmod(volPath, sc.FILE_VOLUME_PERMISSIONS)

        return (volPath,)
开发者ID:EdDev,项目名称:vdsm,代码行数:58,代码来源:fileVolume.py

示例5: renameVolumeRollback

 def renameVolumeRollback(cls, taskObj, oldPath, newPath):
     try:
         cls.log.info("oldPath=%s newPath=%s", oldPath, newPath)
         sdUUID = getDomUuidFromVolumePath(oldPath)
         oop.getProcessPool(sdUUID).os.rename(oldPath, newPath)
     except Exception:
         cls.log.error("Could not rollback "
                       "volume rename (oldPath=%s newPath=%s)",
                       oldPath, newPath, exc_info=True)
开发者ID:EdDev,项目名称:vdsm,代码行数:9,代码来源:fileVolume.py

示例6: _truncate_volume

 def _truncate_volume(cls, vol_path, size, vol_id, dom):
     try:
         oop.getProcessPool(dom.sdUUID).truncateFile(
             vol_path, size, mode=sc.FILE_VOLUME_PERMISSIONS,
             creatExcl=True)
     except OSError as e:
         if e.errno == errno.EEXIST:
             raise se.VolumeAlreadyExists(vol_id)
         raise
开发者ID:oVirt,项目名称:vdsm,代码行数:9,代码来源:fileVolume.py

示例7: newVolumeLease

 def newVolumeLease(cls, metaId, sdUUID, volUUID):
     cls.log.debug("Initializing volume lease volUUID=%s sdUUID=%s, "
                   "metaId=%s", volUUID, sdUUID, metaId)
     volPath, = metaId
     leasePath = cls.leaseVolumePath(volPath)
     oop.getProcessPool(sdUUID).truncateFile(leasePath, LEASE_FILEOFFSET)
     cls.file_setrw(leasePath, rw=True)
     sanlock.init_resource(sdUUID, volUUID, [(leasePath,
                                              LEASE_FILEOFFSET)])
开发者ID:EdDev,项目名称:vdsm,代码行数:9,代码来源:fileVolume.py

示例8: _putMetadata

    def _putMetadata(cls, metaId, meta):
        volPath, = metaId
        metaPath = cls.metaVolumePath(volPath)

        data = cls.formatMetadata(meta)

        with open(metaPath + ".new", "w") as f:
            f.write(data)

        sdUUID = getDomUuidFromVolumePath(volPath)
        oop.getProcessPool(sdUUID).os.rename(metaPath + ".new", metaPath)
开发者ID:EdDev,项目名称:vdsm,代码行数:11,代码来源:fileVolume.py

示例9: _putMetadata

    def _putMetadata(cls, metaId, meta, **overrides):
        volPath, = metaId
        metaPath = cls.metaVolumePath(volPath)

        sd = sdCache.produce_manifest(meta.domain)

        data = meta.storage_format(sd.getVersion(), **overrides)

        with open(metaPath + ".new", "w") as f:
            f.write(data)

        oop.getProcessPool(meta.domain).os.rename(metaPath + ".new", metaPath)
开发者ID:nirs,项目名称:vdsm,代码行数:12,代码来源:fileVolume.py

示例10: halfbakedVolumeRollback

    def halfbakedVolumeRollback(cls, taskObj, *args):
        if len(args) == 1:  # Backward compatibility
            volPath, = args
            sdUUID = getDomUuidFromVolumePath(volPath)
        elif len(args) == 3:
            (sdUUID, volUUID, volPath) = args
        else:
            raise TypeError("halfbakedVolumeRollback takes 1 or 3 "
                            "arguments (%d given)" % len(args))

        metaVolPath = cls.manifestClass.metaVolumePath(volPath)
        cls.log.info("Halfbaked volume rollback for volPath=%s", volPath)

        if oop.getProcessPool(sdUUID).fileUtils.pathExists(volPath) and not \
                oop.getProcessPool(sdUUID).fileUtils.pathExists(metaVolPath):
            oop.getProcessPool(sdUUID).os.unlink(volPath)
开发者ID:EdDev,项目名称:vdsm,代码行数:16,代码来源:fileVolume.py

示例11: _prepareMetadata

    def _prepareMetadata(cls, domPath, sdUUID, domainName, domClass,
                         remotePath, storageType, version, alignment,
                         block_size):
        """
        Prepare all domain's special volumes and metadata
        """
        # create domain metadata folder
        metadataDir = os.path.join(domPath, sd.DOMAIN_META_DATA)

        procPool = oop.getProcessPool(sdUUID)
        cls.log.info("Creating domain metadata directory %r", metadataDir)
        procPool.fileUtils.createdir(metadataDir, 0o775)

        special_volumes = cls.manifestClass.special_volumes(version)
        for name, size_mb in FILE_SPECIAL_VOLUME_SIZES_MIB.iteritems():
            if name in special_volumes:
                try:
                    procPool.truncateFile(
                        os.path.join(metadataDir, name),
                        size_mb * constants.MEGAB, METADATA_PERMISSIONS)
                except Exception as e:
                    raise se.StorageDomainMetadataCreationError(
                        "create meta file '%s' failed: %s" % (name, str(e)))

        if cls.supports_external_leases(version):
            xleases_path = os.path.join(metadataDir, sd.XLEASES)
            cls.format_external_leases(sdUUID, xleases_path)

        metaFile = os.path.join(metadataDir, sd.METADATA)

        md = FileSDMetadata(metaFile)
        # initialize domain metadata content
        # FIXME : This is 99% like the metadata in block SD
        #         Do we really need to keep the EXPORT_PATH?
        #         no one uses it
        metadata = {
            sd.DMDK_VERSION: version,
            sd.DMDK_SDUUID: sdUUID,
            sd.DMDK_TYPE: storageType,
            sd.DMDK_CLASS: domClass,
            sd.DMDK_DESCRIPTION: domainName,
            sd.DMDK_ROLE: sd.REGULAR_DOMAIN,
            sd.DMDK_POOLS: [],
            sd.DMDK_LOCK_POLICY: '',
            sd.DMDK_LOCK_RENEWAL_INTERVAL_SEC:
            sd.DEFAULT_LEASE_PARAMS[sd.DMDK_LOCK_RENEWAL_INTERVAL_SEC],
            sd.DMDK_LEASE_TIME_SEC: sd.DEFAULT_LEASE_PARAMS[
                sd.DMDK_LEASE_TIME_SEC],
            sd.DMDK_IO_OP_TIMEOUT_SEC:
            sd.DEFAULT_LEASE_PARAMS[sd.DMDK_IO_OP_TIMEOUT_SEC],
            sd.DMDK_LEASE_RETRIES:
            sd.DEFAULT_LEASE_PARAMS[sd.DMDK_LEASE_RETRIES],
            REMOTE_PATH: remotePath
        }

        if version > 4:
            metadata[sd.DMDK_ALIGNMENT] = alignment
            metadata[sd.DMDK_BLOCK_SIZE] = block_size

        md.update(metadata)
开发者ID:oVirt,项目名称:vdsm,代码行数:60,代码来源:fileSD.py

示例12: collectMetaFiles

    def collectMetaFiles(mountPoint):
        try:
            # removes the path to the data center's mount directory from
            # the mount point.
            if mountPoint.startswith(sc.REPO_MOUNT_DIR):
                client_name = mountPoint[len(sc.REPO_MOUNT_DIR):]

            # Since glob treats values between brackets as character ranges,
            # and since IPV6 addresses contain brackets, we should escape the
            # mountPoint that we pass to glob.
            # <data-center>/mnt/mountpoint/<uuid>/dom_mdm
            mdPattern = os.path.join(
                glob_escape(mountPoint),
                UUID_GLOB_PATTERN,
                sd.DOMAIN_META_DATA)

            metaFiles = oop.getProcessPool(client_name).glob.glob(mdPattern)

            for metaFile in metaFiles:
                if (os.path.basename(os.path.dirname(metaFile)) !=
                        sd.MASTER_FS_DIR):
                    sdUUID = os.path.basename(os.path.dirname(metaFile))

                    return (sdUUID, os.path.dirname(metaFile))

        except Exception:
            log.warn("Could not collect metadata file for domain path %s",
                     mountPoint, exc_info=True)
开发者ID:oVirt,项目名称:vdsm,代码行数:28,代码来源:fileSD.py

示例13: validateFileSystemFeatures

def validateFileSystemFeatures(sdUUID, mountDir):
    try:
        # Don't unlink this file, we don't have the cluster lock yet as it
        # requires direct IO which is what we are trying to test for. This
        # means that unlinking the file might cause a race. Since we don't
        # care what the content of the file is, just that we managed to
        # open it O_DIRECT.
        testFilePath = os.path.join(mountDir, "__DIRECT_IO_TEST__")
        oop.getProcessPool(sdUUID).directTouch(testFilePath)
    except OSError as e:
        if e.errno == errno.EINVAL:
            log = logging.getLogger("storage.fileSD")
            log.error("Underlying file system doesn't support"
                      "direct IO")
            raise se.StorageDomainTargetUnsupported()

        raise
开发者ID:oVirt,项目名称:vdsm,代码行数:17,代码来源:fileSD.py

示例14: format

    def format(cls, sdUUID):
        """
        Format detached storage domain.
        This removes all data from the storage domain.
        """
        cls.log.info("Formatting domain %s", sdUUID)
        try:
            domaindir = cls.findDomainPath(sdUUID)
        except (se.StorageDomainDoesNotExist):
            pass
        else:
            try:
                oop.getProcessPool(sdUUID).fileUtils.cleanupdir(
                    domaindir, ignoreErrors=False)
            except RuntimeError as e:
                raise se.MiscDirCleanupFailure(str(e))

        return True
开发者ID:oVirt,项目名称:vdsm,代码行数:18,代码来源:fileSD.py

示例15: create

    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
开发者ID:EdDev,项目名称:vdsm,代码行数:44,代码来源:nfsSD.py


注:本文中的vdsm.storage.outOfProcess.getProcessPool函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。