18
18
from heat.common import exception
19
from heat.common import grouputils
19
20
from heat.common.i18n import _
20
21
from heat.common import template_format
21
22
from heat.common import urlfetch
74
75
self.template_name = tri.template_name
75
76
self.resource_type = tri.name
77
self.resource_path = tri.path
76
78
if tri.user_resource:
77
79
self.allowed_schemes = ('http', 'https')
192
195
if t_data is not None:
193
196
self.stack.t.files[self.template_name] = t_data
194
197
self.stack.t.env.register_class(self.resource_type,
199
path=self.resource_path)
197
201
if reported_excp is None:
198
202
reported_excp = ValueError(_('Unknown error retrieving %s') %
276
280
return self.update_with_template(self.child_template(),
277
281
self.child_params())
279
def handle_delete(self):
280
return self.delete_nested()
282
283
def FnGetRefId(self):
283
284
if self.nested() is None:
284
285
return six.text_type(self.name)
293
294
if stack is None:
296
def _get_inner_resource(resource_name):
297
if self.nested() is not None:
299
return self.nested()[resource_name]
301
raise exception.ResourceNotFound(
302
resource_name=resource_name,
303
stack_name=self.nested().name)
305
def get_rsrc_attr(resource_name, *attr_path):
306
resource = _get_inner_resource(resource_name)
307
return resource.FnGetAtt(*attr_path)
309
def get_rsrc_id(resource_name):
310
resource = _get_inner_resource(resource_name)
311
return resource.FnGetRefId()
313
297
# first look for explicit resource.x.y
314
298
if key.startswith('resource.'):
315
npath = key.split(".", 2)[1:] + list(path)
317
return get_rsrc_attr(*npath)
319
return get_rsrc_id(*npath)
299
return grouputils.get_nested_attrs(self, key, False, *path)
321
301
# then look for normal outputs
322
302
if key in stack.outputs:
323
return attributes.select_from_attribute(stack.output(key), path)
303
return attributes.select_from_attribute(self.get_output(key), path)
325
305
# otherwise the key must be wrong.
326
306
raise exception.InvalidTemplateAttribute(resource=self.name,