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

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-10-03 09:43:04 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20131003094304-k2c4qcsfn7cv6eos
Tags: 2013.2~rc1-0ubuntu1
* New upstream release.
* debian/control: Dropped python-d2to1 build dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#    License for the specific language governing permissions and limitations
14
14
#    under the License.
15
15
 
 
16
from requests import exceptions
 
17
 
16
18
from heat.common import exception
17
19
from heat.common import template_format
18
20
from heat.common import urlfetch
34
36
    A Resource representing a child stack to allow composition of templates.
35
37
    '''
36
38
 
37
 
    properties_schema = {PROP_TEMPLATE_URL: {'Type': 'String',
38
 
                                             'Required': True},
39
 
                         PROP_TIMEOUT_MINS: {'Type': 'Number'},
40
 
                         PROP_PARAMETERS: {'Type': 'Map'}}
 
39
    properties_schema = {
 
40
        PROP_TEMPLATE_URL: {
 
41
            'Type': 'String',
 
42
            'Required': True,
 
43
            'Description': _('The URL of a template that specifies the stack'
 
44
                             ' to be created as a resource.')},
 
45
        PROP_TIMEOUT_MINS: {
 
46
            'Type': 'Number',
 
47
            'Description': _('The length of time, in minutes, to wait for the'
 
48
                             ' nested stack creation.')},
 
49
        PROP_PARAMETERS: {
 
50
            'Type': 'Map',
 
51
            'Description': _('The set of parameters passed to this nested'
 
52
                             ' stack.')}}
41
53
 
42
54
    update_allowed_keys = ('Properties',)
43
55
    update_allowed_properties = (PROP_TEMPLATE_URL, PROP_TIMEOUT_MINS,
44
56
                                 PROP_PARAMETERS)
45
57
 
46
58
    def handle_create(self):
47
 
        template_data = urlfetch.get(self.properties[PROP_TEMPLATE_URL])
 
59
        try:
 
60
            template_data = urlfetch.get(self.properties[PROP_TEMPLATE_URL])
 
61
        except (exceptions.RequestException, IOError) as r_exc:
 
62
            raise ValueError("Could not fetch remote template '%s': %s" %
 
63
                             (self.properties[PROP_TEMPLATE_URL], str(r_exc)))
 
64
 
48
65
        template = template_format.parse(template_data)
49
66
 
50
67
        return self.create_with_template(template,
70
87
                                     self.stack.resolve_runtime_data,
71
88
                                     self.name)
72
89
 
73
 
        template_data = urlfetch.get(self.properties[PROP_TEMPLATE_URL])
 
90
        try:
 
91
            template_data = urlfetch.get(self.properties[PROP_TEMPLATE_URL])
 
92
        except (exceptions.RequestException, IOError) as r_exc:
 
93
            raise ValueError("Could not fetch remote template '%s': %s" %
 
94
                             (self.properties[PROP_TEMPLATE_URL], str(r_exc)))
 
95
 
74
96
        template = template_format.parse(template_data)
75
97
 
76
98
        return self.update_with_template(template,