store slice_urn in sliver_allocation table
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 10 Jan 2013 01:53:55 +0000 (20:53 -0500)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 10 Jan 2013 01:53:55 +0000 (20:53 -0500)
sfa/planetlab/plaggregate.py
sfa/planetlab/pldriver.py
sfa/planetlab/plslices.py
sfa/storage/model.py

index 1d06c4b..3e2d342 100644 (file)
@@ -363,11 +363,14 @@ class PlAggregate:
         rspec.xml.set('expires',  rspec_expires)
 
         # lookup the sliver allocations
+        geni_urn = None
         sliver_ids = [sliver['sliver_id'] for sliver in slivers]
         constraint = SliverAllocation.sliver_id.in_(sliver_ids)
         sliver_allocations = dbsession.query(SliverAllocation).filter(constraint)
         sliver_allocation_dict = {}
         for sliver_allocation in sliver_allocations:
+            if not geni_urn:
+                geni_urn = sliver_allocation.slice_urn
             sliver_allocation_dict[sliver_allocation.sliver_id] = sliver_allocation
       
         if not options.get('list_leases') or options['list_leases'] != 'leases':
@@ -415,6 +418,6 @@ class PlAggregate:
                 rspec.version.add_leases(leases)
 
                
-        return {'geni_urn': urns[0]
+        return {'geni_urn': geni_urn
                 'geni_rspec': rspec.toxml(),
                 'geni_slivers': geni_slivers}
index aaaa0cc..ac2e660 100644 (file)
@@ -645,7 +645,7 @@ class PlDriver (Driver):
        
         # add/remove slice from nodes
         request_nodes = rspec.version.get_nodes_with_slivers()
-        nodes = slices.verify_slice_nodes(slice, request_nodes, peer)
+        nodes = slices.verify_slice_nodes(urn, slice, request_nodes, peer)
          
         # add/remove links links 
         slices.verify_slice_links(slice, rspec.version.get_link_requests(), nodes)
index 16d9bc3..ae5847c 100644 (file)
@@ -180,7 +180,7 @@ class PlSlices:
         return leases
 
 
-    def verify_slice_nodes(self, slice, rspec_nodes, peer):
+    def verify_slice_nodes(self, slice_urn, slice, rspec_nodes, peer):
         
         slivers = {}
         for node in rspec_nodes:
@@ -222,7 +222,8 @@ class PlSlices:
             sliver_hrn = '%s.%s-%s' % (self.driver.hrn, slice['slice_id'], node['node_id'])
             sliver_id = Xrn(sliver_hrn, type='sliver').urn
             record = SliverAllocation(sliver_id=sliver_id, client_id=client_id, 
-                                      component_id=component_id, 
+                                      component_id=component_id,
+                                      slice_urn = slice_urn, 
                                       allocation_state='geni_allocated')      
             record.sync()
         return resulting_nodes
index 1535297..3f600d4 100644 (file)
@@ -317,6 +317,7 @@ class SliverAllocation(Base,AlchemyObj):
     sliver_id           = Column(String, primary_key=True)
     client_id           = Column(String)
     component_id        = Column(String)
+    slice_urn           = Column(String)
     allocation_state    = Column(String)
 
     def __init__(self, **kwds):
@@ -326,6 +327,8 @@ class SliverAllocation(Base,AlchemyObj):
             self.client_id = kwds['client_id']
         if 'component_id' in kwds:
             self.component_id = kwds['component_id']
+        if 'slice_urn' in kwds:
+            self.slice_urn = kwds['slice_urn']
         if 'allocation_state' in kwds:
             self.allocation_state = kwds['allocation_state']
 
@@ -389,6 +392,7 @@ class SliverAllocation(Base,AlchemyObj):
             record.sliver_id = self.sliver_id
             record.client_id  = self.client_id
             record.component_id  = self.component_id
+            record.slice_urn  = self.slice_urn
             record.allocation_state = self.allocation_state
         dbsession.commit()