parameters['Parameters.member.%d.ParameterValue' % count] = v
count = count + 1
- parameters['Timeout'] = options.timeout
+ parameters['TimeoutInMinutes'] = options.timeout
if options.template_file:
parameters['TemplateBody'] = open(options.template_file).read()
except ValueError:
msg = _("The Template must be a JSON document.")
return webob.exc.HTTPBadRequest(explanation=msg)
- stack['StackName'] = req.params['StackName']
- if 'Timeout' in req.params:
- stack['Timeout'] = req.params['Timeout']
try:
res = rpc.call(con, 'engine',
SUPPORTED_PARAMS = ('StackName', 'TemplateBody', 'TemplateUrl',
'NotificationARNs', 'Parameters', 'Version',
'SignatureVersion', 'Timestamp', 'AWSAccessKeyId',
- 'Signature', 'KeyStoneCreds', 'Timeout',
+ 'Signature', 'KeyStoneCreds', 'TimeoutInMinutes',
'LogicalResourceId', 'PhysicalResourceId', 'NextToken',
)
return dict(get_param_pairs())
+def _extract_args(params):
+ kwargs = {}
+ try:
+ timeout_mins = int(params.get('TimeoutInMinutes', 0))
+ except ValueError:
+ logger.exception('create timeout conversion')
+ else:
+ if timeout > 0:
+ kwargs['timeout_in_minutes'] = timeout_mins
+ return kwargs
+
+
class EngineManager(manager.Manager):
"""
Manages the running instances from creation to destruction.
mem['LastUpdatedTimestamp'] = heat_utils.strtime(s.updated_at)
mem['NotificationARNs'] = 'TODO'
mem['Parameters'] = ps.t['Parameters']
- mem['TimeoutInMinutes'] = ps.t.get('Timeout', '60')
mem['Description'] = ps.t.get('Description',
- 'No description')
+ 'No description')
mem['StackStatus'] = s.status
mem['StackStatusReason'] = s.status_reason
new_pt = db_api.parsed_template_create(None, pt)
stack.parsed_template_id = new_pt.id
- greenpool.spawn_n(stack.create)
+
+ greenpool.spawn_n(stack.create, **_extract_args(params))
return {'StackId': "/".join([new_s.name, str(new_s.id)])}
stack.update_and_save({'status': new_status,
'status_reason': reason})
- def _timeout(self):
- '''Return the stack creation timeout in seconds'''
- if 'Timeout' in self.t:
- try:
- # Timeout is in minutes
- return int(self.t['Timeout']) * 60
- except ValueError:
- logger.exception('create timeout conversion')
-
- # Default to 1 hour
- return 60 * 60
-
- def create(self):
+ def create(self, timeout_in_minutes=60):
'''
Create the stack and all of the resources.
+
+ Creation will fail if it exceeds the specified timeout. The default is
+ 60 minutes.
'''
self.state_set(self.IN_PROGRESS, 'Stack creation started')
stack_status = self.CREATE_COMPLETE
reason = 'Stack successfully created'
+ res = None
- with eventlet.Timeout(self._timeout()) as tmo:
+ with eventlet.Timeout(timeout_in_minutes * 60) as tmo:
try:
for res in self:
if stack_status != self.CREATE_FAILED:
res.state_set(res.CREATE_FAILED,
'Stack creation aborted')
- except eventlet.Timeout, t:
+ except eventlet.Timeout as t:
if t is tmo:
stack_status = self.CREATE_FAILED
- reason = 'Timed out waiting for %s' % (res.name)
+ reason = 'Timed out waiting for %s' % str(res)
else:
# not my timeout
raise