示例#1
0
    def validateCreateVolumeParams(self, volFormat, srcVolUUID, diskType=None,
                                   preallocate=None, add_bitmaps=False):
        """
        Validate create volume parameters
        """
        if volFormat not in sc.VOL_FORMAT:
            raise se.IncorrectFormat(volFormat)

        # Volumes with a parent must be cow
        if srcVolUUID != sc.BLANK_UUID and volFormat != sc.COW_FORMAT:
            raise se.IncorrectFormat(sc.type2name(volFormat))

        if diskType is not None and diskType not in sc.VOL_DISKTYPE:
            raise se.InvalidParameterException("DiskType", diskType)

        if preallocate is not None and preallocate not in sc.VOL_TYPE:
            raise se.IncorrectType(preallocate)

        if add_bitmaps:
            if srcVolUUID == sc.BLANK_UUID:
                raise se.UnsupportedOperation(
                    "Cannot add bitmaps for volume without parent volume",
                    srcVolUUID=srcVolUUID,
                    add_bitmaps=add_bitmaps)

            if not self.supports_bitmaps_operations():
                raise se.UnsupportedOperation(
                    "Cannot perform bitmaps operations on "
                    "storage domain version < 4",
                    domain_version=self.getVersion(),
                    add_bitmaps=add_bitmaps)
示例#2
0
    def validateCreateVolumeParams(self, volFormat, srcVolUUID,
                                   preallocate=None):
        """
        Validate create volume parameters
        """
        if volFormat not in sc.VOL_FORMAT:
            raise se.IncorrectFormat(volFormat)

        # Volumes with a parent must be cow
        if srcVolUUID != sc.BLANK_UUID and volFormat != sc.COW_FORMAT:
            raise se.IncorrectFormat(sc.type2name(volFormat))

        if preallocate is not None and preallocate not in sc.VOL_TYPE:
            raise se.IncorrectType(preallocate)
示例#3
0
    def validateCreateVolumeParams(cls, volFormat, srcVolUUID, diskType=None,
                                   preallocate=None):
        """
        Validate create volume parameters
        """
        if volFormat not in sc.VOL_FORMAT:
            raise se.IncorrectFormat(volFormat)

        # Volumes with a parent must be cow
        if srcVolUUID != sc.BLANK_UUID and volFormat != sc.COW_FORMAT:
            raise se.IncorrectFormat(sc.type2name(volFormat))

        if diskType is not None and diskType not in sc.VOL_DISKTYPE:
            raise se.InvalidParameterException("DiskType", diskType)

        if preallocate is not None and preallocate not in sc.VOL_TYPE:
            raise se.IncorrectType(preallocate)
示例#4
0
    def validateCreateVolumeParams(cls, volFormat, srcVolUUID, diskType=None,
                                   preallocate=None, add_bitmaps=False):
        """
        Validate create volume parameters
        """
        if volFormat not in sc.VOL_FORMAT:
            raise se.IncorrectFormat(volFormat)

        # Volumes with a parent must be cow
        if srcVolUUID != sc.BLANK_UUID and volFormat != sc.COW_FORMAT:
            raise se.IncorrectFormat(sc.type2name(volFormat))

        if diskType is not None and diskType not in sc.VOL_DISKTYPE:
            raise se.InvalidParameterException("DiskType", diskType)

        if preallocate is not None and preallocate not in sc.VOL_TYPE:
            raise se.IncorrectType(preallocate)

        if add_bitmaps and srcVolUUID == sc.BLANK_UUID:
            raise se.UnsupportedOperation(
                "Cannot add bitmaps for volume without parent volume",
                srcVolUUID=srcVolUUID,
                add_bitmaps=add_bitmaps)
示例#5
0
文件: volume.py 项目: bronhaim/vdsm
    def extendSize(self, newSize):
        """
        Extend the size (virtual disk size seen by the guest) of the volume.
        """
        if self.isShared():
            raise se.VolumeNonWritable(self.volUUID)

        volFormat = self.getFormat()
        if volFormat == sc.COW_FORMAT:
            self.log.debug(
                "skipping cow size extension for volume %s to "
                "size %s", self.volUUID, newSize)
            return
        elif volFormat != sc.RAW_FORMAT:
            raise se.IncorrectFormat(self.volUUID)

        # Note: This function previously prohibited extending non-leaf volumes.
        # If a disk is enlarged a volume may become larger than its parent.  In
        # order to support live merge of a larger volume into its raw parent we
        # must permit extension of this raw volume prior to starting the merge.
        isBase = self.getParent() == sc.BLANK_UUID
        if not (isBase or self.isLeaf()):
            raise se.VolumeNonWritable(self.volUUID)

        curRawSize = self.getVolumeSize()

        if (newSize < curRawSize):
            self.log.error(
                "current size of volume %s is larger than the "
                "size requested in the extension (%s > %s)", self.volUUID,
                curRawSize, newSize)
            raise se.VolumeResizeValueError(newSize)

        if (newSize == curRawSize):
            self.log.debug(
                "the requested size %s is equal to the current "
                "size %s, skipping extension", newSize, curRawSize)
        else:
            self.log.info(
                "executing a raw size extension for volume %s "
                "from size %s to size %s", self.volUUID, curRawSize, newSize)
            vars.task.pushRecovery(
                task.Recovery("Extend size for volume: " + self.volUUID,
                              "volume", "Volume", "extendSizeFinalize",
                              [self.sdUUID, self.imgUUID, self.volUUID]))
            self._extendSizeRaw(newSize)

        self.syncMetadata()  # update the metadata
示例#6
0
    def calculate_vol_alloc(self, src_sd_id, src_vol_params,
                            dst_sd_id, dst_vol_format):
        """
        Calculate destination volume allocation size for copying source volume.

        Arguments:
            src_sd_id (str): Source volume storage domain id
            src_vol_params (dict): Dictionary returned from
                                   `storage.volume.Volume.getVolumeParams()`
            dst_sd_id (str): Destination volume storage domain id
            dst_vol_format (int): One of sc.RAW_FORMAT, sc.COW_FORMAT

        Returns:
            Volume allocation in bytes
        """
        if dst_vol_format == sc.RAW_FORMAT:
            # destination 'raw'.
            # The actual volume size must be the src virtual size.
            return src_vol_params['capacity']
        else:
            # destination 'cow'.
            # The actual volume size can be more than virtual size
            # due to qcow2 metadata.
            if src_vol_params['volFormat'] == sc.COW_FORMAT:
                # source 'cow'
                if src_vol_params['parent'] != sc.BLANK_UUID:
                    # source 'cow' with parent
                    # Using estimated size of the chain.
                    if src_vol_params['prealloc'] != sc.SPARSE_VOL:
                        raise se.IncorrectFormat(self)
                    return self.estimateChainSize(
                        src_sd_id,
                        src_vol_params['imgUUID'],
                        src_vol_params['volUUID'],
                        src_vol_params['capacity'])
                else:
                    # source 'cow' without parent.
                    # Use estimate for supporting compressed source images, for
                    # example, uploaded compressed qcow2 appliance.
                    return self.estimate_qcow2_size(src_vol_params, dst_sd_id)
            else:
                # source 'raw'.
                # Add additional space for qcow2 metadata.
                return self.estimate_qcow2_size(src_vol_params, dst_sd_id)