]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
VMware: Fix ImageNotAuthorized during copy volume
authorVipin Balachandran <vbala@vmware.com>
Fri, 27 Mar 2015 13:09:04 +0000 (06:09 -0700)
committerVipin Balachandran <vbala@vmware.com>
Fri, 27 Mar 2015 13:34:55 +0000 (06:34 -0700)
Copy volume to image by non-admin user fails with ImageNotAuthorized.
This is because we are setting image's is_public meta-data to True
while calling image update (for writing to image). This patch fixes
this by setting is_public using the image-meta passed in by Cinder.

This bug was introduced by commit 960cbb21e359a3526e9ff9bf4ca78db1eca3a743.

Note: The oslo.vmware API which we use for upload requires is_public
meta-data which may not be needed at all for writing to image.
Till we update oslo.vmware API, we have to pass a value for is_public.

Change-Id: Ib7778b6c7a3e8dd501216173a26d7ba246aa85e4
Closes-Bug: #1437319

cinder/tests/test_vmware_vmdk.py
cinder/volume/drivers/vmware/vmdk.py

index 9ad4333206643ebba648044888005610095eb5dc..e32719c1fcd7eddccd82d54ad0c745b5fbe650f7 100644 (file)
@@ -1164,6 +1164,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase):
         image_meta['disk_format'] = 'vmdk'
         image_meta['id'] = image_id
         image_meta['name'] = image_id
+        image_meta['is_public'] = True
         image_service = FakeObject()
         vol_name = 'volume-123456789'
         project_id = 'project-owner-id-123'
index 29f951c8928d7b03db43b2f6227016df25663dbc..a9b3c47c80015a5e4c908bf0caeed94ce9c23b8b 100644 (file)
@@ -1344,7 +1344,7 @@ class VMwareEsxVmdkDriver(driver.VolumeDriver):
                                     vmdk_size=volume['size'] * units.Gi,
                                     image_name=image_meta['name'],
                                     image_version=1,
-                                    is_public=True)
+                                    is_public=image_meta['is_public'])
         LOG.info(_LI("Done copying volume %(vol)s to a new image %(img)s"),
                  {'vol': volume['name'], 'img': image_meta['name']})