Not able to upload volume to image

upload_to_image() function should be updated when
client version is bigger than 3.1.

Without this we are not able to run this function:

   image = cinder_client.volumes.upload_to_image(
       volume=temporary_volume,
       force=True,
       image_name='temporary_image_of_{0}'.format(temporary_volume.id),
       container_format="bare",
       disk_format="raw"
   )

Change-Id: I825ad0d6f6c25e2d85c756e6148e73e7e298ef75
Closes-Bug: #1787399
Co-Authored-By: Jiao Pengju <jiaopengju@cmss.chinamobile.com>
This commit is contained in:
Gaëtan Trellu 2018-08-16 13:03:02 -04:00 committed by jiaopengju
parent ed23bc9551
commit 089f9886b0
2 changed files with 12 additions and 1 deletions

View File

@ -170,7 +170,9 @@ class ProtectOperation(protection_plugin.Operation):
force=True,
image_name='temporary_image_of_{0}'.format(temporary_volume.id),
container_format="bare",
disk_format="raw"
disk_format="raw",
visibility="private",
protected=False
)
image_id = image[1]['os-volume_upload_image']['image_id']
is_success = utils.status_poll(

View File

@ -211,6 +211,15 @@ class VolumeGlanceProtectionPluginTest(base.TestCase):
call_hooks(protect_operation, self.checkpoint, resource, self.cntxt,
{})
self.cinder_client.volumes.upload_to_image.assert_called_with(
volume=Volume(id='2345', status='available', size=1),
force=True,
image_name='temporary_image_of_2345',
container_format="bare",
disk_format="raw",
visibility="private",
protected=False
)
def test_delete_backup(self):
resource = Resource(id="123",