Merge "Fix using parent_name for Properties"
This commit is contained in:
commit
c1c6639c4a
|
@ -273,7 +273,8 @@ class Property(object):
|
|||
keys = list(self.schema.schema)
|
||||
schemata = dict((k, self.schema.schema[k]) for k in keys)
|
||||
properties = Properties(schemata, dict(child_values),
|
||||
context=self.context)
|
||||
context=self.context,
|
||||
parent_name=self.name)
|
||||
if validate:
|
||||
properties.validate()
|
||||
|
||||
|
@ -364,11 +365,8 @@ class Properties(collections.Mapping):
|
|||
for k, s in schema.items())
|
||||
self.resolve = resolver
|
||||
self.data = data
|
||||
self.error_prefix = []
|
||||
if parent_name is not None:
|
||||
self.error_prefix.append(parent_name)
|
||||
if section is not None:
|
||||
self.error_prefix.append(section)
|
||||
self.error_prefix = [section] if section is not None else []
|
||||
self.parent_name = parent_name
|
||||
self.context = context
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -969,6 +969,18 @@ class Resource(object):
|
|||
else:
|
||||
action = self.CREATE
|
||||
except exception.ResourceFailure as failure:
|
||||
if isinstance(failure.exc, exception.StackValidationFailed):
|
||||
path = [self.t.name]
|
||||
path.extend(failure.exc.path)
|
||||
raise exception.ResourceFailure(
|
||||
exception_or_error=exception.StackValidationFailed(
|
||||
error=failure.exc.error,
|
||||
path=path,
|
||||
message=failure.exc.error_message
|
||||
),
|
||||
resource=failure.resource,
|
||||
action=failure.action
|
||||
)
|
||||
if not isinstance(failure.exc, exception.ResourceInError):
|
||||
raise failure
|
||||
|
||||
|
@ -1546,9 +1558,9 @@ class Resource(object):
|
|||
with_value=self.stack.strict_validate,
|
||||
template=self.t)
|
||||
except exception.StackValidationFailed as ex:
|
||||
path = [self.stack.t.RESOURCES, ex.path[0],
|
||||
self.stack.t.get_section_name(ex.path[1])]
|
||||
path.extend(ex.path[2:])
|
||||
path = [self.stack.t.RESOURCES, self.t.name,
|
||||
self.stack.t.get_section_name(ex.path[0])]
|
||||
path.extend(ex.path[1:])
|
||||
raise exception.StackValidationFailed(
|
||||
error=ex.error,
|
||||
path=path,
|
||||
|
|
|
@ -245,7 +245,7 @@ class ResourceDefinition(object):
|
|||
require a context to validate constraints.
|
||||
"""
|
||||
return properties.Properties(schema, self._properties or {},
|
||||
function.resolve, self.name, context,
|
||||
function.resolve, context=context,
|
||||
section='Properties')
|
||||
|
||||
def deletion_policy(self):
|
||||
|
@ -262,7 +262,7 @@ class ResourceDefinition(object):
|
|||
require a context to validate constraints.
|
||||
"""
|
||||
return properties.Properties(schema, self._update_policy or {},
|
||||
function.resolve, self.name, context,
|
||||
function.resolve, context=context,
|
||||
section='UpdatePolicy')
|
||||
|
||||
def metadata(self):
|
||||
|
|
|
@ -565,7 +565,7 @@ class AodhAlarmTest(common.HeatTestCase):
|
|||
)
|
||||
self.assertEqual(
|
||||
"StackValidationFailed: resources.MEMAlarmHigh: Property error: "
|
||||
"MEMAlarmHigh.Properties.time_constraints[0].start: Error "
|
||||
"Properties.time_constraints[0].start: Error "
|
||||
"validating value '%s': Invalid CRON expression: "
|
||||
"[%s] is not acceptable, out of range" % (start_time, start_time),
|
||||
error.message)
|
||||
|
@ -618,7 +618,7 @@ class AodhAlarmTest(common.HeatTestCase):
|
|||
)
|
||||
self.assertEqual(
|
||||
"StackValidationFailed: resources.MEMAlarmHigh: Property error: "
|
||||
"MEMAlarmHigh.Properties.time_constraints[0].timezone: Error "
|
||||
"Properties.time_constraints[0].timezone: Error "
|
||||
"validating value '%s': Invalid timezone: '%s'"
|
||||
% (timezone, timezone),
|
||||
error.message)
|
||||
|
|
Loading…
Reference in New Issue