From 23726f803ba01042189133593d3bc9e408fc918b Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Wed, 11 Sep 2013 11:16:50 +0200 Subject: [PATCH] Fixing granularity, now set to 60 seconds. 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 | 27 ++++++++++++++++++--------- sfa/iotlab/iotlabapi.py | 6 +++--- sfa/iotlab/iotlabdriver.py | 4 ++-- sfa/iotlab/iotlabslices.py | 3 +++ 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/sfa/iotlab/iotlabaggregate.py b/sfa/iotlab/iotlabaggregate.py index c17418b0..9831973b 100644 --- a/sfa/iotlab/iotlabaggregate.py +++ b/sfa/iotlab/iotlabaggregate.py @@ -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())) diff --git a/sfa/iotlab/iotlabapi.py b/sfa/iotlab/iotlabapi.py index ab807df1..50592bd7 100644 --- a/sfa/iotlab/iotlabapi.py +++ b/sfa/iotlab/iotlabapi.py @@ -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 diff --git a/sfa/iotlab/iotlabdriver.py b/sfa/iotlab/iotlabdriver.py index c8d56178..84c8a462 100644 --- a/sfa/iotlab/iotlabdriver.py +++ b/sfa/iotlab/iotlabdriver.py @@ -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 diff --git a/sfa/iotlab/iotlabslices.py b/sfa/iotlab/iotlabslices.py index 0fa68910..ccffec57 100644 --- a/sfa/iotlab/iotlabslices.py +++ b/sfa/iotlab/iotlabslices.py @@ -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']] -- 2.43.0