remove sliver allocation record when deleting slivers
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Sat, 1 Dec 2012 00:41:57 +0000 (19:41 -0500)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Sat, 1 Dec 2012 00:41:57 +0000 (19:41 -0500)
sfa/planetlab/plaggregate.py
sfa/planetlab/pldriver.py

index 6f1a0d2..b24e5a2 100644 (file)
@@ -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)
index df4bb5f..248bab1 100644 (file)
@@ -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: