iotlab driver fixed for OneLab in Production
[sfa.git] / sfa / iotlab / iotlabshell.py
index ba62ca9..830da14 100644 (file)
@@ -7,6 +7,7 @@ holding information about which slice is running which job.
 from datetime import datetime
 
 from sfa.util.sfalogging import logger
+from sfa.util.sfatime import SFATIME_FORMAT
 
 from sfa.iotlab.OARrestapi import OARrestapi
 from sfa.iotlab.LDAPapi import LDAPapi
@@ -30,7 +31,7 @@ class IotlabShell():
         # self.leases_db = TestbedAdditionalSfaDB(config)
         self.oar = OARrestapi()
         self.ldap = LDAPapi()
-        self.time_format = "%Y-%m-%d %H:%M:%S"
+        self.time_format = SFATIME_FORMAT
         self.root_auth = config.SFA_REGISTRY_ROOT_AUTH
         self.grain = 60  # 10 mins lease minimum, 60 sec granularity
         #import logging, logging.handlers
@@ -68,8 +69,8 @@ class IotlabShell():
         :rtype: list of dicts
 
         """
-        logger.debug("IOTLAB_API \tGetPersons person_filter %s"
-                     % (person_filter))
+        logger.debug("IOTLAB_API \tGetPersons 1st person_filter %s"
+                     % (person_filter[0]['hrn']))
         person_list = []
         if person_filter and isinstance(person_filter, list):
         #If we are looking for a list of users (list of dict records)
@@ -497,7 +498,9 @@ class IotlabShell():
             # Put the duration in seconds first
             #desired_walltime = duration * 60
             desired_walltime = duration
-            total_walltime = desired_walltime + 240 #+4 min Update SA 23/10/12
+            # JORDAN : removed the 4 minutes added by default in iotlab
+            # XXX total_walltime = desired_walltime + 240 #+4 min Update SA 23/10/12
+            total_walltime = desired_walltime # Needed to have slots aligned in MySlice (temp fix) # JA 11/07/2014
             sleep_walltime = desired_walltime  # 0 sec added Update SA 23/10/12
             walltime = []
             #Put the walltime back in str form
@@ -559,10 +562,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
 
@@ -593,7 +598,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\