From a76d02e790357258f8f57a5b33a0d2fe794a3714 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Thu, 15 Mar 2012 22:24:42 +1100 Subject: [PATCH] Hook up the update and delete (not quite working) Signed-off-by: Angus Salkeld --- heat/api/v1/router.py | 11 +++++------ heat/api/v1/stacks.py | 9 ++++++++- heat/client.py | 9 +++++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/heat/api/v1/router.py b/heat/api/v1/router.py index 95432860c8..55ebeba8f8 100644 --- a/heat/api/v1/router.py +++ b/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) diff --git a/heat/api/v1/stacks.py b/heat/api/v1/stacks.py index a4746fd963..0fa8f2bb27 100644 --- a/heat/api/v1/stacks.py +++ b/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""" diff --git a/heat/client.py b/heat/client.py index 837ccfbd07..88dbf517c5 100644 --- a/heat/client.py +++ b/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