Add HIDDEN status to Cinder::Volume image_ref

Add HIDDEN status and translation rules to image_ref
property of Cinder::Volume resource.

bp deprecating-improvements

Change-Id: I478e772f0452c4ba9a648472b577466b6caa96b8
This commit is contained in:
Peter Razumovsky 2015-06-29 12:27:56 +03:00
parent 6c0001ffb7
commit 42f6e521b5
2 changed files with 26 additions and 8 deletions

View File

@ -106,9 +106,14 @@ class CinderVolume(vb.BaseVolume):
properties.Schema.STRING,
_('The ID of the image to create the volume from.'),
support_status=support.SupportStatus(
status=support.DEPRECATED,
status=support.HIDDEN,
message=_('Use property %s.') % IMAGE,
version='2014.1')
version='5.0.0',
previous_status=support.SupportStatus(
status=support.DEPRECATED,
version='2014.1'
)
)
),
IMAGE: properties.Schema(
properties.Schema.STRING,
@ -200,6 +205,16 @@ class CinderVolume(vb.BaseVolume):
_volume_creating_status = ['creating', 'restoring-backup', 'downloading']
def translation_rules(self):
return [
properties.TranslationRule(
self.properties,
properties.TranslationRule.REPLACE,
[self.IMAGE],
value_path=[self.IMAGE_REF]
)
]
def _name(self):
name = self.properties[self.NAME]
if name:

View File

@ -898,12 +898,14 @@ class CinderVolumeTest(vt_base.BaseVolumeTest):
def test_cinder_create_with_image_and_imageRef(self):
stack_name = 'test_create_with_image_and_imageRef'
combinations = {'imageRef': 'image-456', 'image': 'image-123'}
err_msg = ("Cannot define the following properties at the same "
"time: image, imageRef.")
err_msg = "Cannot use image and imageRef at the same time."
self.stub_ImageConstraint_validate()
self._test_cinder_create_invalid_property_combinations(
stack_name, combinations,
err_msg, exception.ResourcePropertyConflict)
stack = utils.parse_stack(self.t, stack_name=stack_name)
vp = stack.t['Resources']['volume2']['Properties']
vp.pop('size')
vp.update(combinations)
ex = self.assertRaises(ValueError, stack.get, 'volume2')
self.assertEqual(err_msg, six.text_type(ex))
def test_cinder_create_with_size_snapshot_and_image(self):
stack_name = 'test_create_with_size_snapshot_and_image'
@ -929,10 +931,11 @@ class CinderVolumeTest(vt_base.BaseVolumeTest):
'snapshot_id': 'snapshot-123'}
self.stub_ImageConstraint_validate()
self.stub_SnapshotConstraint_validate()
# image appears there because of translation rule
err_msg = ('If "size" is provided, only one of "image", "imageRef", '
'"source_volid", "snapshot_id" can be specified, but '
'currently specified options: '
'[\'snapshot_id\', \'imageRef\'].')
'[\'snapshot_id\', \'image\'].')
self._test_cinder_create_invalid_property_combinations(
stack_name, combinations,
err_msg, exception.StackValidationFailed)