From fc2a216091686513bcd89006108b3b43a0527be8 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Fri, 30 Nov 2012 19:41:57 -0500 Subject: [PATCH] remove sliver allocation record when deleting slivers --- sfa/planetlab/plaggregate.py | 8 ++++++-- sfa/planetlab/pldriver.py | 4 +--- 2 files changed, 7 insertions(+), 5 deletions(-) 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: -- 2.43.0