Add HIDDEN status to RandomString sequence

Add HIDDEN status to RandomString property sequence
and translation_rule for this property.

bp deprecation-improvements

Change-Id: Ib1bce384242343af949ab021297cf888f342daac
This commit is contained in:
Peter Razumovsky 2015-06-15 17:26:34 +03:00
parent a43e2c95d8
commit f013e37011
2 changed files with 24 additions and 25 deletions

View File

@ -79,9 +79,13 @@ class RandomString(resource.Resource):
'octdigits']),
],
support_status=support.SupportStatus(
status=support.DEPRECATED,
message=_('Use property %s.') % CHARACTER_CLASSES,
version='2014.2'
status=support.HIDDEN,
version='5.0.0',
previous_status=support.SupportStatus(
status=support.DEPRECATED,
message=_('Use property %s.') % CHARACTER_CLASSES,
version='2014.2'
)
)
),
CHARACTER_CLASSES: properties.Schema(
@ -169,6 +173,23 @@ class RandomString(resource.Resource):
'octdigits': string.octdigits
}
def translation_rules(self):
if self.properties.get(self.SEQUENCE):
return [
properties.TranslationRule(
self.properties,
properties.TranslationRule.ADD,
[self.CHARACTER_CLASSES],
[{self.CHARACTER_CLASSES_CLASS: self.properties.get(
self.SEQUENCE),
self.CHARACTER_CLASSES_MIN: 1}]),
properties.TranslationRule(
self.properties,
properties.TranslationRule.DELETE,
[self.SEQUENCE]
)
]
@staticmethod
def _deprecated_random_string(sequence, length):
rand = random.SystemRandom()

View File

@ -154,28 +154,6 @@ Resources:
secret6.resource_id = None
self.assertEqual('secret6', secret6.FnGetRefId())
def test_invalid_property_combination(self):
template_random_string = '''
HeatTemplateFormatVersion: '2012-12-12'
Resources:
secret:
Type: OS::Heat::RandomString
Properties:
length: 32
sequence: octdigits
character_classes:
- class: digits
min: 1
character_sequences:
- sequence: (),[]{}
min: 1
'''
exc = self.assertRaises(exception.StackValidationFailed,
self.create_stack, template_random_string)
self.assertEqual("Cannot use deprecated 'sequence' property along "
"with 'character_sequences' or 'character_classes' "
"properties", six.text_type(exc))
def test_invalid_length(self):
template_random_string = '''
HeatTemplateFormatVersion: '2012-12-12'