"copy_volume_to_image",
stub_upload_volume_to_image_service)
- id = 1
+ id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
vol = {"container_format": 'bare',
"disk_format": 'raw',
"image_name": 'image_name',
self.stubs.Set(volume_api.API, 'get', stub_volume_get_raise_exc)
- id = 1
+ id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
vol = {"container_format": 'bare',
"disk_format": 'raw',
"image_name": 'image_name',
"copy_volume_to_image",
stub_upload_volume_to_image_service_raise)
- id = 1
+ id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
vol = {"container_format": 'bare',
"disk_format": 'raw',
"image_name": 'image_name',
"copy_volume_to_image",
stub_upload_volume_to_image_service_raise)
- id = 1
+ id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
vol = {"container_format": 'bare',
"disk_format": 'raw',
"image_name": 'image_name',
"copy_volume_to_image",
stub_upload_volume_to_image_service_raise)
- id = 1
+ id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
vol = {"container_format": 'bare',
"disk_format": 'raw',
"image_name": 'image_name',
body)
def test_volume_upload_image_typeerror(self):
- id = 1
+ id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
body = {"os-volume_upload_image_fake": "fake"}
req = webob.Request.blank('/v2/tenant1/volumes/%s/action' % id)
req.method = 'POST'
self.assertEqual(res.status_int, 400)
def test_volume_upload_image_without_type(self):
- id = 1
+ id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
vol = {"container_format": 'bare',
"disk_format": 'raw',
"image_name": None,
self.assertEqual(res.status_int, 400)
def test_extend_volume_valueerror(self):
- id = 1
+ id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
body = {'os-extend': {'new_size': 'fake'}}
req = fakes.HTTPRequest.blank('/v2/tenant1/volumes/%s/action' % id)
self.assertRaises(webob.exc.HTTPBadRequest,
body)
def test_copy_volume_to_image_notimagename(self):
- id = 1
+ id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
vol = {"container_format": 'bare',
"disk_format": 'raw',
"image_name": None,
def test_copy_volume_to_image_with_protected_prop(self):
"""Test create image from volume with protected properties."""
- id = 1
+ id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
def fake_get_volume_image_metadata(*args):
meta_dict = {
In this case volume glance metadata will not be available for this
volume.
"""
- id = 1
+ id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
def fake_get_volume_image_metadata_raise(*args):
raise exception.GlanceMetadataNotFound(id=id)
def test_copy_volume_to_image_without_protected_prop(self):
"""Test protected property is not defined with the root image."""
- id = 1
+ id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
def fake_get_volume_image_metadata(*args):
return []
def test_copy_volume_to_image_without_core_prop(self):
"""Test glance_core_properties defined in cinder.conf is empty."""
- id = 1
+ id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
# Need to mock create, update, copy_volume_to_image
with mock.patch.object(glance.GlanceImageService, "create") \
from cinder.volume import volume_types
+allow_force_upload = cfg.BoolOpt('enable_force_upload',
+ default=False,
+ help='Enables the Force option on '
+ 'upload_to_image. This enables '
+ 'running upload_volume on in-use '
+ 'volumes for backends that support it.')
volume_host_opt = cfg.BoolOpt('snapshot_same_host',
default=True,
help='Create volume from snapshot at the host '
'seconds')
CONF = cfg.CONF
+CONF.register_opt(allow_force_upload)
CONF.register_opt(volume_host_opt)
CONF.register_opt(volume_same_az_opt)
CONF.register_opt(az_cache_time_opt)
@wrap_check_policy
def copy_volume_to_image(self, context, volume, metadata, force):
"""Create a new image from the specified volume."""
+
+ if not CONF.enable_force_upload and force:
+ LOG.info(_LI("Force upload to image is disabled, "
+ "Force option will be ignored."),
+ resource={'type': 'volume', 'id': volume['id']})
+ force = False
+
self._check_volume_availability(volume, force)
glance_core_properties = CONF.glance_core_properties
if glance_core_properties: