from sfa.storage.alchemy import dbsession
from sqlalchemy.orm import joinedload
from sfa.storage.model import RegRecord, RegUser, RegSlice, RegKey
-from sfa.iotlab.iotlabpostgres import TestbedAdditionalSfaDB, TestbedXP
+from sfa.iotlab.iotlabpostgres import TestbedAdditionalSfaDB, LeaseTableXP
from sfa.iotlab.OARrestapi import OARrestapi
from sfa.iotlab.LDAPapi import LDAPapi
"""
return self.oar.parser.SendRequest("GET_running_jobs")
- def __get_hostnames_from_oar_node_ids(self, resource_id_list ):
+ def __get_hostnames_from_oar_node_ids(self, oar_id_node_dict,
+ resource_id_list ):
"""Get the hostnames of the nodes from their OAR identifiers.
Get the list of nodes dict using GetNodes and find the hostname
associated with the identifier.
+ :param oar_id_node_dict: full node dictionary list keyed by oar node id
:param resource_id_list: list of nodes identifiers
:returns: list of node hostnames.
"""
- full_nodes_dict_list = self.GetNodes()
- #Put the full node list into a dictionary keyed by oar node id
- oar_id_node_dict = {}
- for node in full_nodes_dict_list:
- oar_id_node_dict[node['oar_id']] = node
hostname_list = []
for resource_id in resource_id_list:
self.oar.parser.SendRequest("GET_reserved_nodes", \
username = username)
+ # Get the full node dict list once for all
+ # so that we can get the hostnames given their oar node id afterwards
+ # when the reservations are checked.
+ full_nodes_dict_list = self.GetNodes()
+ #Put the full node list into a dictionary keyed by oar node id
+ oar_id_node_dict = {}
+ for node in full_nodes_dict_list:
+ oar_id_node_dict[node['oar_id']] = node
for resa in reservation_dict_list:
logger.debug ("GetReservedNodes resa %s"%(resa))
#dict list of hostnames and their site
resa['reserved_nodes'] = \
- self.__get_hostnames_from_oar_node_ids(resa['resource_ids'])
+ self.__get_hostnames_from_oar_node_ids(oar_id_node_dict,
+ resa['resource_ids'])
#del resa['resource_ids']
return reservation_dict_list
logger.debug("IOTLAB_API \r\n \r\n \t AddLeases %s %s %s " \
%(type(slice_record['hrn']), type(job_id), type(end_time)))
- iotlab_ex_row = TestbedXP(slice_hrn = slice_record['hrn'], job_id=job_id,
+ iotlab_ex_row = LeaseTableXP(slice_hrn = slice_record['hrn'], experiment_id=job_id,
end_time= end_time)
logger.debug("IOTLAB_API \r\n \r\n \t AddLeases iotlab_ex_row %s" \
# deleted_jobs = set_jobs_psql.difference(kept_jobs)
# deleted_jobs = list(deleted_jobs)
# if len(deleted_jobs) > 0:
- # self.iotlab_db.testbed_session.query(TestbedXP).filter(TestbedXP.job_id.in_(deleted_jobs)).delete(synchronize_session='fetch')
+ # self.iotlab_db.testbed_session.query(LeaseTableXP).filter(LeaseTableXP.job_id.in_(deleted_jobs)).delete(synchronize_session='fetch')
# self.iotlab_db.testbed_session.commit()
# return
return filtered_reservation_list
+
def GetLeases(self, lease_filter_dict=None, login=None):
"""
#the same user in LDAP SA 27/07/12
job_oar_list = []
- jobs_psql_query = self.iotlab_db.testbed_session.query(TestbedXP).all()
- jobs_psql_dict = dict([(row.job_id, row.__dict__)
+ jobs_psql_query = self.iotlab_db.testbed_session.query(LeaseTableXP).all()
+ jobs_psql_dict = dict([(row.experiment_id, row.__dict__)
for row in jobs_psql_query])
#jobs_psql_dict = jobs_psql_dict)
logger.debug("IOTLAB_API \tGetLeases jobs_psql_dict %s"
% (jobs_psql_dict))
- jobs_psql_id_list = [row.job_id for row in jobs_psql_query]
+ jobs_psql_id_list = [row.experiment_id for row in jobs_psql_query]
for resa in unfiltered_reservation_list:
logger.debug("IOTLAB_API \tGetLeases USER %s"