class SlabPosition(Element):
fields = ['posx', 'posy','posz']
+
+class SlabLocation(Location):
+ fields = list(Location.fields)
+ fields.extend (['site'])
+
class Slabv1Node:
@staticmethod
- def add_connection_information(xml, ldap_username):
+ def add_connection_information(xml, ldap_username, sites_set):
""" Adds login and ssh connection info in the network item in
the xml. Does not create the network element, therefore
should be used after add_nodes, which creates the network item.
slab_network_dict = {}
slab_network_dict['login'] = ldap_username
- slab_network_dict['vm'] = 'ssh ' + ldap_username + \
- '@grenoble.senslab.info'
- network_elem.set('vm', unicode(slab_network_dict['vm']))
+
+ slab_network_dict['ssh'] = \
+ ['ssh ' + ldap_username + '@'+site+'.senslab.info' \
+ for site in sites_set]
+ network_elem.set('ssh', \
+ unicode(slab_network_dict['ssh']))
network_elem.set('login', unicode( slab_network_dict['login']))
else:
network_elem = xml
- #logger.debug("slabv1Node \t add_nodes nodes %s \r\n "%(nodes))
+ logger.debug("slabv1Node \t add_nodes nodes %s \r\n "%(nodes[0]))
node_elems = []
#Then add nodes items to the network item in the xml
for node in nodes:
# set location
if attribute is 'location':
node_elem.add_instance('location', node['location'], \
- Location.fields)
+ SlabLocation.fields)
# add granularity of the reservation system
#TODO put the granularity in network instead SA 18/07/12
if attribute is 'granularity' :
node_elems = xml.xpath(xpath)
logger.debug("SLABV1NODE \tget_nodes_with_slivers \
node_elems %s"%(node_elems))
- return Slabv1Node.get_node_objs(node_elems)
+ return Slabv1Node.get_node_objs(node_elems)
@staticmethod
def get_node_objs(node_elems):
for location_elem in location_elems]
if len(locations) > 0:
node['location'] = locations[0]
-
+
+
# get interfaces
iface_elems = node_elem.xpath('./default:interface | ./interface')
node['interfaces'] = [iface_elem.get_instance(Interface) \
from sfa.util.xrn import hrn_to_urn, urn_to_hrn, get_authority
from sfa.rspecs.rspec import RSpec
-from sfa.rspecs.elements.versions.slabv1Node import SlabPosition
-from sfa.rspecs.elements.location import Location
+#from sfa.rspecs.elements.location import Location
from sfa.rspecs.elements.hardware_type import HardwareType
from sfa.rspecs.elements.login import Login
from sfa.rspecs.elements.services import Services
from sfa.rspecs.version_manager import VersionManager
-from sfa.rspecs.elements.versions.slabv1Node import SlabNode
+from sfa.rspecs.elements.versions.slabv1Node import SlabPosition, SlabNode, \
+ SlabLocation
from sfa.util.sfalogging import logger
from sfa.util.xrn import Xrn
slice_name = slice_hrn
slices = self.driver.GetSlices(slice_filter= str(slice_name), \
- slice_filter_type = 'slice_hrn', login=login)
+ slice_filter_type = 'slice_hrn', \
+ login=login)
logger.debug("Slabaggregate api \tget_slice_and_slivers \
sfa_slice %s \r\n slices %s self.driver.hrn %s" \
for node in node_ids_list:
sliver_xrn = Xrn(slice_urn, type='sliver', id=node)
sliver_xrn.set_authority(self.driver.hrn)
- #node_id = self.driver.root_auth + '.' + node_id
sliver = Sliver({'sliver_id':sliver_xrn.urn,
'name': sfa_slice['hrn'],
'type': 'slab-node',
if get_authority (sfa_slice['hrn']) == self.driver.root_auth:
tmp = sfa_slice['hrn'].split('.')
ldap_username = tmp[1].split('_')[0]
- vmaddr = 'ssh ' + ldap_username + '@grenoble.senslab.info'
- slivers['default_sliver'] = {'vm': vmaddr , 'login': ldap_username}
+ ssh_access = None
+ slivers['default_sliver'] = {'ssh': ssh_access , \
+ 'login': ldap_username}
#TODO get_slice_and_slivers Find the login of the external user
# xxx how to retrieve site['login_base']
#site_id=node['site_id']
#site=sites_dict[site_id]
+
rspec_node['mobile'] = node['mobile']
rspec_node['archi'] = node['archi']
rspec_node['radio'] = node['radio']
- slab_xrn = slab_xrn_object(self.driver.root_auth, node['hostname'])
+ slab_xrn = slab_xrn_object(self.driver.root_auth, \
+ node['hostname'])
rspec_node['component_id'] = slab_xrn.urn
rspec_node['component_name'] = node['hostname']
rspec_node['component_manager_id'] = \
if node['hostname'] in reserved_nodes:
rspec_node['boot_state'] = "Reserved"
rspec_node['exclusive'] = 'true'
- rspec_node['hardware_types'] = [HardwareType({'name': 'slab-node'})]
+ rspec_node['hardware_types'] = [HardwareType({'name': \
+ 'slab-node'})]
# only doing this because protogeni rspec needs
# to advertise available initscripts
# add site/interface info to nodes.
- # assumes that sites, interfaces and tags have already been prepared.
- #site = sites_dict[node['site_id']]
- location = Location({'country':'France'})
+ # assumes that sites, interfaces and tags have already been
+ #prepared.
+
+ location = SlabLocation({'country':'France','site': \
+ node['site']})
rspec_node['location'] = location
-
+
position = SlabPosition()
for field in position :
if lease_option in ['all', 'resources']:
#if not options.get('list_leases') or options.get('list_leases') and options['list_leases'] != 'leases':
nodes = self.get_nodes(slices, slivers)
+ logger.debug("\r\n \r\n SlabAggregate \ lease_option %s get rspec ******* nodes %s"\
+ %(lease_option, nodes[0]))
+
+ sites_set = set([node['location']['site'] for node in nodes] )
+
#In case creating a job, slice_xrn is not set to None
rspec.version.add_nodes(nodes)
if slice_xrn :
ldap_username = tmp[1].split('_')[0]
if version.type == "Slab":
- rspec.version.add_connection_information(ldap_username)
+ rspec.version.add_connection_information(ldap_username, sites_set)
default_sliver = slivers.get('default_sliver', [])
if default_sliver:
single_requested_lease['start_time'] = \
lease.get('start_time')
single_requested_lease['duration'] = lease.get('duration')
-
- requested_lease_list.append(single_requested_lease)
-
- logger.debug("SLABDRIVER.PY \tcreate_sliver APRESLEASE" )
+ #Check the experiment's duration is valid before adding
+ #the lease to the requested leases list
+ duration_in_seconds = \
+ int(single_requested_lease['duration'])*60
+ if duration_in_seconds > self.GetLeaseGranularity():
+ requested_lease_list.append(single_requested_lease)
+
#Create dict of leases by start_time, regrouping nodes reserved
#at the same
#time, for the same amount of time = one job on OAR
def GetLeaseGranularity(self):
""" Returns the granularity of Senslab testbed.
OAR returns seconds for experiments duration.
- Defined in seconds. """
+ Defined in seconds.
+ Experiments which last less than 10 min are invalid"""
- grain = 60
+ grain = 600
return grain
def update_jobs_in_slabdb(self, job_oar_list, jobs_psql):