'''Implementation of SQLAlchemy backend.'''
from sqlalchemy.orm.session import Session
+from heat.common.exception import NotFound
from heat.db.sqlalchemy import models
from heat.db.sqlalchemy.session import get_session
filter_by(id=template_id).first()
if not result:
- raise Exception("raw template with id %s not found" % template_id)
+ raise NotFound("raw template with id %s not found" % template_id)
return result
results = model_query(context, models.RawTemplate).all()
if not results:
- raise Exception('no raw templates were found')
+ raise NotFound('no raw templates were found')
return results
results = model_query(context, models.ParsedTemplate).all()
if not results:
- raise Exception('no parsed templates were found')
+ raise NotFound('no parsed templates were found')
return results
filter_by(id=resource_id).first()
if not result:
- raise Exception("resource with id %s not found" % resource_id)
+ raise NotFound("resource with id %s not found" % resource_id)
return result
results = model_query(context, models.Resource).all()
if not results:
- raise Exception('no resources were found')
+ raise NotFound('no resources were found')
return results
filter_by(stack_id=stack_id).all()
if not results:
- raise Exception("no resources for stack_id %s were found" % stack_id)
+ raise NotFound("no resources for stack_id %s were found" % stack_id)
return results
def stack_delete(context, stack_name):
s = stack_get(context, stack_name)
if not s:
- raise Exception('Attempt to delete a stack with id: %s %s' %
+ raise NotFound('Attempt to delete a stack with id: %s %s' %
(stack_name, 'that does not exist'))
session = Session.object_session(s)
filter_by(name=watch_name).first()
if not wr:
- raise Exception('Attempt to delete a watch_rule with name: %s %s' %
+ raise NotFound('Attempt to delete a watch_rule with name: %s %s' %
(watch_name, 'that does not exist'))
session = Session.object_session(wr)
filter_by(name=watch_name).all()
if not ds:
- raise Exception('Attempt to delete watch_data with name: %s %s' %
+ raise NotFound('Attempt to delete watch_data with name: %s %s' %
(watch_name, 'that does not exist'))
session = Session.object_session(ds)
from novaclient.v1_1 import client as nc
from keystoneclient.v2_0 import client as kc
-from novaclient.exceptions import BadRequest
-from novaclient.exceptions import NotFound
-
from heat.common import exception
from heat.common.config import HeatEngineConfigOpts
from heat.db import api as db_api
else:
try:
db_api.resource_get(self.stack.context, self.id).delete()
- except Exception as ex:
+ except exception.NotFound:
# Don't fail on delete if the db entry has
# not been created yet.
- if 'not found' not in str(ex):
- self.state_set(self.DELETE_FAILED)
- logger.exception('Delete %s from DB' % str(self))
- return str(ex)
+ pass
+ except Exception as ex:
+ self.state_set(self.DELETE_FAILED)
+ logger.exception('Delete %s from DB' % str(self))
+ return str(ex)
self.state_set(self.DELETE_COMPLETE)