Browse Source

Hook up the update and delete (not quite working)

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
changes/40/40/1
Angus Salkeld 10 years ago
parent
commit
a76d02e790
  1. 11
      heat/api/v1/router.py
  2. 9
      heat/api/v1/stacks.py
  3. 9
      heat/client.py

11
heat/api/v1/router.py

@ -25,12 +25,7 @@ logger = logging.getLogger(__name__)
class API(wsgi.Router):
"""WSGI router for Heat v1 API requests."""
#TODO
#DeleteStack
#GetTemplate
#UpdateStack
#ValidateTemplate
#TODO GetTemplate, ValidateTemplate
def __init__(self, conf, **local_conf):
self.conf = conf
@ -48,5 +43,9 @@ class API(wsgi.Router):
action="list", conditions=dict(method=["GET"]))
mapper.connect("/DescribeStacks", controller=stacks_resource,
action="describe", conditions=dict(method=["GET"]))
mapper.connect("/DeleteStack", controller=stacks_resource,
action="delete", conditions=dict(method=["DELETE"]))
mapper.connect("/UpdateStack", controller=stacks_resource,
action="update", conditions=dict(method=["PUT"]))
super(API, self).__init__(mapper)

9
heat/api/v1/stacks.py

@ -253,13 +253,14 @@ class StackController(object):
for s in stack_db:
mem = {}
mem['StackId'] = stack_db[s]['StackId']
mem['StackStatus'] = 'happy'
mem['StackName'] = s
mem['CreationTime'] = 'now'
try:
mem['TemplateDescription'] = stack_db[s]['Description']
mem['StackStatus'] = stack_db[s]['StackStatus']
except:
mem['TemplateDescription'] = 'No description'
mem['StackStatus'] = 'unknown'
summaries.append(mem)
return res
@ -379,6 +380,12 @@ class StackController(object):
:raises HttpNotAuthorized if object is not
deleteable by the requesting user
"""
logger.info('in delete %s ' % req.params['StackName']
if not stack_db.has_key(req.params['StackName']):
msg = _("Stack does not exist with that name.")
return webob.exc.HTTPNotFound(msg)
del stack_db[req.params['StackName']]
def create_resource(options):
"""Stacks resource factory method"""

9
heat/client.py

@ -72,11 +72,16 @@ class V1Client(base_client.BaseClient):
return data
def update_stack(self, **kwargs):
return
params = self._extract_params(kwargs, SUPPORTED_PARAMS)
self._insert_common_parameters(params)
res = self.do_request("PUT", "/UpdateStack", params=params)
data = json.loads(res.read())
return data
def delete_stack(self, **kwargs):
self._insert_common_parameters(params)
params = self._extract_params(kwargs, SUPPORTED_PARAMS)
self._insert_common_parameters(params)
self.do_request("DELETE", "/DeleteStack", params)
return True

Loading…
Cancel
Save