Ejemplo n.º 1
0
    def validateCreateVolumeParams(cls, volFormat, preallocate, srcVolUUID):
        """
        Validate create volume parameters
        """
        if volFormat not in VOL_FORMAT:
            raise se.IncorrectFormat(type2name(volFormat))

        if preallocate not in VOL_TYPE:
            raise se.IncorrectFormat(type2name(preallocate))
Ejemplo n.º 2
0
    def validateCreateVolumeParams(cls, volFormat, preallocate, srcVolUUID):
        """
        Validate create volume parameters
        """
        if volFormat not in VOL_FORMAT:
            raise se.IncorrectFormat(type2name(volFormat))

        if preallocate not in VOL_TYPE:
            raise se.IncorrectType(type2name(preallocate))

        # Volumes with a parent must be cow
        if srcVolUUID != BLANK_UUID and volFormat != COW_FORMAT:
            raise se.IncorrectFormat(type2name(volFormat))
Ejemplo n.º 3
0
    def validateCreateVolumeParams(self, volFormat, srcVolUUID,
                                   preallocate=None):
        """
        Validate create volume parameters
        """
        if volFormat not in volume.VOL_FORMAT:
            raise se.IncorrectFormat(volFormat)

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

        if preallocate is not None and preallocate not in volume.VOL_TYPE:
            raise se.IncorrectType(preallocate)
Ejemplo n.º 4
0
 def validateCreateVolumeParams(self, volFormat, srcVolUUID,
                                preallocate=None):
     super(BlockStorageDomain, self).validateCreateVolumeParams(
         volFormat, srcVolUUID, preallocate=preallocate)
     # Sparse-Raw not supported for block volumes
     if preallocate == volume.SPARSE_VOL and volFormat == volume.RAW_FORMAT:
         raise se.IncorrectFormat(volume.type2name(volFormat))
Ejemplo n.º 5
0
    def validateCreateVolumeParams(cls, volFormat, preallocate, srcVolUUID):
        """
        Validate create volume parameters.
        'srcVolUUID' - backing volume UUID
        'volFormat' - volume format RAW/QCOW2
        'preallocate' - sparse/preallocate
        """
        volume.Volume.validateCreateVolumeParams(volFormat, preallocate,
                                                 srcVolUUID)

        # Sparse-Raw not supported for block volumes
        if preallocate == volume.SPARSE_VOL and volFormat == volume.RAW_FORMAT:
            raise se.IncorrectFormat(srcVolUUID)

        # Snapshot should be COW volume
        if srcVolUUID != volume.BLANK_UUID and volFormat != volume.COW_FORMAT:
            raise se.IncorrectFormat(srcVolUUID)
Ejemplo n.º 6
0
    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 == COW_FORMAT:
            self.log.debug(
                "skipping cow size extension for volume %s to "
                "size %s", self.volUUID, newSize)
            return
        elif volFormat != 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() == 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
Ejemplo n.º 7
0
    def extendSize(self, newSize):
        """
        Extend the size (virtual disk size seen by the guest) of the volume.
        """
        if not self.isLeaf() or self.isShared():
            raise se.VolumeNonWritable(self.volUUID)

        volFormat = self.getFormat()

        if volFormat == COW_FORMAT:
            self.log.debug(
                "skipping cow size extension for volume %s to "
                "size %s", self.volUUID, newSize)
            return
        elif volFormat != RAW_FORMAT:
            raise se.IncorrectFormat(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