+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
class IotlabImporter:
"""
IotlabImporter class, generic importer_class. Used to populate the SFA DB
with iotlab resources' records.
+=======
+class SlabImporter:
+ """
+ SlabImporter class, generic importer_class. Used to populate the SFA DB
+ with senslab resources' records.
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
Used to update records when new resources, users or nodes, are added
or deleted.
"""
return
self.records_by_type_hrn [ rec_tuple ] = record
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
def import_sites_and_nodes(self, iotlabdriver):
+=======
+ def import_sites_and_nodes(self, slabdriver):
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
"""
Gets all the sites and nodes from OAR, process the information,
For each site, import the site's nodes to the DB by calling
import_nodes.
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
:param iotlabdriver: IotlabDriver object, used to have access to iotlabdriver
methods and fetching info on sites and nodes.
:type iotlabdriver: IotlabDriver
sites_listdict = iotlabdriver.iotlab_api.GetSites()
nodes_listdict = iotlabdriver.iotlab_api.GetNodes()
+=======
+ :param slabdriver: SlabDriver object, used to have access to slabdriver
+ methods and fetching info on sites and nodes.
+ :type slabdriver: SlabDriver
+ """
+
+ sites_listdict = slabdriver.slab_api.GetSites()
+ nodes_listdict = slabdriver.slab_api.GetNodes()
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
nodes_by_id = dict([(node['node_id'], node) for node in nodes_listdict])
for site in sites_listdict:
site_hrn = site['name']
site_record.just_created()
dbsession.add(site_record)
dbsession.commit()
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
self.logger.info("IotlabImporter: imported authority (site) \
+=======
+ self.logger.info("SlabImporter: imported authority (site) \
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
%s" % site_record)
self.update_just_added_records_dict(site_record)
except SQLAlchemyError:
# if the site import fails then there is no point in
# trying to import the
# site's child records(node, slices, persons), so skip them.
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
self.logger.log_exc("IotlabImporter: failed to import site. \
+=======
+ self.logger.log_exc("SlabImporter: failed to import site. \
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
Skipping child records")
continue
else:
site_record.stale = False
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
self.import_nodes(site['node_ids'], nodes_by_id, iotlabdriver)
return
def import_nodes(self, site_node_ids, nodes_by_id, iotlabdriver):
+=======
+ self.import_nodes(site['node_ids'], nodes_by_id, slabdriver)
+
+ return
+
+ def import_nodes(self, site_node_ids, nodes_by_id, slabdriver):
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
"""
Creates appropriate hostnames and RegNode records for
:type nodes_by_id: dictionary
:param iotlabdriver:IotlabDriver object, used to have access to iotlabdriver
attributes.
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
:type iotlabdriver:IotlabDriver
+=======
+ :type slabdriver:SlabDriver
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
"""
escaped_hrn = \
self.hostname_to_hrn_escaped(iotlabdriver.iotlab_api.root_auth, \
node['hostname'])
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
self.logger.info("IOTLABIMPORTER node %s " %(node))
+=======
+ self.logger.info("SLABIMPORTER node %s " %(node))
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
hrn = node['hrn']
self.auth_hierarchy.create_gid(urn, \
create_uuid(), pkey)
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
def iotlab_get_authority(hrn):
+=======
+ def slab_get_authority(hrn):
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
return hrn.split(".")[0]
node_record = RegNode(hrn=hrn, gid=node_gid,
node_record.just_created()
dbsession.add(node_record)
dbsession.commit()
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
self.logger.info("IotlabImporter: imported node: %s" \
% node_record)
self.update_just_added_records_dict(node_record)
except SQLAlchemyError:
self.logger.log_exc("IotlabImporter: \
+=======
+ self.logger.info("SlabImporter: imported node: %s" \
+ % node_record)
+ self.update_just_added_records_dict(node_record)
+ except SQLAlchemyError:
+ self.logger.log_exc("SlabImporter: \
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
failed to import node")
else:
#TODO: xxx update the record ...
pass
node_record.stale = False
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
def init_person_key (self, person, iotlab_key):
+=======
+
+
+ def init_person_key (self, person, slab_key):
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
"""
Returns a tuple pubkey and pkey.
:param person Person's data.
:type person: dict
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
:param iotlab_key: SSH public key, from LDAP user's data.
+=======
+ :param slab_key: SSH public key, from LDAP user's data.
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
RSA type supported.
:type iotlab_key: string
:rtype (string, Keypair)
pubkey = None
if person['pkey']:
# randomly pick first key in set
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
pubkey = iotlab_key
+=======
+ pubkey = slab_key
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
try:
pkey = convert_public_key(pubkey)
return (pubkey, pkey)
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
def import_persons_and_slices(self, iotlabdriver):
+=======
+ def import_persons_and_slices(self, slabdriver):
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
"""
Gets user data from LDAP, process the information.
import the user's slice onto the database as well by calling
import_slice.
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
:param iotlabdriver:IotlabDriver object, used to have access to iotlabdriver
+=======
+ :param slabdriver:SlabDriver object, used to have access to slabdriver
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
attributes.
:type iotlabdriver:IotlabDriver
"""
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
ldap_person_listdict = iotlabdriver.iotlab_api.GetPersons()
self.logger.info("IOTLABIMPORT \t ldap_person_listdict %s \r\n" \
+=======
+ ldap_person_listdict = slabdriver.slab_api.GetPersons()
+ self.logger.info("SLABIMPORT \t ldap_person_listdict %s \r\n" \
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
%(ldap_person_listdict))
# import persons
for person in ldap_person_listdict :
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
self.logger.info("IotlabImporter: person :" %(person))
+=======
+ self.logger.info("SlabImporter: person :" %(person))
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
if 'ssh-rsa' not in person['pkey']:
#people with invalid ssh key (ssh-dss, empty, bullshit keys...)
#won't be imported
person_urn = hrn_to_urn(person_hrn, 'user')
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
self.logger.info("IotlabImporter: users_rec_by_email %s " \
+=======
+ self.logger.info("SlabImporter: users_rec_by_email %s " \
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
%(self.users_rec_by_email))
#Check if user using person['email'] from LDAP is already registered
#in SFA. One email = one person. In this case, do not create another
#record for this person
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
#person_hrn returned by GetPerson based on iotlab root auth +
+=======
+ #person_hrn returned by GetPerson based on senslab root auth +
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
#uid ldap
user_record = self.find_record_by_type_hrn('user', person_hrn)
slice_record = self.find_record_by_type_hrn ('slice', slice_hrn)
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
iotlab_key = person['pkey']
+=======
+ slab_key = person['pkey']
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
# new person
if not user_record:
(pubkey, pkey) = self.init_person_key(person, iotlab_key)
self.update_just_added_records_dict( user_record )
except SQLAlchemyError:
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
self.logger.log_exc("IotlabImporter: \
+=======
+ self.logger.log_exc("SlabImporter: \
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
failed to import person %s"%(person))
else:
# update the record ?
sfa_keys = user_record.reg_keys
new_key = False
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
if iotlab_key is not sfa_keys :
+=======
+ if slab_key is not sfa_keys :
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
new_key = True
if new_key:
self.logger.info("IotlabImporter: \t \t USER UPDATE \
dbsession.commit()
user_record.stale = False
except SQLAlchemyError:
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
self.logger.log_exc("IotlabImporter: \
+=======
+ self.logger.log_exc("SlabImporter: \
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
failed to update person %s"%(person))
self.import_slice(slice_hrn, slice_record, user_record)
self.update_just_added_records_dict ( slice_record )
except SQLAlchemyError:
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
self.logger.log_exc("IotlabImporter: failed to import slice")
#No slice update upon import in iotlab
+=======
+ self.logger.log_exc("SlabImporter: failed to import slice")
+
+ #No slice update upon import in senslab
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
else:
# xxx update the record ...
self.logger.warning ("Slice update not yet implemented")
dbsession.commit()
slice_record.stale = False
except SQLAlchemyError:
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
self.logger.log_exc("IotlabImporter: failed to update slice")
+=======
+ self.logger.log_exc("SlabImporter: failed to update slice")
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
def run (self, options):
"""
config = Config()
+<<<<<<< HEAD:sfa/importer/iotlabimporter.py
iotlabdriver = IotlabDriver(config)
#Create special slice table for iotlab
# special records must be preserved
system_hrns = [iotlabdriver.hrn, iotlabdriver.iotlab_api.root_auth, \
iotlabdriver.hrn+ '.slicemanager']
+=======
+ slabdriver = SlabDriver(config)
+
+ #Create special slice table for senslab
+
+ if not slabdriver.db.exists('slab_xp'):
+ slabdriver.db.createtable()
+ self.logger.info ("SlabImporter.run: slab_xp table created ")
+
+
+ # import site and node records in site into the SFA db.
+ self.import_sites_and_nodes(slabdriver)
+ #import users and slice into the SFA DB.
+ self.import_persons_and_slices(slabdriver)
+
+ ### remove stale records
+ # special records must be preserved
+ system_hrns = [slabdriver.hrn, slabdriver.slab_api.root_auth, \
+ slabdriver.hrn+ '.slicemanager']
+>>>>>>> 3fe7429... SA:sfa/importer/slabimporter.py
for record in self.all_records:
if record.hrn in system_hrns:
record.stale = False
try:
self.ldapserv = ldap.open(self.ldapHost)
except ldap.LDAPError, error:
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
return {'bool': False, 'message': error}
+=======
+ return {'bool' : False, 'message' : error }
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
# Bind with authentification
if(bind):
def bind(self):
""" Binding method.
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
+=======
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
:return: dictionary with the bind status. True if Successful,
False if not and in this case the error message( {'bool', 'message'} )
:rtype: dict
try:
self.ldapserv.unbind_s()
except ldap.LDAPError, error:
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
return {'bool': False, 'message': error}
+=======
+ return {'bool' : False, 'message' : error }
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
class LoginPassword():
"""
Sets password and login maximum length, and defines the characters
that can be found in a random generated password.
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
+=======
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
"""
self.login_max_length = 8
self.length_password = 8
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
self.chars_password = ['!', '$', '(',')', '*', '+', ',', '-', '.',
'0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'\'']
+=======
+ self.chars_password = [ '!', '$', '(',')', '*', '+', ',', '-', '.', \
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', \
+ '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', \
+ 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', \
+ 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', \
+ '_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', \
+ 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p' ,'q', \
+ 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', \
+ '\'']
+
+
+
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
@staticmethod
def clean_user_names(record):
"""
if 'first_name' in record and 'last_name' in record:
#Remove all special characters from first_name/last name
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
lower_first_name = record['first_name'].replace('-', '')\
.replace('_', '').replace('[', '')\
.replace(']', '').replace(' ', '')\
.replace('_', '').replace('[', '')\
.replace(']', '').replace(' ', '')\
.lower()
+=======
+ lower_first_name = record['first_name'].replace('-','')\
+ .replace('_','').replace('[','')\
+ .replace(']','').replace(' ','')\
+ .lower()
+ lower_last_name = record['last_name'].replace('-','')\
+ .replace('_','').replace('[','')\
+ .replace(']','').replace(' ','')\
+ .lower()
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
return lower_first_name, lower_last_name
else:
return None, None
:return: Returns encrypted password.
:rtype:string
"""
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
#Keep consistency with Java Iotlab's LDAP API
+=======
+ #Keep consistency with Java Senslab's LDAP API
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
#RFC2307SSHAPasswordEncryptor so set the salt size to 8 bytes
return lssha.encrypt(password, salt_size = 8)
def LdapGenerateUniqueLogin(self, record):
"""
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
Generate login for adding a new user in LDAP Directory
(four characters minimum length). Get proper last name and
first name so that the user's login can be generated.
+=======
+ Generate login for adding a new user in LDAP Directory
+ (four characters minimum length). Get proper last name and
+ first name so that the user's login can be generated.
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
:param record: Record must contain first_name and last_name.
:param record: dict
:return: the generated login for the user described with record if the
login generation is successful, None if it fails.
:rtype: string or None
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
+=======
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
"""
#For compatibility with other ldap func
if 'mail' in record and 'email' not in record:
#Hrn should not be part of the filter because the hrn
#presented by a certificate of a SFA user not imported in
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
#Iotlab does not include the iotlab login in it
#Plus, the SFA user may already have an account with iotlab
+=======
+ #Senslab does not include the senslab login in it
+ #Plus, the SFA user may already have an account with senslab
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
#using another login.
return req_ldap
def make_ldap_attributes_from_record(self, record):
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
"""When adding a new user to Iotlab's LDAP, creates an attributes
+=======
+ """When adding a new user to Senslab's LDAP, creates an attributes
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
dictionnary from the SFA record understandable by LDAP.
Generates the user's LDAP login.
User is automatically validated (account enabled) and described
#Password is automatically generated because SFA user don't go
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
#through the Iotlab website used to register new users,
#There is no place in SFA where users can enter such information
#yet.
#If the user wants to set his own password , he must go to the Iotlab
+=======
+ #through the Senslab website used to register new users,
+ #There is no place in SFA where users can enter such information
+ #yet.
+ #If the user wants to set his own password , he must go to the Senslab
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
#website.
password = self.login_pwd.generate_password()
attrs['userPassword'] = self.login_pwd.encrypt_password(password)
except ldap.LDAPError, error:
logger.log_exc("LDAP Add Error %s" %error)
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
return {'bool': False, 'message': error}
+=======
+ return {'bool' : False, 'message' : error }
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
self.conn.close()
return {'bool': True, 'uid':user_ldap_attrs['uid']}
%(error))
return
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
return results
+=======
+ return results
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
def _process_ldap_info_for_one_user(self, record, result_data):
"""
parent_hrn = get_authority(hrn)
if parent_hrn != self.authname:
peer_authority = parent_hrn
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
#In case the user was not imported from Iotlab LDAP
#but from another federated site, has an account in
#iotlab but currently using his hrn from federated site
+=======
+ #In case the user was not imported from Senslab LDAP
+ #but from another federated site, has an account in
+ #senslab but currently using his hrn from federated site
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
#then the login is different from the one found in its hrn
if tmpname != hrn.split('.')[1]:
hrn = None
expected_fields=None):
"""
Search a SFA user with a hrn. User should be already registered
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
in Iotlab LDAP.
+=======
+ in Senslab LDAP.
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
:param record: sfa user's record. Should contain first_name,last_name,
email or mail. If no record is provided, returns all the users found
in LDAP.
:type record: dict
+<<<<<<< HEAD:sfa/iotlab/LDAPapi.py
:param is_user_enabled: is the user's iotlab account already valid.
+=======
+ :param is_user_enabled: is the user's senslab account already valid.
+>>>>>>> 3fe7429... SA:sfa/senslab/LDAPapi.py
:type is_user_enabled: Boolean.
:return: LDAP entries from ldap matching the filter provided. Returns
a single entry if one filter has been given and a list of
def iotlab_xrn_object(root_auth, hostname):
"""Attributes are urn and hrn.
+<<<<<<< HEAD:sfa/iotlab/iotlabaggregate.py
Get the hostname using iotlab_xrn_to_hostname on the urn.
:return: the iotlab node's xrn
+=======
+ Get the hostname using slab_xrn_to_hostname on the urn.
+
+ :return: the senslab node's xrn
+>>>>>>> 3fe7429... SA:sfa/senslab/slabaggregate.py
:rtype: Xrn
"""
return Xrn('.'.join( [root_auth, Xrn.escape(hostname)]), type='node')
:param slice_xrn: xrn of the slice
+<<<<<<< HEAD:sfa/iotlab/iotlabaggregate.py
:param login: user's login on iotlab ldap
+=======
+ :param login: user's login on senslab ldap
+>>>>>>> 3fe7429... SA:sfa/senslab/slabaggregate.py
:type slice_xrn: string
:type login: string
:reutnr : a list of slices dict and a dictionary of Sliver object
:rtype: (list, dict)
+<<<<<<< HEAD:sfa/iotlab/iotlabaggregate.py
..note: There is no slivers in iotlab, only leases.
+=======
+ ..note: There is no slivers in senslab, only leases.
+>>>>>>> 3fe7429... SA:sfa/senslab/slabaggregate.py
"""
slivers = {}
sliver_xrn.set_authority(self.driver.hrn)
sliver = Sliver({'sliver_id':sliver_xrn.urn,
'name': sfa_slice['hrn'],
+<<<<<<< HEAD:sfa/iotlab/iotlabaggregate.py
'type': 'iotlab-node',
+=======
+ 'type': 'slab-node',
+>>>>>>> 3fe7429... SA:sfa/senslab/slabaggregate.py
'tags': []})
slivers[node] = sliver
#Add default sliver attribute :
+<<<<<<< HEAD:sfa/iotlab/iotlabaggregate.py
#connection information for iotlab
if get_authority (sfa_slice['hrn']) == self.driver.iotlab_api.root_auth:
+=======
+ #connection information for senslab
+ if get_authority (sfa_slice['hrn']) == self.driver.slab_api.root_auth:
+>>>>>>> 3fe7429... SA:sfa/senslab/slabaggregate.py
tmp = sfa_slice['hrn'].split('.')
ldap_username = tmp[1].split('_')[0]
ssh_access = None
#tags_filter = {}
# get the granularity in second for the reservation system
+<<<<<<< HEAD:sfa/iotlab/iotlabaggregate.py
grain = self.driver.iotlab_api.GetLeaseGranularity()
nodes = self.driver.iotlab_api.GetNodes()
+=======
+ grain = self.driver.slab_api.GetLeaseGranularity()
+
+
+ nodes = self.driver.slab_api.GetNodes()
+>>>>>>> 3fe7429... SA:sfa/senslab/slabaggregate.py
#geni_available = options.get('geni_available')
#if geni_available:
#filter['boot_state'] = 'boot'
#filter.update({'peer_id': None})
+<<<<<<< HEAD:sfa/iotlab/iotlabaggregate.py
#nodes = self.driver.iotlab_api.GetNodes(filter['hostname'])
+=======
+ #nodes = self.driver.slab_api.GetNodes(filter['hostname'])
+>>>>>>> 3fe7429... SA:sfa/senslab/slabaggregate.py
#site_ids = []
#interface_ids = []
#for node in one_slice['node_ids']:
#slice_nodes_list.append(node)
+<<<<<<< HEAD:sfa/iotlab/iotlabaggregate.py
reserved_nodes = self.driver.iotlab_api.GetNodesCurrentlyInUse()
+=======
+ reserved_nodes = self.driver.slab_api.GetNodesCurrentlyInUse()
+>>>>>>> 3fe7429... SA:sfa/senslab/slabaggregate.py
logger.debug("SLABAGGREGATE api get_nodes slice_nodes_list %s "\
%(slice_nodes_list))
for node in nodes:
nodes_dict[node['node_id']] = node
if slice_nodes_list == [] or node['hostname'] in slice_nodes_list:
+<<<<<<< HEAD:sfa/iotlab/iotlabaggregate.py
rspec_node = IotlabNode()
+=======
+ rspec_node = SlabNode()
+>>>>>>> 3fe7429... SA:sfa/senslab/slabaggregate.py
# xxx how to retrieve site['login_base']
#site_id=node['site_id']
#site=sites_dict[site_id]
rspec_node['archi'] = node['archi']
rspec_node['radio'] = node['radio']
+<<<<<<< HEAD:sfa/iotlab/iotlabaggregate.py
iotlab_xrn = iotlab_xrn_object(self.driver.iotlab_api.root_auth, \
node['hostname'])
rspec_node['component_id'] = iotlab_xrn.urn
+=======
+ slab_xrn = slab_xrn_object(self.driver.slab_api.root_auth, \
+ node['hostname'])
+ rspec_node['component_id'] = slab_xrn.urn
+>>>>>>> 3fe7429... SA:sfa/senslab/slabaggregate.py
rspec_node['component_name'] = node['hostname']
rspec_node['component_manager_id'] = \
hrn_to_urn(self.driver.iotlab_api.root_auth, \
'authority+sa')
+<<<<<<< HEAD:sfa/iotlab/iotlabaggregate.py
# Iotlab's nodes are federated : there is only one authority
# for all Iotlab sites, registered in SFA.
+=======
+ # Senslab's nodes are federated : there is only one authority
+ # for all Senslab sites, registered in SFA.
+>>>>>>> 3fe7429... SA:sfa/senslab/slabaggregate.py
# Removing the part including the site
# in authority_id SA 27/07/12
rspec_node['authority_id'] = rspec_node['component_manager_id']
rspec_node['location'] = location
+<<<<<<< HEAD:sfa/iotlab/iotlabaggregate.py
position = IotlabPosition()
+=======
+ position = SlabPosition()
+>>>>>>> 3fe7429... SA:sfa/senslab/slabaggregate.py
for field in position :
try:
position[field] = node[field]
version.version, 'manifest')
slices, slivers = self.get_slice_and_slivers(slice_xrn, login)
+<<<<<<< HEAD:sfa/iotlab/iotlabaggregate.py
#at this point sliver may be empty if no iotlab job
+=======
+ #at this point sliver may be empty if no senslab job
+>>>>>>> 3fe7429... SA:sfa/senslab/slabaggregate.py
#is running for this user/slice.
rspec = RSpec(version=rspec_version, user_options=options)
#if not options.get('list_leases') or options.get('list_leases')
#and options['list_leases'] != 'leases':
nodes = self.get_nodes(slices, slivers)
+<<<<<<< HEAD:sfa/iotlab/iotlabaggregate.py
logger.debug("\r\n \r\n IotlabAggregate \ lease_option %s \
+=======
+ logger.debug("\r\n \r\n SlabAggregate \ lease_option %s \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabaggregate.py
get rspec ******* nodes %s"\
%(lease_option, nodes[0]))
leases = self.get_all_leases()
rspec.version.add_leases(leases)
+<<<<<<< HEAD:sfa/iotlab/iotlabaggregate.py
#logger.debug("IotlabAggregate \tget_rspec ******* rspec_toxml %s \r\n"\
+=======
+ #logger.debug("SlabAggregate \tget_rspec ******* rspec_toxml %s \r\n"\
+>>>>>>> 3fe7429... SA:sfa/senslab/slabaggregate.py
#%(rspec.toxml()))
return rspec.toxml()
from sfa.trust.certificate import Keypair, convert_public_key
from sfa.trust.gid import create_uuid
from sfa.trust.hierarchy import Hierarchy
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
+=======
+
+from sfa.senslab.slabaggregate import slab_xrn_object
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
from sfa.iotlab.iotlabaggregate import iotlab_xrn_object
existing_hrns_by_types[record.type].append(record.hrn)
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER \tGetPeer\texisting_hrns_by_types %s "\
+=======
+ logger.debug("SLABDRIVER \tGetPeer\texisting_hrns_by_types %s "\
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
%( existing_hrns_by_types))
records_list = []
for hrn in existing_hrns_by_types['authority']:
records_list.append(existing_records[(hrn,'authority')])
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER \tGetPeer \trecords_list %s " \
+=======
+ logger.debug("SLABDRIVER \tGetPeer \trecords_list %s " \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
%(records_list))
except KeyError:
#over the records' list
def GetPersons(self, person_filter=None):
"""
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
Get the enabled users and their properties from Iotlab LDAP.
+=======
+ Get the enabled users and their properties from Senslab LDAP.
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
If a filter is specified, looks for the user whose properties match
the filter, otherwise returns the whole enabled users'list.
:param person_filter: Must be a list of dictionnaries
#Usually the list contains only one user record
for searched_attributes in person_filter:
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
#Get only enabled user accounts in iotlab LDAP :
+=======
+ #Get only enabled user accounts in senslab LDAP :
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
#add a filter for make_ldap_filters_from_record
person = self.ldap.LdapFindUser(searched_attributes, \
is_user_enabled=True)
person_list = None
else:
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
#Get only enabled user accounts in iotlab LDAP :
+=======
+ #Get only enabled user accounts in senslab LDAP :
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
#add a filter for make_ldap_filters_from_record
person_list = self.ldap.LdapFindUser(is_user_enabled=True)
posting a delete request to OAR.
:param job_id: job id in OAR.
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
:param username: user's iotlab login in LDAP.
+=======
+ :param username: user's senslab login in LDAP.
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
:type job_id:integer
:type username: string
(True) or no (False)
:rtype: dict
"""
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER \tDeleteJobs jobid %s username %s "\
+=======
+ logger.debug("SLABDRIVER \tDeleteJobs jobid %s username %s "\
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
%(job_id, username))
if not job_id or job_id is -1:
return
#return None
#except KeyError:
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
#logger.error("IOTLABDRIVER \tGetJobsId KeyError")
+=======
+ #logger.error("SLABDRIVER \tGetJobsId KeyError")
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
#return None
#parsed_job_info = self.get_info_on_reserved_nodes(job_info, \
def GetJobsResources(self, job_id, username = None):
""" Gets the list of nodes associated with the job_id and username
if provided.
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
Transforms the iotlab hostnames to the corresponding
+=======
+ Transforms the senslab hostnames to the corresponding
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
SFA nodes hrns.
Rertuns dict key :'node_ids' , value : hostnames list
:param username: user's LDAP login
#Get job resources list from OAR
node_id_list = self.oar.parser.SendRequest(req, job_id, username)
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER \t GetJobsResources %s " %(node_id_list))
+=======
+ logger.debug("SLABDRIVER \t GetJobsResources %s " %(node_id_list))
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
hostname_list = \
self.__get_hostnames_from_oar_node_ids(node_id_list)
#reserved_node_hostname_list[index] = \
#node_dict[job_info[node_list_name][index]]['hostname']
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
#logger.debug("IOTLABDRIVER \t get_info_on_reserved_nodes \
#reserved_node_hostname_list %s" \
#%(reserved_node_hostname_list))
#except KeyError:
#logger.error("IOTLABDRIVER \t get_info_on_reserved_nodes KEYERROR " )
+=======
+ #logger.debug("SLABDRIVER \t get_info_on_reserved_nodes \
+ #reserved_node_hostname_list %s" \
+ #%(reserved_node_hostname_list))
+ #except KeyError:
+ #logger.error("SLABDRIVER \t get_info_on_reserved_nodes KEYERROR " )
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
#return reserved_node_hostname_list
def GetNodes(self, node_filter_dict = None, return_fields_list = None):
"""
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
Make a list of iotlab nodes and their properties from information
+=======
+ Make a list of senslab nodes and their properties from information
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
given by OAR. Search for specific nodes if some filters are specified.
Nodes properties returned if no return_fields_list given:
'hrn','archi','mobile','hostname','site','boot_state','node_id',
gid=slice_record['gid'],
pointer=slice_record['slice_id'],
authority=slice_record['authority'])
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER.PY AddSlice sfa_record %s user_record %s"
+=======
+ logger.debug("SLABDRIVER.PY AddSlice sfa_record %s user_record %s"
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
% (sfa_record, user_record))
sfa_record.just_created()
dbsession.add(sfa_record)
#TODO : Check rights to delete person
def DeletePerson(self, person_record):
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
""" Disable an existing account in iotlab LDAP.
+=======
+ """ Disable an existing account in senslab LDAP.
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
Users and techs can only delete themselves. PIs can only
delete themselves and other non-PIs at their sites.
ins can delete anyone.
delete_failed = []
delete_failed.append(job_id)
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.info("IOTLABDRIVER DeleteSlice %s answer %s"%(slice_record, \
+=======
+ logger.info("SLABDRIVER DeleteSlice %s answer %s"%(slice_record, \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
delete_failed))
return delete_failed or True
def __add_person_to_db(user_dict):
"""
Add a federated user straight to db when the user issues a lease
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
request with iotlab nodes and that he has not registered with iotlab
+=======
+ request with senslab nodes and that he has not registered with senslab
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
yet (that is he does not have a LDAP entry yet).
Uses parts of the routines in SlabImport when importing user from LDAP.
Called by AddPerson, right after LdapAddUser.
iotlab ldap, provided that the person_uid is valid.
Non-admins can only modify their own keys.
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
:param person_uid: user's iotlab login in LDAP
+=======
+ :param person_uid: user's senslab login in LDAP
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
:param old_attributes_dict: dict with the user's old sshPublicKey
:param new_key_dict:dict with the user's new sshPublicKey
:type person_uid: string
way to handle failure when dealing with multiple job delete. Plus,
there was no easy way to report it to the user.
"""
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER DeleteLeases leases_id_list %s slice_hrn %s \
+=======
+ logger.debug("SLABDRIVER DeleteLeases leases_id_list %s slice_hrn %s \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
\r\n " %(leases_id_list, slice_hrn))
for job_id in leases_id_list:
self.DeleteJobs(job_id, slice_hrn)
lease_dict['time_format'] = self.time_format
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER.PY \tLaunchExperimentOnOAR slice_user %s\
+=======
+ logger.debug("SLABDRIVER.PY \tLaunchExperimentOnOAR slice_user %s\
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
\r\n " %(slice_user))
#Create the request for OAR
reqdict = self._create_job_structure_request_for_OAR(lease_dict)
# first step : start the OAR job and update the job
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER.PY \tLaunchExperimentOnOAR reqdict %s\
+=======
+ logger.debug("SLABDRIVER.PY \tLaunchExperimentOnOAR reqdict %s\
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
\r\n " %(reqdict))
answer = self.oar.POSTRequestToOARRestAPI('POST_job', \
reqdict, slice_user)
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER \tLaunchExperimentOnOAR jobid %s " %(answer))
+=======
+ logger.debug("SLABDRIVER \tLaunchExperimentOnOAR jobid %s " %(answer))
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
try:
jobid = answer['id']
except KeyError:
lease_start_time, lease_duration):
"""Creates a job in OAR corresponding to the information provided
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
as parameters. Adds the job id and the slice hrn in the iotlab
+=======
+ as parameters. Adds the job id and the slice hrn in the senslab
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
database so that we are able to know which slice has which nodes.
:param hostname_list: list of nodes' OAR hostnames.
end_time = lease_start_time + lease_duration
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER \r\n \r\n \t AddLeases TURN ON LOGGING SQL \
%s %s %s "%(slice_record['hrn'], job_id, end_time))
iotlab_dbsession.commit()
logger.debug("IOTLABDRIVER \t AddLeases hostname_list start_time %s " \
+=======
+ logger.debug("SLABDRIVER \r\n \r\n \t AddLeases TURN ON LOGGING SQL \
+ %s %s %s "%(slice_record['hrn'], job_id, end_time))
+
+
+ logger.debug("SLABDRIVER \r\n \r\n \t AddLeases %s %s %s " \
+ %(type(slice_record['hrn']), type(job_id), type(end_time)))
+
+ slab_ex_row = SenslabXP(slice_hrn = slice_record['hrn'], \
+ job_id = job_id, end_time= end_time)
+
+ logger.debug("SLABDRIVER \r\n \r\n \t AddLeases slab_ex_row %s" \
+ %(slab_ex_row))
+ slab_dbsession.add(slab_ex_row)
+ slab_dbsession.commit()
+
+ logger.debug("SLABDRIVER \t AddLeases hostname_list start_time %s " \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
%(start_time))
return
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
#Delete the jobs from job_iotlab table
+=======
+ #Delete the jobs from job_senslab table
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
def DeleteSliceFromNodes(self, slice_record):
""" Deletes all the running or scheduled jobs of a given slice
given its record.
False, for each job id.
:rtype: dict
"""
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER \t DeleteSliceFromNodese %s " %(slice_record))
+=======
+ logger.debug("SLABDRIVER \t DeleteSliceFromNodese %s " %(slice_record))
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
if isinstance(slice_record['oar_job_id'], list):
oar_bool_answer = {}
def GetLeaseGranularity(self):
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
""" Returns the granularity of an experiment in the Iotlab testbed.
+=======
+ """ Returns the granularity of an experiment in the Senslab testbed.
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
OAR uses seconds for experiments duration , the granulaity is also
defined in seconds.
Experiments which last less than 10 min (600 sec) are invalid"""
deleted_jobs = set_jobs_psql.difference(kept_jobs)
deleted_jobs = list(deleted_jobs)
if len(deleted_jobs) > 0:
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
iotlab_dbsession.query(IotlabXP).filter(IotlabXP.job_id.in_(deleted_jobs)).delete(synchronize_session='fetch')
iotlab_dbsession.commit()
+=======
+ slab_dbsession.query(SenslabXP).filter(SenslabXP.job_id.in_(deleted_jobs)).delete(synchronize_session='fetch')
+ slab_dbsession.commit()
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
return
#the same user in LDAP SA 27/07/12
job_oar_list = []
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
jobs_psql_query = iotlab_dbsession.query(IotlabXP).all()
+=======
+ jobs_psql_query = slab_dbsession.query(SenslabXP).all()
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
jobs_psql_dict = dict([(row.job_id, row.__dict__ ) for row in jobs_psql_query ])
#jobs_psql_dict = jobs_psql_dict)
logger.debug("IOTLABDRIVER \tGetLeases jobs_psql_dict %s"\
for resa in unfiltered_reservation_list:
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER \tGetLeases USER %s"\
+=======
+ logger.debug("SLABDRIVER \tGetLeases USER %s"\
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
%(resa['user']))
#Construct list of jobs (runing, waiting..) in oar
job_oar_list.append(resa['lease_id'])
#(slice used and job id)
if resa['lease_id'] in jobs_psql_dict:
job_info = jobs_psql_dict[resa['lease_id']]
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER \tGetLeases job_info %s"\
+=======
+ logger.debug("SLABDRIVER \tGetLeases job_info %s"\
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
%(job_info))
resa['slice_hrn'] = job_info['slice_hrn']
resa['slice_id'] = hrn_to_urn(resa['slice_hrn'], 'slice')
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
#otherwise, assume it is a iotlab slice:
+=======
+ #otherwise, assume it is a senslab slice:
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
else:
resa['slice_id'] = hrn_to_urn(self.root_auth+'.'+ \
resa['user'] +"_slice" , 'slice')
#Transform the hostnames into urns (component ids)
for node in resa['reserved_nodes']:
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
iotlab_xrn = iotlab_xrn_object(self.root_auth, node)
resa['component_id_list'].append(iotlab_xrn.urn)
if lease_filter_dict:
logger.debug("IOTLABDRIVER \tGetLeases resa_ %s \
+=======
+ slab_xrn = slab_xrn_object(self.root_auth, node)
+ resa['component_id_list'].append(slab_xrn.urn)
+
+ if lease_filter_dict:
+ logger.debug("SLABDRIVER \tGetLeases resa_ %s \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
\r\n leasefilter %s" %(resa, lease_filter_dict))
if lease_filter_dict['name'] == resa['slice_hrn']:
reservation_list = unfiltered_reservation_list
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
self.update_jobs_in_iotlabdb(job_oar_list, jobs_psql_id_list)
logger.debug(" IOTLABDRIVER.PY \tGetLeases reservation_list %s"\
+=======
+ self.update_jobs_in_slabdb(job_oar_list, jobs_psql_id_list)
+
+ logger.debug(" SLABDRIVER.PY \tGetLeases reservation_list %s"\
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
%(reservation_list))
return reservation_list
#return
##TODO UpdateSlice 04/07/2012 SA || Commented out 28/05/13 SA
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
##Funciton should delete and create another job since oin iotlab slice=job
+=======
+ ##Funciton should delete and create another job since oin senslab slice=job
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
#def UpdateSlice(self, auth, slice_id_or_name, slice_fields=None):
#"""Updates the parameters of an existing slice with the values in
#slice_fields.
#FROM PLC API DOC
#"""
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
#logger.warning("IOTLABDRIVER UpdateSlice EMPTY - DO NOTHING \r\n ")
+=======
+ #logger.warning("SLABDRIVER UpdateSlice EMPTY - DO NOTHING \r\n ")
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
#return
#Unused SA 30/05/13, we only update the user's key or we delete it.
##TODO UpdatePerson 04/07/2012 SA
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
#def UpdatePerson(self, iotlab_hrn, federated_hrn, person_fields=None):
+=======
+ #def UpdatePerson(self, slab_hrn, federated_hrn, person_fields=None):
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
#"""Updates a person. Only the fields specified in person_fields
#are updated, all other fields are left untouched.
#Users and techs can only update themselves. PIs can only update
#FROM PLC API DOC
#"""
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
##new_row = FederatedToIotlab(iotlab_hrn, federated_hrn)
##iotlab_dbsession.add(new_row)
##iotlab_dbsession.commit()
#logger.debug("IOTLABDRIVER UpdatePerson EMPTY - DO NOTHING \r\n ")
+=======
+ ##new_row = FederatedToSenslab(slab_hrn, federated_hrn)
+ ##slab_dbsession.add(new_row)
+ ##slab_dbsession.commit()
+
+ #logger.debug("SLABDRIVER UpdatePerson EMPTY - DO NOTHING \r\n ")
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
#return
@staticmethod
#user_by_email = dict((user[1]['mail'][0], user[1]['sshPublicKey']) \
#for user in ldap_rslt)
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER GetKeys -key_dict %s \r\n " %(key_dict))
+=======
+ logger.debug("SLABDRIVER GetKeys -key_dict %s \r\n " %(key_dict))
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
return key_dict
#TODO : test
#of the user otherwise will mess up the RegRecord in
#Resolve, don't know why - SA 08/08/2012
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
#Only one entry for one user = one slice in iotlab_xp table
+=======
+ #Only one entry for one user = one slice in slab_xp table
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
#slicerec = dbsession.query(RegRecord).filter_by(hrn = slice_filter).first()
raw_slicerec = dbsession.query(RegSlice).options(joinedload('reg_researchers')).filter_by(hrn = slice_filter).first()
#raw_slicerec = dbsession.query(RegRecord).filter_by(hrn = slice_filter).first()
def GetSlices(self, slice_filter = None, slice_filter_type = None, \
login=None):
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
""" Get the slice records from the iotlab db and add lease information
+=======
+ """ Get the slice records from the slab db and add lease information
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
if any.
:param slice_filter: can be the slice hrn or slice record id in the db
self._get_slice_records(slice_filter, slice_filter_type)
slice_hrn = fixed_slicerec_dict['hrn']
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug(" IOTLABDRIVER \tGetSlices login %s \
+=======
+ logger.debug(" SLABDRIVER \tGetSlices login %s \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
slice record %s slice_filter %s \
slice_filter_type %s " %(login, \
fixed_slicerec_dict, slice_filter, \
for lease in leases_list :
slicerec_dict = {}
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER.PY \tGetSlices slice_filter %s \
+=======
+ logger.debug("SLABDRIVER.PY \tGetSlices slice_filter %s \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
\ lease['slice_hrn'] %s" \
%(slice_filter, lease['slice_hrn']))
if lease['slice_hrn'] == slice_hrn:
#str(fixed_slicerec_dict['slice_hrn'])})
return_slicerec_dictlist.append(slicerec_dict)
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER.PY \tGetSlices \
OHOHOHOH %s" %(return_slicerec_dictlist ))
logger.debug("IOTLABDRIVER.PY \tGetSlices \
+=======
+ logger.debug("SLABDRIVER.PY \tGetSlices \
+ OHOHOHOH %s" %(return_slicerec_dictlist ))
+
+ logger.debug("SLABDRIVER.PY \tGetSlices \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
slicerec_dict %s return_slicerec_dictlist %s \
lease['reserved_nodes'] \
%s" %(slicerec_dict, return_slicerec_dictlist, \
lease['reserved_nodes'] ))
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER.PY \tGetSlices RETURN \
+=======
+ logger.debug("SLABDRIVER.PY \tGetSlices RETURN \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
return_slicerec_dictlist %s" \
%(return_slicerec_dictlist))
else:
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
#Get all slices from the iotlab sfa database ,
+=======
+ #Get all slices from the senslab sfa database ,
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
#put them in dict format
#query_slice_list = dbsession.query(RegRecord).all()
query_slice_list = dbsession.query(RegSlice).options(joinedload('reg_researchers')).all()
for fixed_slicerec_dict in return_slicerec_dictlist:
slicerec_dict = {}
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
#Check if the slice belongs to a iotlab user
+=======
+ #Check if the slice belongs to a senslab user
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
if fixed_slicerec_dict['peer_authority'] is None:
owner = fixed_slicerec_dict['hrn'].split(".")[1].split("_")[0]
else:
#return_slicerec_dictlist.append(slicerec_dict)
fixed_slicerec_dict.update(slicerec_dict)
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
logger.debug("IOTLABDRIVER.PY \tGetSlices RETURN \
+=======
+ logger.debug("SLABDRIVER.PY \tGetSlices RETURN \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
return_slicerec_dictlist %s \slice_filter %s " \
%(return_slicerec_dictlist, slice_filter))
return return_slicerec_dictlist
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
+=======
+
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
#iotlab_record = {}
##for field in record:
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
## iotlab_record[field] = record[field]
#if sfa_type == "slice":
#iotlab_record["hrn"] = hrn
#logger.debug("IOTLABDRIVER.PY sfa_fields_to_iotlab_fields \
#iotlab_record %s " %(iotlab_record['hrn']))
+=======
+ ## slab_record[field] = record[field]
+
+ #if sfa_type == "slice":
+ ##instantion used in get_slivers ?
+ #if not "instantiation" in slab_record:
+ #slab_record["instantiation"] = "senslab-instantiated"
+ ##slab_record["hrn"] = hrn_to_pl_slicename(hrn)
+ ##Unused hrn_to_pl_slicename because Slab's hrn already
+ ##in the appropriate form SA 23/07/12
+ #slab_record["hrn"] = hrn
+ #logger.debug("SLABDRIVER.PY sfa_fields_to_slab_fields \
+ #slab_record %s " %(slab_record['hrn']))
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
#if "url" in record:
#iotlab_record["url"] = record["url"]
#if "description" in record:
#iotlab_record["description"] = record["description"]
#if "expires" in record:
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
#iotlab_record["expires"] = int(record["expires"])
+=======
+ #slab_record["expires"] = int(record["expires"])
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
##nodes added by OAR only and then imported to SFA
##elif type == "node":
##if not "hostname" in iotlab_record:
##if not "hostname" in record:
##raise MissingSfaInfo("hostname")
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
##iotlab_record["hostname"] = record["hostname"]
##if not "model" in iotlab_record:
##iotlab_record["model"] = "geni"
+=======
+ ##slab_record["hostname"] = record["hostname"]
+ ##if not "model" in slab_record:
+ ##slab_record["model"] = "geni"
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
##One authority only
##elif type == "authority":
+<<<<<<< HEAD:sfa/iotlab/iotlabapi.py
+=======
+
+
+
+
+
+
+
+>>>>>>> 3fe7429... SA:sfa/senslab/slabapi.py
from sfa.util.xrn import Xrn, hrn_to_urn, get_authority
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
from sfa.iotlab.iotlabpostgres import IotlabDB
+=======
+from sfa.senslab.slabpostgres import SlabDB
+
+
+from sfa.senslab.slabaggregate import SlabAggregate, slab_xrn_to_hostname
+
+from sfa.senslab.slabslices import SlabSlices
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
from sfa.iotlab.iotlabaggregate import IotlabAggregate, iotlab_xrn_to_hostname
class IotlabDriver(Driver):
""" Iotlab Driver class inherited from Driver generic class.
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
+=======
+class SlabDriver(Driver):
+ """ Senslab Driver class inherited from Driver generic class.
+
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
Contains methods compliant with the SFA standard and the testbed
infrastructure (calls to LDAP and OAR).
def __init__(self, config):
"""
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
Sets the iotlab SFA config parameters ,
instanciates the testbed api and the iotlab database.
:param config: iotlab SFA configuration object
+=======
+ Sets the senslab SFA config parameters ,
+ instanciates the testbed api and the senslab database.
+
+ :param config: senslab SFA configuration object
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
:type config: Config object
"""
Driver.__init__ (self, config)
def fill_record_info(self, record_list):
"""
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
For each SFA record, fill in the iotlab specific and SFA specific
+=======
+ For each SFA record, fill in the senslab specific and SFA specific
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
fields in the record.
:param record_list: list of sfa dictionaries records
other way to do it given the way it's called in registry manager.
"""
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
logger.debug("IOTLABDRIVER \tfill_record_info records %s " %(record_list))
+=======
+ logger.debug("SLABDRIVER \tfill_record_info records %s " %(record_list))
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
if not isinstance(record_list, list):
record_list = [record_list]
for record in record_list:
#If the record is a SFA slice record, then add information
#about the user of this slice. This kind of
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
#information is in the Iotlab's DB.
+=======
+ #information is in the Senslab's DB.
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
if str(record['type']) == 'slice':
if 'reg_researchers' in record and \
isinstance(record['reg_researchers'], list) :
'key_ids':''}) #For client_helper.py compatibility
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
#Get iotlab slice record and oar job id if any.
recslice_list = self.iotlab_api.GetSlices(slice_filter = \
+=======
+ #Get slab slice record and oar job id if any.
+ recslice_list = self.slab_api.GetSlices(slice_filter = \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
str(record['hrn']),\
slice_filter_type = 'slice_hrn')
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
logger.debug("IOTLABDRIVER \tfill_record_info \
+=======
+ logger.debug("SLABDRIVER \tfill_record_info \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
TYPE SLICE RECUSER record['hrn'] %s ecord['oar_job_id']\
%s " %(record['hrn'], record['oar_job_id']))
del record['reg_researchers']
try:
for rec in recslice_list:
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
logger.debug("IOTLABDRIVER\r\n \t \
fill_record_info oar_job_id %s " \
%(rec['oar_job_id']))
record['node_ids'] = [ self.iotlab_api.root_auth + \
+=======
+ logger.debug("SLABDRIVER\r\n \t \
+ fill_record_info oar_job_id %s " \
+ %(rec['oar_job_id']))
+
+ record['node_ids'] = [ self.slab_api.root_auth + \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
hostname for hostname in rec['node_ids']]
except KeyError:
pass
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
logger.debug( "IOTLABDRIVER.PY \t fill_record_info SLICE \
+=======
+ logger.debug( "SLABDRIVER.PY \t fill_record_info SLICE \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
recslice_list %s \r\n \t RECORD %s \r\n \
\r\n" %(recslice_list, record))
slice_filter = record['record_id'],\
slice_filter_type = 'record_id_user')
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
logger.debug( "IOTLABDRIVER.PY \t fill_record_info TYPE USER \
+=======
+ logger.debug( "SLABDRIVER.PY \t fill_record_info TYPE USER \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
recslice_list %s \r\n \t RECORD %s \r\n" \
%(recslice_list , record))
#Append slice record in records list,
#Will update PIs and researcher for the slice
recuser = recslice_list[0]['reg_researchers']
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
logger.debug( "IOTLABDRIVER.PY \t fill_record_info USER \
+=======
+ logger.debug( "SLABDRIVER.PY \t fill_record_info USER \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
recuser %s \r\n \r\n" %(recuser))
recslice = {}
recslice = recslice_list[0]
#GetPersons takes [] as filters
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
user_iotlab = self.iotlab_api.GetPersons([record])
record.update(user_iotlab[0])
+=======
+ user_slab = self.slab_api.GetPersons([record])
+
+
+ record.update(user_slab[0])
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
#For client_helper.py compatibility
record.update( { 'geni_urn':'',
'keys':'',
'key_ids':'' })
record_list.append(recslice)
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
logger.debug("IOTLABDRIVER.PY \tfill_record_info ADDING SLICE\
+=======
+ logger.debug("SLABDRIVER.PY \tfill_record_info ADDING SLICE\
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
INFO TO USER records %s" %(record_list))
def sliver_status(self, slice_urn, slice_hrn):
"""
Receive a status request for slice named urn/hrn
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
urn:publicid:IDN+iotlab+nturro_slice hrn iotlab.nturro_slice
+=======
+ urn:publicid:IDN+senslab+nturro_slice hrn senslab.nturro_slice
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
shall return a structure as described in
http://groups.geni.net/geni/wiki/GAPI_AM_API_V2#SliverStatus
NT : not sure if we should implement this or not, but used by sface.
#slice_nodes_list.append(node['hostname'])
slice_nodes_list = one_slice['node_ids']
#Get all the corresponding nodes details
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
nodes_all = self.iotlab_api.GetNodes({'hostname':slice_nodes_list},
+=======
+ nodes_all = self.slab_api.GetNodes({'hostname':slice_nodes_list},
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
['node_id', 'hostname','site','boot_state'])
nodeall_byhostname = dict([(one_node['hostname'], one_node) \
for one_node in nodes_all])
result['geni_status'] = top_level_status
result['geni_resources'] = []
return result
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
+=======
+
+ top_level_status = 'ready'
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
top_level_status = 'ready'
resources = []
for node_hostname in single_slice['node_ids']:
res = {}
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
res['iotlab_hostname'] = node_hostname
res['iotlab_boot_state'] = nodeall_byhostname[node_hostname]['boot_state']
+=======
+ res['slab_hostname'] = node_hostname
+ res['slab_boot_state'] = nodeall_byhostname[node_hostname]['boot_state']
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
#res['pl_hostname'] = node['hostname']
#res['pl_boot_state'] = \
result['geni_status'] = top_level_status
result['geni_resources'] = resources
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
logger.debug("IOTLABDRIVER \tsliver_statusresources %s res %s "\
+=======
+ logger.debug("SLABDRIVER \tsliver_statusresources %s res %s "\
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
%(resources,res))
return result
type. Find the lease requests in the rspec and creates
a lease request list with the mandatory information ( nodes,
start time and duration) of the valid leases (duration above or equal
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
to the iotlab experiment minimum duration).
+=======
+ to the senslab experiment minimum duration).
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
:param rspec: rspec request received.
:type rspec: RSpec
requested_lease_list = []
for lease in rspec.version.get_leases():
single_requested_lease = {}
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
logger.debug("IOTLABDRIVER.PY \t_get_requested_leases_list lease %s " %(lease))
+=======
+ logger.debug("SLABDRIVER.PY \t_get_requested_leases_list lease %s " %(lease))
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
if not lease.get('lease_id'):
if get_authority(lease['component_id']) == \
#the lease to the requested leases list
duration_in_seconds = \
int(single_requested_lease['duration'])
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
if duration_in_seconds >= self.iotlab_api.GetMinExperimentDurationInSec() :
+=======
+ if duration_in_seconds >= self.slab_api.GetMinExperimentDurationInSec() :
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
requested_lease_list.append(single_requested_lease)
return requested_lease_list
logger.debug("IOTLABDRIVER _process_requested_jobs requested_lease_list \
%s"%(requested_lease_list))
job_dict = self._group_leases_by_start_time(requested_lease_list)
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
logger.debug("IOTLABDRIVER _process_requested_jobs job_dict\
+=======
+ logger.debug("SLABDRIVER _process_requested_jobs job_dict\
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
%s"%(job_dict))
return job_dict
"""
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
aggregate = IotlabAggregate(self)
slices = IotlabSlices(self)
+=======
+ aggregate = SlabAggregate(self)
+
+ slices = SlabSlices(self)
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
peer = slices.get_peer(slice_hrn)
sfa_peer = slices.get_sfa_peer(slice_hrn)
slice_record = None
if users:
slice_record = users[0].get('slice_record', {})
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
logger.debug("IOTLABDRIVER.PY \t ===============create_sliver \t\
+=======
+ logger.debug("SLABDRIVER.PY \t ===============create_sliver \t\
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
creds %s \r\n \r\n users %s" \
%(creds, users))
slice_record['user'] = {'keys':users[0]['keys'], \
# add/remove slice from nodes
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
+=======
+ # add/remove slice from nodes
+
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
#requested_slivers = [node.get('component_id') \
#for node in rspec.version.get_nodes_with_slivers()\
#if node.get('authority_id') is self.iotlab_api.root_auth]
requested_job_dict = self._process_requested_jobs(rspec)
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
logger.debug("IOTLABDRIVER.PY \tcreate_sliver requested_job_dict %s "\
+=======
+ logger.debug("SLABDRIVER.PY \tcreate_sliver requested_job_dict %s "\
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
%(requested_job_dict))
#verify_slice_leases returns the leases , but the return value is unused
#here. Removed SA 13/08/12
def delete_sliver (self, slice_urn, slice_hrn, creds, options):
"""
Deletes the lease associated with the slice hrn and the credentials
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
if the slice belongs to iotlab. Answer to DeleteSliver.
:return: 1 if the slice to delete was not found on iotlab,
True if the deletion was successful, False otherwise otherwise.
.. note:: Should really be named delete_leases because iotlab does
+=======
+ if the slice belongs to senslab. Answer to DeleteSliver.
+
+ :return: 1 if the slice to delete was not found on senslab,
+ True if the deletion was successful, False otherwise otherwise.
+
+ .. note:: Should really be named delete_leases because senslab does
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
not have any slivers, but only deals with leases. However, SFA api only
have delete_sliver define so far. SA 13.05/2013
"""
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
sfa_slice_list = self.iotlab_api.GetSlices(slice_filter = slice_hrn, \
+=======
+ sfa_slice_list = self.slab_api.GetSlices(slice_filter = slice_hrn, \
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
slice_filter_type = 'slice_hrn')
if not sfa_slice_list:
for sfa_slice in sfa_slice_list:
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
logger.debug("IOTLABDRIVER.PY delete_sliver slice %s" %(sfa_slice))
slices = IotlabSlices(self)
# determine if this is a peer slice
+=======
+ logger.debug("SLABDRIVER.PY delete_sliver slice %s" %(sfa_slice))
+ slices = SlabSlices(self)
+ # determine if this is a peer slice
+
+ peer = slices.get_peer(slice_hrn)
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
peer = slices.get_peer(slice_hrn)
\r\n \t sfa_slice %s " %(peer, sfa_slice))
try:
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
self.iotlab_api.DeleteSliceFromNodes(sfa_slice)
+=======
+ self.slab_api.DeleteSliceFromNodes(sfa_slice)
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
return True
except :
return False
def list_resources (self, slice_urn, slice_hrn, creds, options):
"""
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
List resources from the iotlab aggregate and returns a Rspec
+=======
+ List resources from the senslab aggregate and returns a Rspec
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
advertisement with resources found when slice_urn and slice_hrn are None
(in case of resource discovery).
If a slice hrn and urn are provided, list experiment's slice
#return rspec
#panos: passing user-defined options
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
aggregate = IotlabAggregate(self)
+=======
+ aggregate = SlabAggregate(self)
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
rspec = aggregate.get_rspec(slice_xrn=slice_urn, \
version=rspec_version, options=options)
def list_slices (self, creds, options):
"""
Answer to ListSlices.
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
List slices belonging to iotlab, returns slice urns list.
+=======
+ List slices belonging to senslab, returns slice urns list.
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
No caching used. Options unused but are defined in the SFA method
api prototype.
# get data from db
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
slices = self.iotlab_api.GetSlices()
logger.debug("IOTLABDRIVER.PY \tlist_slices hrn %s \r\n \r\n" %(slices))
slice_hrns = [iotlab_slice['hrn'] for iotlab_slice in slices]
+=======
+ slices = self.slab_api.GetSlices()
+ logger.debug("SLABDRIVER.PY \tlist_slices hrn %s \r\n \r\n" %(slices))
+ slice_hrns = [slab_slice['hrn'] for slab_slice in slices]
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
slice_urns = [hrn_to_urn(slice_hrn, 'slice') \
for slice_hrn in slice_hrns]
# cache the result
#if self.cache:
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
#logger.debug ("IotlabDriver.list_slices stores value in cache")
+=======
+ #logger.debug ("SlabDriver.list_slices stores value in cache")
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
#self.cache.add('slices', slice_urns)
return slice_urns
def update (self, old_sfa_record, new_sfa_record, hrn, new_key):
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
"""No site or node record update allowed in Iotlab.
+=======
+ """No site or node record update allowed in Senslab.
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
The only modifications authorized here are key deletion/addition
on an existing user and password change.
On an existing user, CAN NOT BE MODIFIED:
person = persons[0]
keys = [person['pkey']]
#Get all the person's keys
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
keys_dict = self.iotlab_api.GetKeys(keys)
+=======
+ keys_dict = self.slab_api.GetKeys(keys)
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
# Delete all stale keys, meaning the user has only one key
#at a time
hrn = sfa_record['hrn']
if sfa_record_type == 'user':
+<<<<<<< HEAD:sfa/iotlab/iotlabdriver.py
#get user from iotlab ldap
person = self.iotlab_api.GetPersons(sfa_record)
#No registering at a given site in Iotlab.
#Once registered to the LDAP, all iotlab sites are
+=======
+ #get user from senslab ldap
+ person = self.slab_api.GetPersons(sfa_record)
+ #No registering at a given site in Senslab.
+ #Once registered to the LDAP, all senslab sites are
+>>>>>>> 3fe7429... SA:sfa/senslab/slabdriver.py
#accesible.
if person :
#Mark account as disabled in ldap