~ubuntu-branches/ubuntu/trusty/heat/trusty-security

« back to all changes in this revision

Viewing changes to heat/engine/stack_resource.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-10-03 09:43:04 UTC
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: package-import@ubuntu.com-20131003094304-zhhr2brapzlpvjmm
Tags: upstream-2013.2~rc1
ImportĀ upstreamĀ versionĀ 2013.2~rc1

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from heat.engine import parser
22
22
from heat.engine import resource
23
23
from heat.engine import scheduler
 
24
from heat.engine import template as tmpl
24
25
 
25
26
from heat.openstack.common import log as logging
26
27
 
33
34
    as a resource in a parent stack.
34
35
    '''
35
36
 
 
37
    # Assume True as this is evaluated before the stack is created
 
38
    # so there is no way to know for sure without subclass-specific
 
39
    # template parsing.
 
40
    requires_deferred_auth = True
 
41
 
36
42
    def __init__(self, name, json_snippet, stack):
37
43
        super(StackResource, self).__init__(name, json_snippet, stack)
38
44
        self._nested = None
71
77
        Handle the creation of the nested stack from a given JSON template.
72
78
        '''
73
79
        if self.recursion_depth >= cfg.CONF.max_nested_stack_depth:
74
 
            raise exception.StackRecursionLimitReached(
75
 
                cfg.CONF.max_nested_stack_depth)
 
80
            msg = _("Recursion depth exceeds %d.") % \
 
81
                cfg.CONF.max_nested_stack_depth
 
82
            raise exception.RequestLimitExceeded(message=msg)
76
83
        template = parser.Template(child_template)
 
84
        if ((len(template[tmpl.RESOURCES]) +
 
85
             self.stack.root_stack.total_resources() >
 
86
             cfg.CONF.max_resources_per_stack)):
 
87
            raise exception.RequestLimitExceeded(
 
88
                message=exception.StackResourceLimitExceeded.message)
77
89
        self._outputs_to_attribs(child_template)
78
90
 
79
91
        # Note we disable rollback for nested stacks, since they
114
126
        # on updated templates we should make sure it's optional because not
115
127
        # all subclasses want that behavior, since they may offer custom
116
128
        # attributes.
 
129
        nested_stack = self.nested()
 
130
        if nested_stack is not None:
 
131
            res_diff = (
 
132
                len(template[tmpl.RESOURCES]) - len(nested_stack.resources))
 
133
            new_size = nested_stack.root_stack.total_resources() + res_diff
 
134
            if new_size > cfg.CONF.max_resources_per_stack:
 
135
                raise exception.RequestLimitExceeded(
 
136
                    message=exception.StackResourceLimitExceeded.message)
117
137
 
118
138
        # Note we disable rollback for nested stacks, since they
119
139
        # should be rolled back by the parent stack on failure