Fixing granularity, now set to 60 seconds.
authorSandrine Avakian <sandrine.avakian@inria.fr>
Wed, 11 Sep 2013 09:16:50 +0000 (11:16 +0200)
committerMohamed Larabi <mohamed.larabi@inria.fr>
Mon, 16 Sep 2013 13:58:36 +0000 (15:58 +0200)
Changing minimal experiment time, set to 10 units of granularity
(still 10 minutes).
Fixing Rspec returns all leases when a slice xrn is specified
and options leases and all are used in the request.

sfa/iotlab/iotlabaggregate.py
sfa/iotlab/iotlabapi.py
sfa/iotlab/iotlabdriver.py
sfa/iotlab/iotlabslices.py

index c17418b..9831973 100644 (file)
@@ -279,13 +279,16 @@ class IotlabAggregate:
 
         return (rspec_nodes)
 
-    def get_all_leases(self):
+    def get_all_leases(self, ldap_username):
         """
 
         Get list of lease dictionaries which all have the mandatory keys
         ('lease_id', 'hostname', 'site_id', 'name', 'start_time', 'duration').
         All the leases running or scheduled are returned.
 
+        :param ldap_username: if a ldap uid is not None, looks for the leases
+        belonging to this user.
+        :type ldap_username: string
         :returns: rspec lease dictionary with keys lease_id, component_id,
             slice_id, start_time, duration.
         :rtype: dict
@@ -304,7 +307,10 @@ class IotlabAggregate:
             #lease_filter.update({'name': slice_record['name']})
 
         #leases = self.driver.iotlab_api.GetLeases(lease_filter)
-        leases = self.driver.iotlab_api.GetLeases()
+
+        logger.debug("IOTLABAGGREGATE  get_all_leases ldap_username %s "
+                     % (ldap_username))
+        leases = self.driver.iotlab_api.GetLeases(ldap_username)
         grain = self.driver.iotlab_api.GetLeaseGranularity()
         # site_ids = []
         rspec_leases = []
@@ -326,7 +332,7 @@ class IotlabAggregate:
                     pass
                 rspec_lease['start_time'] = lease['t_from']
                 rspec_lease['duration'] = (lease['t_until'] - lease['t_from']) \
-                    * grain
+                    * grain
                 rspec_leases.append(rspec_lease)
         return rspec_leases
 
@@ -351,11 +357,12 @@ class IotlabAggregate:
         :type options: dict
 
         :returns: Xml Rspec.
-        :rtype: XML
+        :rtype: XMLf
 
 
         """
 
+        ldap_username= None
         rspec = None
         version_manager = VersionManager()
         version = version_manager.get_version(version)
@@ -404,11 +411,13 @@ class IotlabAggregate:
             if slice_xrn and slices is not None:
                 #Get user associated with this slice
                 #for one_slice in slices :
-                ldap_username = slices[0]['hrn']
-                tmp = ldap_username.split('.')
-                ldap_username = tmp[1].split('_')[0]
+                # ldap_username = slices[0]['hrn']
+                # tmp = ldap_username.split('.')
+                # ldap_username = tmp[1].split('_')[0]
+                ldap_username = slices[0]['user']
                 logger.debug("IotlabAggregate \tget_rspec **** \
-                        version type %s \r\n" % (version.type))
+                        version type %s ldap_ user %s \r\n" \
+                        % (version.type, ldap_username))
                 if version.type == "Iotlab":
                     rspec.version.add_connection_information(
                         ldap_username, sites_set)
@@ -423,7 +432,7 @@ class IotlabAggregate:
                         attrib, default_sliver[attrib])
 
         if lease_option in ['all','leases']:
-            leases = self.get_all_leases()
+            leases = self.get_all_leases(ldap_username)
             rspec.version.add_leases(leases)
             logger.debug("IotlabAggregate \tget_rspec **** \
                        FINAL RSPEC %s \r\n" % (rspec.toxml()))
index ab807df..50592bd 100644 (file)
@@ -26,7 +26,7 @@ from sfa.iotlab.iotlabaggregate import iotlab_xrn_object
 class IotlabTestbedAPI():
     """ Class enabled to use LDAP and OAR api calls. """
 
-    _MINIMUM_DURATION = 600
+    _MINIMUM_DURATION = 10  # 10 units of granularity 60 s, 10 mins
 
     def __init__(self, config):
         """Creates an instance of OARrestapi and LDAPapi which will be used to
@@ -50,7 +50,7 @@ class IotlabTestbedAPI():
         return
 
     @staticmethod
-    def GetMinExperimentDurationInSec():
+    def GetMinExperimentDurationInGranularity():
         """ Returns the minimum allowed duration for an experiment on the
         testbed. In seconds.
 
@@ -930,7 +930,7 @@ class IotlabTestbedAPI():
 
         """
 
-        unfiltered_reservation_list = self.GetReservedNodes()
+        unfiltered_reservation_list = self.GetReservedNodes(login)
 
         reservation_list = []
         #Find the slice associated with this user iotlab ldap uid
index c8d5617..84c8a46 100644 (file)
@@ -3,7 +3,7 @@ Implements what a driver should provide for SFA to work.
 """
 from sfa.util.faults import SliverDoesNotExist, UnknownSfaType
 from sfa.util.sfalogging import logger
-from sfa.storage.alchemy import dbsession
+from sfa.storage.alchemy import dbsession
 from sfa.storage.model import RegRecord
 
 from sfa.managers.driver import Driver
@@ -376,7 +376,7 @@ class IotlabDriver(Driver):
                     #the lease to the requested leases list
                     duration_in_seconds = \
                         int(single_requested_lease['duration'])
-                    if duration_in_seconds >= self.iotlab_api.GetMinExperimentDurationInSec():
+                    if duration_in_seconds >= self.iotlab_api.GetMinExperimentDurationInGranularity():
                         requested_lease_list.append(single_requested_lease)
 
         return requested_lease_list
index 0fa6891..ccffec5 100644 (file)
@@ -130,6 +130,9 @@ class IotlabSlices:
 
         #First remove job whose duration is too short
         for job in requested_jobs_dict.values():
+            job['duration'] = \
+                str(int(job['duration']) \
+                * self.driver.iotlab_api.GetLeaseGranularity())
             if job['duration'] < self.driver.iotlab_api.GetLeaseGranularity():
                 del requested_jobs_dict[job['start_time']]