Support format info in fs type drivers

This feature adds format info in filesystem type
drivers with the following changes:
1) Store format info in admin_metadata while creating/cloning
volumes
2) Use format info while extending volumes
3) Modify volume format when performing snapshot delete
(blockRebase) operation on attached volume.
4) Return format in connection_info

blueprint add-support-store-volume-format-info

Change-Id: I43036837274a7c8dba612db53b34a6ce2cfb2f07
This commit is contained in:
Rajat Dhasmana
2020-11-03 08:45:22 -05:00
parent a6c71f5439
commit ace1748218
10 changed files with 227 additions and 38 deletions

View File

@@ -28,11 +28,13 @@ from oslo_log import log as logging
from oslo_utils import units
import six
from cinder import context
from cinder import coordination
from cinder import exception
from cinder.i18n import _
from cinder.image import image_utils
from cinder import interface
from cinder import objects
from cinder import utils
from cinder.volume import configuration
from cinder.volume.drivers import remotefs
@@ -383,9 +385,16 @@ class NfsDriver(remotefs.RemoteFSSnapDriverDistributed):
% (volume.id, new_size))
path = self.local_path(volume)
LOG.info('Resizing file to %sG...', new_size)
file_format = None
admin_metadata = objects.Volume.get_by_id(
context.get_admin_context(), volume.id).admin_metadata
if admin_metadata and 'format' in admin_metadata:
file_format = admin_metadata['format']
image_utils.resize_image(path, new_size,
run_as_root=self._execute_as_root)
if not self._is_file_size_equal(path, new_size):
run_as_root=self._execute_as_root,
file_format=file_format)
if file_format == 'qcow2' and not self._is_file_size_equal(
path, new_size):
raise exception.ExtendVolumeError(
reason='Resizing image file failed.')