Add the GetTemplate API
see #1 Change-Id: I178a1d9a19570296b62381548434fb4fcf836fee Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
parent
4c359db1b0
commit
3601fb263c
14
bin/heat
14
bin/heat
@ -98,10 +98,18 @@ def template_validate(options, arguments):
|
||||
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')
|
||||
|
@ -123,6 +123,7 @@ class API(wsgi.Router):
|
||||
'update': 'UpdateStack',
|
||||
'events_list': 'DescribeStackEvents',
|
||||
'validate_template': 'ValidateTemplate',
|
||||
'get_template': 'GetTemplate',
|
||||
}
|
||||
|
||||
def __init__(self, conf, **local_conf):
|
||||
|
@ -150,6 +150,25 @@ class StackController(object):
|
||||
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
|
||||
|
@ -67,6 +67,9 @@ class V1Client(base_client.BaseClient):
|
||||
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
|
||||
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
import contextlib
|
||||
from copy import deepcopy
|
||||
import datetime
|
||||
import logging
|
||||
@ -218,6 +217,19 @@ class EngineManager(manager.Manager):
|
||||
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user