from sfa.iotlab.iotlabslices import IotlabSlices
-from sfa.iotlab.iotlabapi import IotlabTestbedAPI
+from sfa.iotlab.iotlabshell import IotlabShell
class IotlabDriver(Driver):
"""
Driver.__init__(self, config)
self.config = config
- self.iotlab_api = IotlabTestbedAPI(config)
+ self.testbed_shell = IotlabShell(config)
self.cache = None
def augment_records_with_testbed_info(self, record_list):
# look for node info using GetNodes
# the record is about one node only
filter_dict = {'hrn': [record['hrn']]}
- node_info = self.iotlab_api.GetNodes(filter_dict)
+ node_info = self.testbed_shell.GetNodes(filter_dict)
# the node_info is about one node only, but it is formatted
# as a list
record.update(node_info[0])
'key_ids': ''})
#Get iotlab slice record and oar job id if any.
- recslice_list = self.iotlab_api.GetSlices(
+ recslice_list = self.testbed_shell.GetSlices(
slice_filter=str(record['hrn']),
slice_filter_type='slice_hrn')
fill_record_info oar_job_id %s "
% (rec['oar_job_id']))
- record['node_ids'] = [self.iotlab_api.root_auth +
+ record['node_ids'] = [self.testbed_shell.root_auth +
'.' + hostname for hostname
in rec['node_ids']]
except KeyError:
#The record is a SFA user record.
#Get the information about his slice from Iotlab's DB
#and add it to the user record.
- recslice_list = self.iotlab_api.GetSlices(
+ recslice_list = self.testbed_shell.GetSlices(
slice_filter=record['record_id'],
slice_filter_type='record_id_user')
'hrn': recslice_list[0]['hrn']})
#GetPersons takes [] as filters
- user_iotlab = self.iotlab_api.GetPersons([record])
+ user_iotlab = self.testbed_shell.GetPersons([record])
record.update(user_iotlab[0])
#For client_helper.py compatibility
"""
#First get the slice with the slice hrn
- slice_list = self.iotlab_api.GetSlices(slice_filter=slice_hrn,
+ slice_list = self.testbed_shell.GetSlices(slice_filter=slice_hrn,
slice_filter_type='slice_hrn')
if len(slice_list) == 0:
slice_nodes_list = []
slice_nodes_list = one_slice['node_ids']
#Get all the corresponding nodes details
- nodes_all = self.iotlab_api.GetNodes(
+ nodes_all = self.testbed_shell.GetNodes(
{'hostname': slice_nodes_list},
['node_id', 'hostname', 'site', 'boot_state'])
nodeall_byhostname = dict([(one_node['hostname'], one_node)
if not lease.get('lease_id'):
if get_authority(lease['component_id']) == \
- self.iotlab_api.root_auth:
+ self.testbed_shell.root_auth:
single_requested_lease['hostname'] = \
iotlab_xrn_to_hostname(\
lease.get('component_id').strip())
#the lease to the requested leases list
duration_in_seconds = \
int(single_requested_lease['duration'])
- if duration_in_seconds >= self.iotlab_api.GetMinExperimentDurationInGranularity():
+ if duration_in_seconds >= self.testbed_shell.GetMinExperimentDurationInGranularity():
requested_lease_list.append(single_requested_lease)
return requested_lease_list
#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]
+ #if node.get('authority_id') is self.testbed_shell.root_auth]
#l = [ node for node in rspec.version.get_nodes_with_slivers() ]
#logger.debug("SLADRIVER \tcreate_sliver requested_slivers \
#requested_slivers %s listnodes %s" \
delete_sliver .
"""
- sfa_slice_list = self.iotlab_api.GetSlices(
+ sfa_slice_list = self.testbed_shell.GetSlices(
slice_filter=slice_hrn,
slice_filter_type='slice_hrn')
logger.debug("IOTLABDRIVER.PY delete_sliver peer %s \
\r\n \t sfa_slice %s " % (peer, sfa_slice))
try:
- self.iotlab_api.DeleteSliceFromNodes(sfa_slice)
+ self.testbed_shell.DeleteSliceFromNodes(sfa_slice)
return True
except:
return False
# get data from db
- slices = self.iotlab_api.GetSlices()
+ slices = self.testbed_shell.GetSlices()
logger.debug("IOTLABDRIVER.PY \tlist_slices hrn %s \r\n \r\n"
% (slices))
slice_hrns = [iotlab_slice['hrn'] for iotlab_slice in slices]
if new_key:
# must check this key against the previous one if it exists
- persons = self.iotlab_api.GetPersons([old_sfa_record])
+ persons = self.testbed_shell.GetPersons([old_sfa_record])
person = persons[0]
keys = [person['pkey']]
#Get all the person's keys
- keys_dict = self.iotlab_api.GetKeys(keys)
+ keys_dict = self.testbed_shell.GetKeys(keys)
# Delete all stale keys, meaning the user has only one key
#at a time
else:
#remove all the other keys
for key in keys_dict:
- self.iotlab_api.DeleteKey(person, key)
- self.iotlab_api.AddPersonKey(
+ self.testbed_shell.DeleteKey(person, key)
+ self.testbed_shell.AddPersonKey(
person, {'sshPublicKey': person['pkey']},
{'sshPublicKey': new_key})
return True
if sfa_record_type == 'user':
#get user from iotlab ldap
- person = self.iotlab_api.GetPersons(sfa_record)
+ person = self.testbed_shell.GetPersons(sfa_record)
#No registering at a given site in Iotlab.
#Once registered to the LDAP, all iotlab sites are
#accesible.
if person:
#Mark account as disabled in ldap
- return self.iotlab_api.DeletePerson(sfa_record)
+ return self.testbed_shell.DeletePerson(sfa_record)
elif sfa_record_type == 'slice':
- if self.iotlab_api.GetSlices(slice_filter=hrn,
+ if self.testbed_shell.GetSlices(slice_filter=hrn,
slice_filter_type='slice_hrn'):
- ret = self.iotlab_api.DeleteSlice(sfa_record)
+ ret = self.testbed_shell.DeleteSlice(sfa_record)
return True