~ubuntu-branches/ubuntu/wily/heat/wily

« back to all changes in this revision

Viewing changes to heat/engine/resources/template_resource.py

  • Committer: Package Import Robot
  • Author(s): Corey Bryant
  • Date: 2015-08-19 08:11:50 UTC
  • mfrom: (1.1.27)
  • Revision ID: package-import@ubuntu.com-20150819081150-m969fd35xn8bdmfu
Tags: 1:5.0.0~b2-0ubuntu1
* New upstream milestone for OpenStack Liberty.
* d/control: Align (build-)depends with upstream.
* d/p/fix-requirements.patch: Dropped. No longer needed.
* d/p/fixup-assert-regex.patch: Rebased.
* d/rules: Remove .eggs directory in override_dh_auto_clean.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
import six
17
17
 
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
73
74
        else:
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')
78
80
            else:
112
114
 
113
115
        self.properties = definition.properties(self.properties_schema,
114
116
                                                self.context)
 
117
        self.attributes_schema.update(self.base_attributes_schema)
115
118
        self.attributes = attributes.Attributes(self.name,
116
119
                                                self.attributes_schema,
117
120
                                                self._resolve_attribute)
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,
195
 
                                            self.template_name)
 
198
                                            self.template_name,
 
199
                                            path=self.resource_path)
196
200
            return t_data
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())
278
282
 
279
 
    def handle_delete(self):
280
 
        return self.delete_nested()
281
 
 
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:
294
295
            return None
295
296
 
296
 
        def _get_inner_resource(resource_name):
297
 
            if self.nested() is not None:
298
 
                try:
299
 
                    return self.nested()[resource_name]
300
 
                except KeyError:
301
 
                    raise exception.ResourceNotFound(
302
 
                        resource_name=resource_name,
303
 
                        stack_name=self.nested().name)
304
 
 
305
 
        def get_rsrc_attr(resource_name, *attr_path):
306
 
            resource = _get_inner_resource(resource_name)
307
 
            return resource.FnGetAtt(*attr_path)
308
 
 
309
 
        def get_rsrc_id(resource_name):
310
 
            resource = _get_inner_resource(resource_name)
311
 
            return resource.FnGetRefId()
312
 
 
313
297
        # first look for explicit resource.x.y
314
298
        if key.startswith('resource.'):
315
 
            npath = key.split(".", 2)[1:] + list(path)
316
 
            if len(npath) > 1:
317
 
                return get_rsrc_attr(*npath)
318
 
            else:
319
 
                return get_rsrc_id(*npath)
 
299
            return grouputils.get_nested_attrs(self, key, False, *path)
320
300
 
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)
324
304
 
325
305
        # otherwise the key must be wrong.
326
306
        raise exception.InvalidTemplateAttribute(resource=self.name,