pagkage /etc/sfa/api_versions.xml
[sfa.git] / sfa / planetlab / plslices.py
index 16d9bc3..ec60f36 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
@@ -371,11 +372,12 @@ class PlSlices:
         
         return site        
 
-    def verify_slice(self, slice_hrn, slice_record, peer, sfa_peer, options={}):
+    def verify_slice(self, slice_hrn, slice_record, peer, sfa_peer, expiration, options={}):
         slicename = hrn_to_pl_slicename(slice_hrn)
         parts = slicename.split("_")
         login_base = parts[0]
         slices = self.driver.shell.GetSlices([slicename]) 
+        expires = int(datetime_to_epoch(utcparse(expiration)))
         if not slices:
             slice = {'name': slicename,
                      'url': 'No Url', 
@@ -385,18 +387,19 @@ class PlSlices:
             slice['node_ids'] = []
             slice['person_ids'] = []
             if peer and slice_record:
-                slice['peer_slice_id'] = slice_record.get('slice_id', None) 
+                slice['peer_slice_id'] = slice_record.get('slice_id', None)
+            # set the expiration
+            self.driver.shell.UpdateSlice(slice['slice_id'], {'expires': expires}) 
         else:
             slice = slices[0]
             if peer and slice_record:
                 slice['peer_slice_id'] = slice_record.get('slice_id', None)
                 # unbind from peer so we can modify if necessary. Will bind back later
                 self.driver.shell.UnBindObjectFromPeer('slice', slice['slice_id'], peer['shortname'])
-               #Update existing record (e.g. expires field) it with the latest info.
-            if slice_record and slice_record.get('expires'):
-                requested_expires = int(datetime_to_epoch(utcparse(slice_record['expires'])))
-                if requested_expires and slice['expires'] != requested_expires:
-                    self.driver.shell.UpdateSlice( slice['slice_id'], {'expires' : requested_expires})
+            
+               #Update expiration if necessary
+            if slice['expires'] != expires:
+                self.driver.shell.UpdateSlice( slice['slice_id'], {'expires' : expires})
        
         return slice