From f73c9e527810bfd2c5e9c95af02bad5fb9cd0891 Mon Sep 17 00:00:00 2001 From: Vipin Balachandran Date: Fri, 27 Mar 2015 06:09:04 -0700 Subject: [PATCH] VMware: Fix ImageNotAuthorized during copy volume 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 | 1 + cinder/volume/drivers/vmware/vmdk.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cinder/tests/test_vmware_vmdk.py b/cinder/tests/test_vmware_vmdk.py index 9ad433320..e32719c1f 100644 --- a/cinder/tests/test_vmware_vmdk.py +++ b/cinder/tests/test_vmware_vmdk.py @@ -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' diff --git a/cinder/volume/drivers/vmware/vmdk.py b/cinder/volume/drivers/vmware/vmdk.py index 29f951c89..a9b3c47c8 100644 --- a/cinder/volume/drivers/vmware/vmdk.py +++ b/cinder/volume/drivers/vmware/vmdk.py @@ -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']}) -- 2.45.2