def get_template(options, arguments):
'''
Gets an existing stack template.
-
- NOT YET IMPLEMENTED.
'''
- pass
+ parameters = {}
+ try:
+ parameters['StackName'] = arguments.pop(0)
+ except IndexError:
+ logging.error("Please specify the stack you wish to get")
+ logging.error("as the first argument")
+ return utils.FAILURE
+
+ c = get_client(options)
+ result = c.get_template(**parameters)
+ print json.dumps(result, indent=2)
@utils.catch_error('create')
'update': 'UpdateStack',
'events_list': 'DescribeStackEvents',
'validate_template': 'ValidateTemplate',
+ 'get_template': 'GetTemplate',
}
def __init__(self, conf, **local_conf):
except rpc_common.RemoteError as ex:
return webob.exc.HTTPBadRequest(str(ex))
+ def get_template(self, req):
+
+ con = req.context
+ parms = dict(req.params)
+
+ logger.info('get_template')
+ try:
+ templ = rpc.call(con, 'engine',
+ {'method': 'get_template',
+ 'args': {'stack_name': req.params['StackName'],
+ 'params': parms}})
+ except rpc_common.RemoteError as ex:
+ return webob.exc.HTTPBadRequest(str(ex))
+
+ if templ is None:
+ return webob.exc.HTTPNotFound('stack not found')
+
+ return {'GetTemplateResult': {'TemplateBody': templ}}
+
def validate_template(self, req):
con = req.context
def validate_template(self, **kwargs):
return self.stack_request("ValidateTemplate", "GET", **kwargs)
+ def get_template(self, **kwargs):
+ return self.stack_request("GetTemplate", "GET", **kwargs)
+
HeatClient = V1Client
# under the License.
-import contextlib
from copy import deepcopy
import datetime
import logging
return res
+ def get_template(self, context, stack_name, params):
+ """
+ Get the template.
+ arg1 -> RPC context.
+ arg2 -> Name of the stack you want to see.
+ arg3 -> Dict of http request parameters passed in from API side.
+ """
+ self._authenticate(context)
+ s = db_api.stack_get(None, stack_name)
+ if s:
+ return s.raw_template.template
+ return None
+
def delete_stack(self, context, stack_name, params):
"""
The delete_stack method deletes a given stack.