From 13435988905df7de2d804ba2201ec08f13f61de6 Mon Sep 17 00:00:00 2001 From: Peter Razumovsky Date: Thu, 13 Nov 2014 18:31:46 +0300 Subject: [PATCH] Add Dimensions Default in AWS_CloudWatch_Alarm.yaml Relying on [1], property Dimensions isn't required, but this template has no Default value for Dimensions (thereby making it required). This patch fix that omission. Besides that, parameters have wrong parsing, because if parameter with type 'CommaDelimitedList' has default value '', parameter's parsing result would be [u''] instead of []. this is wrong, so this patch fix it. [1] http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html Change-Id: I259249659c8b5dc846432f8e08985b148b30d682 Closes-bug: #1386824 --- etc/heat/templates/AWS_CloudWatch_Alarm.yaml | 1 + heat/engine/parameters.py | 2 ++ heat/tests/test_parameters.py | 5 ++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/etc/heat/templates/AWS_CloudWatch_Alarm.yaml b/etc/heat/templates/AWS_CloudWatch_Alarm.yaml index e21e500d6..2e5f36625 100644 --- a/etc/heat/templates/AWS_CloudWatch_Alarm.yaml +++ b/etc/heat/templates/AWS_CloudWatch_Alarm.yaml @@ -43,6 +43,7 @@ Parameters: Default: '' Dimensions: Type: CommaDelimitedList + Default: '' Mappings: ComparisonOperatorMap: diff --git a/heat/engine/parameters.py b/heat/engine/parameters.py index 2118f8aff..76f108f89 100644 --- a/heat/engine/parameters.py +++ b/heat/engine/parameters.py @@ -335,6 +335,8 @@ class CommaDelimitedListParam(Parameter, collections.Sequence): return value try: if value is not None: + if value == '': + return [] return value.split(',') except (KeyError, AttributeError) as err: message = _('Value must be a comma-delimited list string: %s') diff --git a/heat/tests/test_parameters.py b/heat/tests/test_parameters.py index ef0885563..8c0e6c209 100644 --- a/heat/tests/test_parameters.py +++ b/heat/tests/test_parameters.py @@ -251,10 +251,9 @@ class ParameterTest(testtools.TestCase): self.assertIn('wibble', six.text_type(err)) def test_list_value_list_default_empty(self): - schema = {'Type': 'CommaDelimitedList'} - schema['Default'] = '' + schema = {'Type': 'CommaDelimitedList', 'Default': ''} p = self.new_parameter('p', schema) - self.assertEqual([''], p.value()) + self.assertEqual([], p.value()) def test_list_value_list_good(self): schema = {'Type': 'CommaDelimitedList',