X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=blobdiff_plain;f=sfa%2Fplanetlab%2Fpldriver.py;h=0978a576df3f5a1d5cdaaaa14c188171aa6b413d;hp=27c6b4bde321dd7e76d61aaa168f1d044e506829;hb=b54e90d0c3868fa5afb89ff784cba0d5d36265ad;hpb=97dae512edca86d6f4ff892a64383d934abe7aa0 diff --git a/sfa/planetlab/pldriver.py b/sfa/planetlab/pldriver.py index 27c6b4bd..0978a576 100644 --- a/sfa/planetlab/pldriver.py +++ b/sfa/planetlab/pldriver.py @@ -10,7 +10,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 @@ -45,8 +44,9 @@ class PlDriver (Driver): # the cache instance is a class member so it survives across incoming requests cache = None - def __init__ (self, config): - Driver.__init__ (self, config) + def __init__ (self, api): + Driver.__init__ (self, api) + config=api.config self.shell = PlShell (config) self.cache=None if config.SFA_AGGREGATE_CACHING: @@ -508,7 +508,7 @@ class PlDriver (Driver): # get the registry records person_list, persons = [], {} - person_list = dbsession.query (RegRecord).filter(RegRecord.pointer.in_(person_ids)) + person_list = self.api.dbsession().query (RegRecord).filter(RegRecord.pointer.in_(person_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. @@ -687,7 +687,8 @@ class PlDriver (Driver): slices.handle_peer(None, None, persons, peer) # 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) @@ -726,7 +727,8 @@ class PlDriver (Driver): self.shell.DeleteLeases(leases_ids) # delete sliver allocation states - SliverAllocation.delete_allocations(sliver_ids) + dbsession=self.api.dbsession() + SliverAllocation.delete_allocations(sliver_ids,dbsession) finally: if peer: self.shell.BindObjectToPeer('slice', slice_id, peer, slice['peer_slice_id'])