From: Mohamed Larabi Date: Mon, 18 Nov 2013 09:44:50 +0000 (+0100) Subject: apply dbsession changes on v2_to_v3_adapter X-Git-Tag: sfa-3.1-1~26 X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=commitdiff_plain;h=4ecbd8d52c08fc2660b903f8caf3c6a339540024 apply dbsession changes on v2_to_v3_adapter --- diff --git a/sfa/managers/v2_to_v3_adapter.py b/sfa/managers/v2_to_v3_adapter.py index e29b4cde..3ed22765 100644 --- a/sfa/managers/v2_to_v3_adapter.py +++ b/sfa/managers/v2_to_v3_adapter.py @@ -7,8 +7,6 @@ from sfa.util.xrn import Xrn, urn_to_hrn, hrn_to_urn, get_leaf, get_authority from sfa.util.cache import Cache from sfa.rspecs.rspec import RSpec from sfa.storage.model import SliverAllocation -# xxx 1-dbsession-per-request -from sfa.storage.alchemy import dbsession class V2ToV3Adapter: @@ -58,7 +56,7 @@ class V2ToV3Adapter: else: constraint = SliverAllocation.sliver_id.in_(urns) - sliver_allocations = dbsession.query (SliverAllocation).filter (constraint) + sliver_allocations = self.driver.api.dbsession().query (SliverAllocation).filter (constraint) sliver_status = getattr(self.driver, "sliver_status")(slice_urn, slice_hrn) if 'geni_expires' in sliver_status.keys(): geni_expires = sliver_status['geni_expires'] @@ -126,6 +124,7 @@ class V2ToV3Adapter: else: constraint = SliverAllocation.sliver_id.in_(urns) + dbsession = self.driver.api.dbsession() sliver_allocations = dbsession.query (SliverAllocation).filter(constraint) for sliver_allocation in sliver_allocations: sliver_allocation.allocation_state = 'geni_provisioned' @@ -161,9 +160,10 @@ class V2ToV3Adapter: #SliverAllocation constraints = SliverAllocation.slice_urn.in_(urns) + dbsession = self.driver.api.dbsession() sliver_allocations = dbsession.query(SliverAllocation).filter(constraints) sliver_ids = [sliver_allocation.sliver_id for sliver_allocation in sliver_allocations] - SliverAllocation.delete_allocations(sliver_ids) + SliverAllocation.delete_allocations(sliver_ids, dbsession) elif name == "renew":