From: Mohamed Larabi Date: Tue, 12 Nov 2013 10:29:52 +0000 (+0100) Subject: Apply dbsession changes on openstack driver X-Git-Tag: sfa-3.1-1~42^2~5 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=0d9b4d3f412bbf7406b748a8f75a3a00ddb2818a;p=sfa.git Apply dbsession changes on openstack driver --- diff --git a/sfa/openstack/nova_driver.py b/sfa/openstack/nova_driver.py index e0afd07f..e36946e6 100644 --- a/sfa/openstack/nova_driver.py +++ b/sfa/openstack/nova_driver.py @@ -15,7 +15,6 @@ from sfa.trust.credential import Credential #from sfa.trust.sfaticket import SfaTicket from sfa.rspecs.version_manager import VersionManager from sfa.rspecs.rspec import RSpec -from sfa.storage.alchemy import dbsession from sfa.storage.model import RegRecord, SliverAllocation # the driver interface, mostly provides default behaviours @@ -41,8 +40,9 @@ class NovaDriver(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 = Shell(config=config) self.cache=None if config.SFA_AGGREGATE_CACHING: @@ -396,7 +396,8 @@ class NovaDriver(Driver): # update all sliver allocation states setting then to geni_allocated sliver_ids = [sliver.id for sliver in slivers] - SliverAllocation.set_allocations(sliver_ids, 'geni_allocated') + dbsession=self.api.dbsession() + SliverAllocation.set_allocations(sliver_ids, 'geni_provisioned',dbsession) return aggregate.describe(urns=[urn], version=rspec.version) @@ -408,7 +409,8 @@ class NovaDriver(Driver): for instance in instances: sliver_hrn = "%s.%s" % (self.driver.hrn, instance.id) sliver_ids.append(Xrn(sliver_hrn, type='sliver').urn) - 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) @@ -427,7 +429,8 @@ class NovaDriver(Driver): aggregate.delete_instance(instance) # delete sliver allocation states - SliverAllocation.delete_allocations(sliver_ids) + dbsession=self.api.dbsession() + SliverAllocation.delete_allocations(sliver_ids, dbsession) # return geni_slivers geni_slivers = [] diff --git a/sfa/openstack/osaggregate.py b/sfa/openstack/osaggregate.py index 16eec41e..d6d73677 100644 --- a/sfa/openstack/osaggregate.py +++ b/sfa/openstack/osaggregate.py @@ -75,7 +75,7 @@ class OSAggregate: # lookup the sliver allocations 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: sliver_allocation_dict[sliver_allocation.sliver_id] = sliver_allocation