~ubuntu-branches/ubuntu/trusty/heat/trusty

« back to all changes in this revision

Viewing changes to heat/api/aws/exception.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Adam Gandelman
  • Date: 2013-09-08 21:51:19 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20130908215119-r939tu4aumqgdrkx
Tags: 2013.2~b3-0ubuntu1
[ Chuck Short ]
* New upstream release.
* debian/control: Add python-netaddr as build-dep.
* debian/heat-common.install: Remove heat-boto and associated man-page
* debian/heat-common.install: Remove heat-cfn and associated man-page
* debian/heat-common.install: Remove heat-watch and associated man-page
* debian/patches/fix-sqlalchemy-0.8.patch: Dropped

[ Adam Gandelman ]
* debian/patches/default-kombu.patch: Dropped.
* debian/patches/default-sqlite.patch: Refreshed.
* debian/*.install, rules: Install heat.conf.sample as common
  config file in heat-common. Drop other per-package configs, they
  are no longer used.
* debian/rules: Clean pbr .egg from build dir if it exists.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
import webob.exc
21
21
from heat.common import wsgi
 
22
import heat.openstack.common.rpc.common as rpc_common
22
23
 
23
24
 
24
25
class HeatAPIException(webob.exc.HTTPError):
246
247
    err_type = "Server"
247
248
 
248
249
 
249
 
class HeatInvalidStateError(HeatAPIException):
250
 
    '''
251
 
    Cannot perform action on stack in its current state
252
 
    '''
253
 
    code = 400
254
 
    title = 'InvalidAction'
255
 
    explanation = "Cannot perform action on stack in its current state"
256
 
 
257
 
 
258
250
def map_remote_error(ex):
259
251
        """
260
252
        Map rpc_common.RemoteError exceptions returned by the engine
277
269
            'UserParameterMissing',
278
270
        )
279
271
        denied_errors = ('Forbidden', 'NotAuthorized')
280
 
        already_exists_errors = ('StackExists',)
281
 
        invalid_state_errors = ('ActionInProgress',)
282
 
 
283
 
        if ex.exc_type in inval_param_errors:
284
 
            return HeatInvalidParameterValueError(detail=ex.value)
285
 
        elif ex.exc_type in denied_errors:
286
 
            return HeatAccessDeniedError(detail=ex.value)
287
 
        elif ex.exc_type in already_exists_errors:
288
 
            return AlreadyExistsError(detail=ex.value)
289
 
        elif ex.exc_type in invalid_state_errors:
290
 
            return HeatInvalidStateError(detail=ex.value)
 
272
        already_exists_errors = ('StackExists')
 
273
 
 
274
        ex_type = ex.__class__.__name__
 
275
 
 
276
        if ex_type.endswith(rpc_common._REMOTE_POSTFIX):
 
277
            ex_type = ex_type[:-len(rpc_common._REMOTE_POSTFIX)]
 
278
 
 
279
        if ex_type in inval_param_errors:
 
280
            return HeatInvalidParameterValueError(detail=str(ex.message))
 
281
        elif ex_type in denied_errors:
 
282
            return HeatAccessDeniedError(detail=str(ex.message))
 
283
        elif ex_type in already_exists_errors:
 
284
            return AlreadyExistsError(detail=str(ex.message))
291
285
        else:
292
286
            # Map everything else to internal server error for now
293
 
            return HeatInternalFailureError(detail=ex.value)
 
287
            return HeatInternalFailureError(detail=str(ex.message))