summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaëtan Trellu <gaetan.trellu@incloudus.com>2018-08-16 13:03:02 -0400
committerjiaopengju <jiaopengju@cmss.chinamobile.com>2018-10-14 17:36:04 +0800
commit089f9886b0c08156f5afe37e37bc3744a21d062d (patch)
treed9a4301c31a443e1337e385ecc54c9d16e205945
parented23bc95512bb7fe2a49d72de1f43517fe89ffb4 (diff)
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>
Notes
Notes (review): Code-Review+2: Jiao Pengju <jiaopengju@cmss.chinamobile.com> Code-Review+1: Gaëtan Trellu <gaetan.trellu@incloudus.com> Workflow+1: Jiao Pengju <jiaopengju@cmss.chinamobile.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 16 Oct 2018 01:41:57 +0000 Reviewed-on: https://review.openstack.org/592585 Project: openstack/karbor Branch: refs/heads/master
-rw-r--r--karbor/services/protection/protection_plugins/volume/volume_glance_plugin.py4
-rw-r--r--karbor/tests/unit/protection/test_cinder_glance_plugin.py9
2 files changed, 12 insertions, 1 deletions
diff --git a/karbor/services/protection/protection_plugins/volume/volume_glance_plugin.py b/karbor/services/protection/protection_plugins/volume/volume_glance_plugin.py
index f04d486..773a1e5 100644
--- a/karbor/services/protection/protection_plugins/volume/volume_glance_plugin.py
+++ b/karbor/services/protection/protection_plugins/volume/volume_glance_plugin.py
@@ -170,7 +170,9 @@ class ProtectOperation(protection_plugin.Operation):
170 force=True, 170 force=True,
171 image_name='temporary_image_of_{0}'.format(temporary_volume.id), 171 image_name='temporary_image_of_{0}'.format(temporary_volume.id),
172 container_format="bare", 172 container_format="bare",
173 disk_format="raw" 173 disk_format="raw",
174 visibility="private",
175 protected=False
174 ) 176 )
175 image_id = image[1]['os-volume_upload_image']['image_id'] 177 image_id = image[1]['os-volume_upload_image']['image_id']
176 is_success = utils.status_poll( 178 is_success = utils.status_poll(
diff --git a/karbor/tests/unit/protection/test_cinder_glance_plugin.py b/karbor/tests/unit/protection/test_cinder_glance_plugin.py
index 433ea6a..b3613b6 100644
--- a/karbor/tests/unit/protection/test_cinder_glance_plugin.py
+++ b/karbor/tests/unit/protection/test_cinder_glance_plugin.py
@@ -211,6 +211,15 @@ class VolumeGlanceProtectionPluginTest(base.TestCase):
211 211
212 call_hooks(protect_operation, self.checkpoint, resource, self.cntxt, 212 call_hooks(protect_operation, self.checkpoint, resource, self.cntxt,
213 {}) 213 {})
214 self.cinder_client.volumes.upload_to_image.assert_called_with(
215 volume=Volume(id='2345', status='available', size=1),
216 force=True,
217 image_name='temporary_image_of_2345',
218 container_format="bare",
219 disk_format="raw",
220 visibility="private",
221 protected=False
222 )
214 223
215 def test_delete_backup(self): 224 def test_delete_backup(self):
216 resource = Resource(id="123", 225 resource = Resource(id="123",