예제 #1
0
    def extend_volume(self, volume, new_size):
        try:
            lun_uuid = self._get_lun_uuid(volume['name'])
            out = self.exec_webapi('SYNO.Core.ISCSI.LUN',
                                   'set',
                                   1,
                                   uuid=lun_uuid,
                                   new_size=new_size * units.Gi)

            self.check_response(out)

        except Exception as e:
            LOG.exception(_LE('Failed to extend_volume. [%s]'), volume['name'])
            raise exception.ExtendVolumeError(reason=e.msg)
예제 #2
0
    def _do_extend_volume(self, volume_path, size_gb, volume_format):

        if volume_format == DISK_FORMAT_PLOOP:
            self._execute('ploop',
                          'resize',
                          '-s',
                          '%dG' % size_gb,
                          os.path.join(volume_path, 'DiskDescriptor.xml'),
                          run_as_root=True)
        else:
            image_utils.resize_image(volume_path, size_gb)
            if not self._is_file_size_equal(volume_path, size_gb):
                raise exception.ExtendVolumeError(
                    reason='Resizing image file failed.')
예제 #3
0
    def _check_extend_volume_support(self, volume, size_gb):
        volume_path = self.local_path(volume)
        active_file = self.get_active_image_from_info(volume)
        active_file_path = os.path.join(self._local_volume_dir(volume),
                                        active_file)

        if active_file_path != volume_path:
            msg = _('Extend volume is only supported for this '
                    'driver when no snapshots exist.')
            raise exception.InvalidVolume(msg)

        extend_by = int(size_gb) - volume.size
        if not self._is_share_eligible(volume.provider_location, extend_by):
            raise exception.ExtendVolumeError(reason='Insufficient space to '
                                              'extend volume %s to %sG.' %
                                              (volume.id, size_gb))
예제 #4
0
    def _do_extend_volume(self, volume_path, size_gb, volume_name):
        info = self._qemu_img_info(volume_path, volume_name)
        fmt = info.file_format

        # Note(lpetrut): as for version 2.0, qemu-img cannot resize
        # vhd/x images. For the moment, we'll just use an intermediary
        # conversion in order to be able to do the resize.
        if fmt in (self._DISK_FORMAT_VHDX, self._DISK_FORMAT_VHD_LEGACY):
            temp_image = volume_path + '.tmp'
            image_utils.convert_image(volume_path, temp_image,
                                      self._DISK_FORMAT_RAW)
            image_utils.resize_image(temp_image, size_gb)
            image_utils.convert_image(temp_image, volume_path, fmt)
            self._delete(temp_image)
        else:
            image_utils.resize_image(volume_path, size_gb)

        if not self._is_file_size_equal(volume_path, size_gb):
            raise exception.ExtendVolumeError(
                reason='Resizing image file failed.')
예제 #5
0
파일: quobyte.py 프로젝트: openstack/cinder
    def extend_volume(self, volume, size_gb):
        if self._is_volume_attached(volume):
            # NOTE(kaisers): no attached extensions until #1870367 is fixed
            msg = (_("Cannot extend volume %s while it is attached.") %
                   volume['id'])
            raise exception.ExtendVolumeError(msg)

        volume_path = self.local_path(volume)

        info = self._qemu_img_info(volume_path, volume.name)
        backing_fmt = info.file_format

        if backing_fmt not in ['raw', 'qcow2']:
            msg = _('Unrecognized backing format: %s')
            raise exception.InvalidVolume(msg % backing_fmt)

        # qemu-img can resize both raw and qcow2 files
        active_path = os.path.join(
            self._get_mount_point_for_share(volume.provider_location),
            self.get_active_image_from_info(volume))
        image_utils.resize_image(active_path, size_gb)
예제 #6
0
 def _check_extend_volume_support(self, volume, size_gb):
     extend_by = int(size_gb) - volume.size
     if not self._is_share_eligible(volume.provider_location, extend_by):
         raise exception.ExtendVolumeError(reason='Insufficient space to '
                                           'extend volume %s to %sG.' %
                                           (volume.id, size_gb))
예제 #7
0
    def _do_extend_volume(self, volume_path, size_gb):
        image_utils.resize_image(volume_path, size_gb)

        if not self._is_file_size_equal(volume_path, size_gb):
            raise exception.ExtendVolumeError(
                reason='Resizing image file failed.')