From 307b25272cc7ed15da0bb3a69606e1d0f6c603b8 Mon Sep 17 00:00:00 2001 From: Mohamed Larabi Date: Tue, 12 Nov 2013 11:13:23 +0100 Subject: [PATCH] Apply dbsession changes on dummy driver --- sfa/dummy/dummyaggregate.py | 3 +-- sfa/dummy/dummydriver.py | 15 ++++++++------- sfa/dummy/dummyslices.py | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sfa/dummy/dummyaggregate.py b/sfa/dummy/dummyaggregate.py index dca47b59..c6381a61 100644 --- a/sfa/dummy/dummyaggregate.py +++ b/sfa/dummy/dummyaggregate.py @@ -19,7 +19,6 @@ from sfa.rspecs.version_manager import VersionManager from sfa.dummy.dummyxrn import DummyXrn, hostname_to_urn, hrn_to_dummy_slicename, slicename_to_hrn -from sfa.storage.alchemy import dbsession from sfa.storage.model import SliverAllocation import time @@ -243,7 +242,7 @@ class DummyAggregate: geni_urn = urns[0] sliver_ids = [sliver['sliver_id'] for sliver in slivers] constraint = SliverAllocation.sliver_id.in_(sliver_ids) - sliver_allocations = dbsession.query(SliverAllocation).filter(constraint) + sliver_allocations = self.driver.api.dbsession().query(SliverAllocation).filter(constraint) sliver_allocation_dict = {} for sliver_allocation in sliver_allocations: geni_urn = sliver_allocation.slice_urn diff --git a/sfa/dummy/dummydriver.py b/sfa/dummy/dummydriver.py index 0d0514e8..786ce145 100644 --- a/sfa/dummy/dummydriver.py +++ b/sfa/dummy/dummydriver.py @@ -11,7 +11,6 @@ from sfa.util.xrn import Xrn, hrn_to_urn, get_leaf from sfa.util.cache import Cache # one would think the driver should not need to mess with the SFA db, but.. -from sfa.storage.alchemy import dbsession from sfa.storage.model import RegRecord, SliverAllocation from sfa.trust.credential import Credential @@ -44,9 +43,9 @@ class DummyDriver (Driver): # the cache instance is a class member so it survives across incoming requests cache = None - def __init__ (self, config): - Driver.__init__ (self, config) - self.config = config + def __init__ (self, api): + Driver.__init__ (self, api) + config = api.config self.hrn = config.SFA_INTERFACE_HRN self.root_auth = config.SFA_REGISTRY_ROOT_AUTH self.shell = DummyShell (config) @@ -336,7 +335,7 @@ class DummyDriver (Driver): # get the registry records user_list, users = [], {} - user_list = dbsession.query (RegRecord).filter(RegRecord.pointer.in_(user_ids)) + user_list = self.api.dbsession().query (RegRecord).filter(RegRecord.pointer.in_(user_ids)) # create a hrns keyed on the sfa record's pointer. # Its possible for multiple records to have the same pointer so # the dict's value will be a list of hrns. @@ -464,7 +463,8 @@ class DummyDriver (Driver): #users = slices.verify_users(None, slice, geni_users, options=options) # update sliver allocation states and set them to geni_provisioned sliver_ids = [sliver['sliver_id'] for sliver in slivers] - SliverAllocation.set_allocations(sliver_ids, 'geni_provisioned') + dbsession=self.api.dbsession() + SliverAllocation.set_allocations(sliver_ids, 'geni_provisioned',dbsession) version_manager = VersionManager() rspec_version = version_manager.get_version(options['geni_rspec_version']) return self.describe(urns, rspec_version, options=options) @@ -490,7 +490,8 @@ class DummyDriver (Driver): try: self.shell.DeleteSliceFromNodes({'slice_id': slice_id, 'node_ids': node_ids}) # delete sliver allocation states - SliverAllocation.delete_allocations(sliver_ids) + dbsession=self.api.dbsession() + SliverAllocation.delete_allocations(sliver_ids,dbsession) finally: pass diff --git a/sfa/dummy/dummyslices.py b/sfa/dummy/dummyslices.py index 77850317..cf5a6da9 100644 --- a/sfa/dummy/dummyslices.py +++ b/sfa/dummy/dummyslices.py @@ -106,7 +106,7 @@ class DummySlices: component_id=component_id, slice_urn = slice_urn, allocation_state='geni_allocated') - record.sync() + record.sync(self.driver.api.dbsession()) return resulting_nodes -- 2.47.0