iotlab driver: updated the Allocate function to work with the iotlab testbed using OAR
Loic Baron [Fri, 30 May 2014 14:58:57 +0000 (16:58 +0200)]
sfa/iotlab/iotlabaggregate.py
sfa/iotlab/iotlabdriver.py
sfa/iotlab/iotlabshell.py
sfa/iotlab/iotlabslices.py

index 3c708aa..34eb38f 100644 (file)
@@ -406,7 +406,7 @@ class IotlabAggregate:
            filter.update({'name':slice['slice_name']})
         #return_fields = ['lease_id', 'hostname', 'site_id', 'name', 't_from', 't_until']
         leases = self.driver.GetLeases(lease_filter_dict=filter)
-        grain = self.driver.GetLeaseGranularity()
+        grain = self.driver.testbed_shell.GetLeaseGranularity()
   
         rspec_leases = []
         for lease in leases:
@@ -842,4 +842,4 @@ class IotlabAggregate:
 
         return {'geni_urn': geni_urn,
                 'geni_rspec': rspec.toxml(),
-                'geni_slivers': geni_slivers}
\ No newline at end of file
+                'geni_slivers': geni_slivers}
index 03ecca5..eea909c 100644 (file)
@@ -1424,15 +1424,21 @@ class IotlabDriver(Driver):
         sfa_peer = slices.get_sfa_peer(xrn.get_hrn())
 
 
-        slice_record = None
+        slice_record = {}
         users = options.get('geni_users', [])
 
         sfa_users = options.get('sfa_users', [])
         if sfa_users:
-            slice_record = sfa_users[0].get('slice_record', [])
+            # XXX Always empty ??? no slice_record in the Allocate call
+            #slice_record = sfa_users[0].get('slice_record', [])
+            user_xrn = Xrn(sfa_users[0]['urn'])
+            user_hrn = user_xrn.get_hrn()
+
+            slice_record = sfa_users[0].get('slice_record', {})
             slice_record['user'] = {'keys': users[0]['keys'],
                                     'email': users[0]['email'],
-                                    'hrn': slice_record['reg-researchers'][0]}
+                                    'hrn': user_hrn}
+            slice_record['authority'] = xrn.get_authority_hrn() 
 
         logger.debug("IOTLABDRIVER.PY \t urn %s allocate options  %s "
                      % (urn, options))
@@ -1453,8 +1459,10 @@ class IotlabDriver(Driver):
         # oui c'est degueulasse, le slice_record se retrouve modifie
         # dans la methode avec les infos du user, els infos sont propagees
         # dans verify_slice_leases
+        logger.debug("IOTLABDRIVER.PY  BEFORE slices.verify_persons")
         persons = slices.verify_persons(xrn.hrn, slice_record, users,
                                         options=options)
+        logger.debug("IOTLABDRIVER.PY  AFTER slices.verify_persons")
         # ensure slice attributes exists
         # slices.verify_slice_attributes(slice, requested_attributes,
                                     # options=options)
@@ -1487,7 +1495,10 @@ class IotlabDriver(Driver):
             client_id = hostname
             node_urn = xrn_object(self.testbed_shell.root_auth, hostname).urn
             component_id = node_urn
-            slice_urn = current_slice['reg-urn']
+            if 'reg-urn' in current_slice:
+                slice_urn = current_slice['reg-urn']
+            else:
+                slice_urn = current_slice['urn']
             for lease in leases:
                 if hostname in lease['reserved_nodes']:
                     index = lease['reserved_nodes'].index(hostname)
index 896e4d6..25aba10 100644 (file)
@@ -560,10 +560,12 @@ class IotlabShell():
         #They will be set to None.
         if lease_dict['lease_start_time'] is not '0':
             #Readable time accepted by OAR
+            # converting timestamp to date in the local timezone tz = None 
             start_time = datetime.fromtimestamp( \
-                int(lease_dict['lease_start_time'])).\
+                int(lease_dict['lease_start_time']), tz=None).\
                 strftime(lease_dict['time_format'])
-            reqdict['reservation'] = start_time
+
+            reqdict['reservation'] = str(start_time)
         #If there is not start time, Immediate XP. No need to add special
         # OAR parameters
 
@@ -594,7 +596,11 @@ class IotlabShell():
         lease_dict['slice_name'] = slice_name
         lease_dict['slice_user'] = slice_user
         lease_dict['grain'] = self.GetLeaseGranularity()
-        lease_dict['time_format'] = self.time_format
+        # I don't know why the SFATIME_FORMAT has changed...
+        # from sfa.util.sfatime import SFATIME_FORMAT
+        # Let's use a fixed format %Y-%m-%d %H:%M:%S
+        #lease_dict['time_format'] = self.time_format
+        lease_dict['time_format'] = '%Y-%m-%d %H:%M:%S'
 
 
         logger.debug("IOTLAB_API.PY \tLaunchExperimentOnOAR slice_user %s\
index 80b4f47..e486624 100644 (file)
@@ -336,8 +336,8 @@ class IotlabSlices:
                          'authority': slice_record['authority'],
                          'gid': slice_record['gid'],
                          'slice_id': slice_record['record_id'],
-                         'reg-researchers': slice_record['reg-researchers'],
-                         'peer_authority': str(sfa_peer)
+                         #'reg-researchers': slice_record['reg-researchers'],
+                         #'peer_authority': str(sfa_peer)
                          }
 
             if ldap_user: