From: Tony Mack Date: Sat, 1 Dec 2012 00:41:57 +0000 (-0500) Subject: remove sliver allocation record when deleting slivers X-Git-Tag: sfa-3.0-0~80 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=fc2a216091686513bcd89006108b3b43a0527be8;p=sfa.git remove sliver allocation record when deleting slivers --- diff --git a/sfa/planetlab/plaggregate.py b/sfa/planetlab/plaggregate.py index 6f1a0d22..b24e5a2f 100644 --- a/sfa/planetlab/plaggregate.py +++ b/sfa/planetlab/plaggregate.py @@ -374,8 +374,12 @@ class PlAggregate: continue rspec_node = self.sliver_to_rspec_node(sliver, sites, interfaces, node_tags, pl_initscripts) geni_sliver = self.rspec_node_to_geni_sliver(rspec_node) - sliver_allocation = sliver_allocation_dict[sliver['sliver_id']] - geni_sliver['geni_allocation_status'] = sliver_allocation.allocation_state + sliver_allocation_record = sliver_allocation_dict.get(sliver['sliver_id']) + if sliver_allocation_record: + sliver_allocation = sliver_allocation.allocation_state + else: + sliver_allocation = 'geni_unallocated' + geni_sliver['geni_allocation_status'] = sliver_allocation rspec_nodes.append(rspec_node) geni_slivers.append(geni_sliver) rspec.version.add_nodes(rspec_nodes) diff --git a/sfa/planetlab/pldriver.py b/sfa/planetlab/pldriver.py index df4bb5fc..248bab16 100644 --- a/sfa/planetlab/pldriver.py +++ b/sfa/planetlab/pldriver.py @@ -700,14 +700,12 @@ class PlDriver (Driver): constraint = SliverAllocation.sliver_id.in_(sliver_ids) cur_sliver_allocations = dbsession.query(SliverAllocation).filter(constraint) for sliver_allocation in cur_sliver_allocations: - sliver_allocation.allocation_state = 'geni_unallocated' + dbsession.delete(sliver_allocation) dbsession.commit() finally: if peer: self.shell.BindObjectToPeer('slice', slice_id, peer, slice['peer_slice_id']) - - # prepare return struct geni_slivers = [] for node_id in node_ids: