Don't validate template resource parameter defaults in parent
When creating a properties schema for a TemplateResource, we should not
include the default parameter values specified in the template because
properties lack the type conversions that parameters do (specifically, a
comma_delimited_list parameter converts a string value to a list using
str.split()). We don't even pass defaults to the nested template anyway,
because it is the parameter parsing in the child stack that handles
substituting in any defaults.
Change-Id: Ic7251cf0fcb77cc2acae43dc3c1d9f4671e4a52e
Closes-Bug: #1564106
(cherry picked from commit 7933a8bc3d
)
This commit is contained in:
parent
b140e446ed
commit
2a8b332c0e
|
@ -161,8 +161,7 @@ class Schema(constr.Schema):
|
|||
constraints=param.constraints,
|
||||
update_allowed=True,
|
||||
immutable=False,
|
||||
allow_conversion=allow_conversion,
|
||||
default=param.default)
|
||||
allow_conversion=allow_conversion)
|
||||
|
||||
def allowed_param_prop_type(self):
|
||||
"""Return allowed type of Property Schema converted from parameter.
|
||||
|
|
|
@ -344,7 +344,7 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
|
||||
self.assertEqual(properties.Schema.STRING, schema.type)
|
||||
self.assertEqual(description, schema.description)
|
||||
self.assertEqual("m1.large", schema.default)
|
||||
self.assertIsNone(schema.default)
|
||||
self.assertFalse(schema.required)
|
||||
self.assertEqual(1, len(schema.constraints))
|
||||
|
||||
|
@ -353,6 +353,9 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
self.assertEqual(tuple(allowed_values), allowed_constraint.allowed)
|
||||
self.assertEqual(constraint_desc, allowed_constraint.description)
|
||||
|
||||
props = properties.Properties({'test': schema}, {})
|
||||
props.validate()
|
||||
|
||||
def test_from_string_allowed_pattern(self):
|
||||
description = "WebServer EC2 instance type"
|
||||
allowed_pattern = "[A-Za-z0-9.]*"
|
||||
|
@ -369,7 +372,7 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
|
||||
self.assertEqual(properties.Schema.STRING, schema.type)
|
||||
self.assertEqual(description, schema.description)
|
||||
self.assertEqual("m1.large", schema.default)
|
||||
self.assertIsNone(schema.default)
|
||||
self.assertFalse(schema.required)
|
||||
self.assertEqual(1, len(schema.constraints))
|
||||
|
||||
|
@ -378,6 +381,9 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
self.assertEqual(allowed_pattern, allowed_constraint.pattern)
|
||||
self.assertEqual(constraint_desc, allowed_constraint.description)
|
||||
|
||||
props = properties.Properties({'test': schema}, {})
|
||||
props.validate()
|
||||
|
||||
def test_from_string_multi_constraints(self):
|
||||
description = "WebServer EC2 instance type"
|
||||
allowed_pattern = "[A-Za-z0-9.]*"
|
||||
|
@ -395,7 +401,7 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
|
||||
self.assertEqual(properties.Schema.STRING, schema.type)
|
||||
self.assertEqual(description, schema.description)
|
||||
self.assertEqual("m1.large", schema.default)
|
||||
self.assertIsNone(schema.default)
|
||||
self.assertFalse(schema.required)
|
||||
self.assertEqual(2, len(schema.constraints))
|
||||
|
||||
|
@ -407,6 +413,9 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
self.assertEqual(allowed_pattern, allowed_constraint.pattern)
|
||||
self.assertEqual(constraint_desc, allowed_constraint.description)
|
||||
|
||||
props = properties.Properties({'test': schema}, {})
|
||||
props.validate()
|
||||
|
||||
def test_from_param_string_min_len(self):
|
||||
param = parameters.Schema.from_dict('name', {
|
||||
"Description": "WebServer EC2 instance type",
|
||||
|
@ -417,6 +426,7 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
schema = properties.Schema.from_parameter(param)
|
||||
|
||||
self.assertFalse(schema.required)
|
||||
self.assertIsNone(schema.default)
|
||||
self.assertEqual(1, len(schema.constraints))
|
||||
|
||||
len_constraint = schema.constraints[0]
|
||||
|
@ -424,6 +434,9 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
self.assertEqual(7, len_constraint.min)
|
||||
self.assertIsNone(len_constraint.max)
|
||||
|
||||
props = properties.Properties({'test': schema}, {})
|
||||
props.validate()
|
||||
|
||||
def test_from_param_string_max_len(self):
|
||||
param = parameters.Schema.from_dict('name', {
|
||||
"Description": "WebServer EC2 instance type",
|
||||
|
@ -434,6 +447,7 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
schema = properties.Schema.from_parameter(param)
|
||||
|
||||
self.assertFalse(schema.required)
|
||||
self.assertIsNone(schema.default)
|
||||
self.assertEqual(1, len(schema.constraints))
|
||||
|
||||
len_constraint = schema.constraints[0]
|
||||
|
@ -441,6 +455,9 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
self.assertIsNone(len_constraint.min)
|
||||
self.assertEqual(11, len_constraint.max)
|
||||
|
||||
props = properties.Properties({'test': schema}, {})
|
||||
props.validate()
|
||||
|
||||
def test_from_param_string_min_max_len(self):
|
||||
param = parameters.Schema.from_dict('name', {
|
||||
"Description": "WebServer EC2 instance type",
|
||||
|
@ -452,6 +469,7 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
schema = properties.Schema.from_parameter(param)
|
||||
|
||||
self.assertFalse(schema.required)
|
||||
self.assertIsNone(schema.default)
|
||||
self.assertEqual(1, len(schema.constraints))
|
||||
|
||||
len_constraint = schema.constraints[0]
|
||||
|
@ -459,6 +477,9 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
self.assertEqual(7, len_constraint.min)
|
||||
self.assertEqual(11, len_constraint.max)
|
||||
|
||||
props = properties.Properties({'test': schema}, {})
|
||||
props.validate()
|
||||
|
||||
def test_from_param_no_default(self):
|
||||
param = parameters.Schema.from_dict('name', {
|
||||
"Description": "WebServer EC2 instance type",
|
||||
|
@ -471,18 +492,20 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
self.assertEqual(0, len(schema.constraints))
|
||||
self.assertFalse(schema.allow_conversion)
|
||||
|
||||
props = properties.Properties({'name': schema}, {'name': 'm1.large'})
|
||||
props.validate()
|
||||
|
||||
def test_from_number_param_min(self):
|
||||
default = "42"
|
||||
param = parameters.Schema.from_dict('name', {
|
||||
"Type": "Number",
|
||||
"Default": default,
|
||||
"Default": "42",
|
||||
"MinValue": "10",
|
||||
})
|
||||
|
||||
schema = properties.Schema.from_parameter(param)
|
||||
|
||||
self.assertEqual(properties.Schema.NUMBER, schema.type)
|
||||
self.assertEqual(default, schema.default)
|
||||
self.assertIsNone(schema.default)
|
||||
self.assertFalse(schema.required)
|
||||
self.assertEqual(1, len(schema.constraints))
|
||||
|
||||
|
@ -491,18 +514,20 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
self.assertEqual(10, value_constraint.min)
|
||||
self.assertIsNone(value_constraint.max)
|
||||
|
||||
props = properties.Properties({'test': schema}, {})
|
||||
props.validate()
|
||||
|
||||
def test_from_number_param_max(self):
|
||||
default = "42"
|
||||
param = parameters.Schema.from_dict('name', {
|
||||
"Type": "Number",
|
||||
"Default": default,
|
||||
"Default": "42",
|
||||
"MaxValue": "100",
|
||||
})
|
||||
|
||||
schema = properties.Schema.from_parameter(param)
|
||||
|
||||
self.assertEqual(properties.Schema.NUMBER, schema.type)
|
||||
self.assertEqual(default, schema.default)
|
||||
self.assertIsNone(schema.default)
|
||||
self.assertFalse(schema.required)
|
||||
self.assertEqual(1, len(schema.constraints))
|
||||
|
||||
|
@ -511,11 +536,13 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
self.assertIsNone(value_constraint.min)
|
||||
self.assertEqual(100, value_constraint.max)
|
||||
|
||||
props = properties.Properties({'test': schema}, {})
|
||||
props.validate()
|
||||
|
||||
def test_from_number_param_min_max(self):
|
||||
default = "42"
|
||||
param = parameters.Schema.from_dict('name', {
|
||||
"Type": "Number",
|
||||
"Default": default,
|
||||
"Default": "42",
|
||||
"MinValue": "10",
|
||||
"MaxValue": "100",
|
||||
})
|
||||
|
@ -523,7 +550,7 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
schema = properties.Schema.from_parameter(param)
|
||||
|
||||
self.assertEqual(properties.Schema.NUMBER, schema.type)
|
||||
self.assertEqual(default, schema.default)
|
||||
self.assertIsNone(schema.default)
|
||||
self.assertFalse(schema.required)
|
||||
self.assertEqual(1, len(schema.constraints))
|
||||
|
||||
|
@ -532,12 +559,14 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
self.assertEqual(10, value_constraint.min)
|
||||
self.assertEqual(100, value_constraint.max)
|
||||
|
||||
props = properties.Properties({'test': schema}, {})
|
||||
props.validate()
|
||||
|
||||
def test_from_number_param_allowed_vals(self):
|
||||
default = "42"
|
||||
constraint_desc = "The quick brown fox jumps over the lazy dog."
|
||||
param = parameters.Schema.from_dict('name', {
|
||||
"Type": "Number",
|
||||
"Default": default,
|
||||
"Default": "42",
|
||||
"AllowedValues": ["10", "42", "100"],
|
||||
"ConstraintDescription": constraint_desc,
|
||||
})
|
||||
|
@ -545,7 +574,7 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
schema = properties.Schema.from_parameter(param)
|
||||
|
||||
self.assertEqual(properties.Schema.NUMBER, schema.type)
|
||||
self.assertEqual(default, schema.default)
|
||||
self.assertIsNone(schema.default)
|
||||
self.assertFalse(schema.required)
|
||||
self.assertEqual(1, len(schema.constraints))
|
||||
self.assertFalse(schema.allow_conversion)
|
||||
|
@ -555,6 +584,9 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
self.assertEqual(('10', '42', '100'), allowed_constraint.allowed)
|
||||
self.assertEqual(constraint_desc, allowed_constraint.description)
|
||||
|
||||
props = properties.Properties({'test': schema}, {})
|
||||
props.validate()
|
||||
|
||||
def test_from_list_param(self):
|
||||
param = parameters.Schema.from_dict('name', {
|
||||
"Type": "CommaDelimitedList",
|
||||
|
@ -564,10 +596,13 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
schema = properties.Schema.from_parameter(param)
|
||||
|
||||
self.assertEqual(properties.Schema.LIST, schema.type)
|
||||
self.assertEqual("foo,bar,baz", schema.default)
|
||||
self.assertIsNone(schema.default)
|
||||
self.assertFalse(schema.required)
|
||||
self.assertFalse(schema.allow_conversion)
|
||||
|
||||
props = properties.Properties({'test': schema}, {})
|
||||
props.validate()
|
||||
|
||||
def test_from_json_param(self):
|
||||
param = parameters.Schema.from_dict('name', {
|
||||
"Type": "Json",
|
||||
|
@ -577,11 +612,13 @@ class PropertySchemaTest(common.HeatTestCase):
|
|||
schema = properties.Schema.from_parameter(param)
|
||||
|
||||
self.assertEqual(properties.Schema.MAP, schema.type)
|
||||
self.assertEqual({"foo": "bar", "blarg": "wibble"},
|
||||
schema.default)
|
||||
self.assertIsNone(schema.default)
|
||||
self.assertFalse(schema.required)
|
||||
self.assertTrue(schema.allow_conversion)
|
||||
|
||||
props = properties.Properties({'test': schema}, {})
|
||||
props.validate()
|
||||
|
||||
def test_no_mismatch_in_update_policy(self):
|
||||
manager = plugin_manager.PluginManager('heat.engine.resources')
|
||||
resource_mapping = plugin_manager.PluginMapping('resource')
|
||||
|
@ -1288,7 +1325,6 @@ class PropertiesTest(common.HeatTestCase):
|
|||
"DBUsername": {
|
||||
"type": "string",
|
||||
"description": "The WordPress database admin account username",
|
||||
"default": "admin",
|
||||
"required": False,
|
||||
'update_allowed': True,
|
||||
'immutable': False,
|
||||
|
@ -1304,7 +1340,6 @@ class PropertiesTest(common.HeatTestCase):
|
|||
"LinuxDistribution": {
|
||||
"type": "string",
|
||||
"description": "Distribution of choice",
|
||||
"default": "F17",
|
||||
"required": False,
|
||||
'update_allowed': True,
|
||||
'immutable': False,
|
||||
|
@ -1316,7 +1351,6 @@ class PropertiesTest(common.HeatTestCase):
|
|||
"InstanceType": {
|
||||
"type": "string",
|
||||
"description": "WebServer EC2 instance type",
|
||||
"default": "m1.large",
|
||||
"required": False,
|
||||
'update_allowed': True,
|
||||
'immutable': False,
|
||||
|
@ -1337,7 +1371,6 @@ class PropertiesTest(common.HeatTestCase):
|
|||
"DBRootPassword": {
|
||||
"type": "string",
|
||||
"description": "Root password for MySQL",
|
||||
"default": "admin",
|
||||
"required": False,
|
||||
'update_allowed': True,
|
||||
'immutable': False,
|
||||
|
@ -1361,7 +1394,6 @@ class PropertiesTest(common.HeatTestCase):
|
|||
"DBPassword": {
|
||||
"type": "string",
|
||||
"description": "The WordPress database admin account password",
|
||||
"default": "admin",
|
||||
"required": False,
|
||||
'update_allowed': True,
|
||||
'immutable': False,
|
||||
|
@ -1377,7 +1409,6 @@ class PropertiesTest(common.HeatTestCase):
|
|||
"DBName": {
|
||||
"type": "string",
|
||||
"description": "The WordPress database name",
|
||||
"default": "wordpress",
|
||||
"required": False,
|
||||
'update_allowed': True,
|
||||
'immutable': False,
|
||||
|
@ -1491,7 +1522,6 @@ class PropertiesTest(common.HeatTestCase):
|
|||
"InstanceType": {
|
||||
"type": "string",
|
||||
"description": "WebServer EC2 instance type",
|
||||
"default": "m1.large",
|
||||
"required": False,
|
||||
'update_allowed': True,
|
||||
'immutable': False,
|
||||
|
@ -1504,7 +1534,6 @@ class PropertiesTest(common.HeatTestCase):
|
|||
]
|
||||
},
|
||||
"LinuxDistribution": {
|
||||
"default": "F17",
|
||||
"type": "string",
|
||||
"description": "Distribution of choice",
|
||||
"required": False,
|
||||
|
@ -1519,7 +1548,6 @@ class PropertiesTest(common.HeatTestCase):
|
|||
"DBName": {
|
||||
"type": "string",
|
||||
"description": "The WordPress database name",
|
||||
"default": "wordpress",
|
||||
"required": False,
|
||||
'update_allowed': True,
|
||||
'immutable': False,
|
||||
|
@ -1534,7 +1562,6 @@ class PropertiesTest(common.HeatTestCase):
|
|||
"DBUsername": {
|
||||
"type": "string",
|
||||
"description": "The WordPress database admin account username",
|
||||
"default": "admin",
|
||||
"required": False,
|
||||
'update_allowed': True,
|
||||
'immutable': False,
|
||||
|
@ -1549,7 +1576,6 @@ class PropertiesTest(common.HeatTestCase):
|
|||
"DBPassword": {
|
||||
"type": "string",
|
||||
"description": "The WordPress database admin account password",
|
||||
"default": "admin",
|
||||
"required": False,
|
||||
'update_allowed': True,
|
||||
'immutable': False,
|
||||
|
@ -1564,7 +1590,6 @@ class PropertiesTest(common.HeatTestCase):
|
|||
"DBRootPassword": {
|
||||
"type": "string",
|
||||
"description": "Root password for MySQL",
|
||||
"default": "admin",
|
||||
"required": False,
|
||||
'update_allowed': True,
|
||||
'immutable': False,
|
||||
|
|
Loading…
Reference in New Issue