From: Angus Salkeld Date: Thu, 15 Mar 2012 11:24:42 +0000 (+1100) Subject: Hook up the update and delete (not quite working) X-Git-Tag: 2014.1~2208 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=a76d02e790357258f8f57a5b33a0d2fe794a3714;p=openstack-build%2Fheat-build.git Hook up the update and delete (not quite working) Signed-off-by: Angus Salkeld --- diff --git a/heat/api/v1/router.py b/heat/api/v1/router.py index 95432860..55ebeba8 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 a4746fd9..0fa8f2bb 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 837ccfbd..88dbf517 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