diff options
Diffstat (limited to 'heat/db/sqlalchemy/api.py')
-rw-r--r-- | heat/db/sqlalchemy/api.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/heat/db/sqlalchemy/api.py b/heat/db/sqlalchemy/api.py index c3f31ddfc..a33b39d12 100644 --- a/heat/db/sqlalchemy/api.py +++ b/heat/db/sqlalchemy/api.py @@ -164,7 +164,11 @@ def raw_template_update(context, template_id, values): def raw_template_delete(context, template_id): - raw_template = raw_template_get(context, template_id) + try: + raw_template = raw_template_get(context, template_id) + except exception.NotFound: + # Ignore not found + return raw_tmpl_files_id = raw_template.files_id session = context.session with session.begin(subtransactions=True): @@ -267,7 +271,7 @@ def resource_purge_deleted(context, stack_id): query = context.session.query(models.Resource) result = query.filter_by(**filters) attr_ids = [r.attr_data_id for r in result if r.attr_data_id is not None] - with context.session.begin(subtransactions=True): + with context.session.begin(): result.delete() if attr_ids: context.session.query(models.ResourcePropertiesData).filter( @@ -320,7 +324,7 @@ def resource_delete(context, resource_id): def resource_attr_id_set(context, resource_id, atomic_key, attr_id): session = context.session - with session.begin(subtransactions=True): + with session.begin(): values = {'attr_data_id': attr_id} _add_atomic_key_to_values(values, atomic_key) rows_updated = session.query(models.Resource).filter(and_( @@ -346,7 +350,7 @@ def resource_attr_id_set(context, resource_id, atomic_key, attr_id): def resource_attr_data_delete(context, resource_id, attr_id): session = context.session - with session.begin(subtransactions=True): + with session.begin(): resource = session.query(models.Resource).get(resource_id) attr_prop_data = session.query( models.ResourcePropertiesData).get(attr_id) @@ -468,7 +472,7 @@ def resource_exchange_stacks(context, resource_id1, resource_id2): def resource_data_delete(context, resource_id, key): result = resource_data_get_by_key(context, resource_id, key) session = context.session - with session.begin(subtransactions=True): + with session.begin(): session.delete(result) @@ -486,7 +490,7 @@ def resource_create_replacement(context, atomic_key, expected_engine_id=None): session = context.session try: - with session.begin(subtransactions=True): + with session.begin(): new_res = resource_create(context, new_res_values) update_data = {'replaced_by': new_res.id} update_data.update(existing_res_values) @@ -1267,7 +1271,7 @@ def software_deployment_update(context, deployment_id, values): def software_deployment_delete(context, deployment_id): deployment = software_deployment_get(context, deployment_id) session = context.session - with session.begin(subtransactions=True): + with session.begin(): session.delete(deployment) @@ -1631,7 +1635,7 @@ def _db_encrypt_or_decrypt_template_params( batch_size=batch_size) next_batch = list(itertools.islice(template_batches, batch_size)) while next_batch: - with session.begin(subtransactions=True): + with session.begin(): for raw_template in next_batch: try: if verbose: @@ -1714,7 +1718,7 @@ def _db_encrypt_or_decrypt_resource_prop_data_legacy( batch_size=batch_size) next_batch = list(itertools.islice(resource_batches, batch_size)) while next_batch: - with session.begin(subtransactions=True): + with session.begin(): for resource in next_batch: if not resource.properties_data: continue @@ -1761,7 +1765,7 @@ def _db_encrypt_or_decrypt_resource_prop_data( model=models.ResourcePropertiesData, batch_size=batch_size) next_batch = list(itertools.islice(rpd_batches, batch_size)) while next_batch: - with session.begin(subtransactions=True): + with session.begin(): for rpd in next_batch: if not rpd.data: continue |