Added site in Slab RSpec format, for easier filtering
authorSandrine Avakian <sandrine.avakian@inria.fr>
Wed, 13 Feb 2013 13:08:43 +0000 (14:08 +0100)
committerSandrine Avakian <sandrine.avakian@inria.fr>
Wed, 13 Feb 2013 13:08:43 +0000 (14:08 +0100)
on the nodes.
+ Added SlabLocation class in slabv1Node
+ Changed connecton information which is based on
the location of the node. If nodes from multiples sites are selected, the user
is told how to connect via ssh on each site in the network item, with the "ssh"
attribute list.
Added a check upon lease creation, so that the lease duration
is compliant with Senslab's minimun experiment duration.

sfa/rspecs/elements/versions/slabv1Node.py
sfa/rspecs/versions/slabv1.py
sfa/senslab/slabaggregate.py
sfa/senslab/slabdriver.py
testbeds/senslab/tests/TestSuite.py

index 780a299..e70b8b5 100644 (file)
@@ -19,13 +19,18 @@ class SlabNode(Node):
 
 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.
@@ -39,9 +44,12 @@ class Slabv1Node:
 
         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']))
 
         
@@ -58,7 +66,7 @@ class Slabv1Node:
         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:
@@ -87,7 +95,7 @@ class Slabv1Node:
             # 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' :
@@ -145,7 +153,7 @@ class Slabv1Node:
         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):
@@ -169,7 +177,8 @@ class Slabv1Node:
                                             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) \
index 32872ac..39addda 100644 (file)
@@ -59,8 +59,8 @@ class Slabv1(RSpecVersion):
     def get_slice_timeslot(self ):
         return Slabv1Timeslot.get_slice_timeslot(self.xml)
     
-    def add_connection_information(self, ldap_username):
-        return Slabv1Node.add_connection_information(self.xml,ldap_username)
+    def add_connection_information(self, ldap_username, sites_set):
+        return Slabv1Node.add_connection_information(self.xml,ldap_username, sites_set)
     
     def add_nodes(self, nodes, check_for_dupes=False):
         return Slabv1Node.add_nodes(self.xml,nodes )
index 9a20226..1c985d0 100644 (file)
@@ -2,8 +2,7 @@ import time
 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
@@ -13,7 +12,8 @@ from sfa.rspecs.elements.granularity import Granularity
 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
@@ -57,7 +57,8 @@ class SlabAggregate:
         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" \
@@ -82,7 +83,6 @@ class SlabAggregate:
             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', 
@@ -96,8 +96,9 @@ class SlabAggregate:
         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
 
@@ -193,11 +194,13 @@ class SlabAggregate:
                 # 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'] = \
@@ -217,16 +220,19 @@ class SlabAggregate:
                 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 :
@@ -354,6 +360,11 @@ class SlabAggregate:
         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 :
@@ -370,7 +381,7 @@ class SlabAggregate:
                 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:
index 36c8ef8..a8b6cd1 100644 (file)
@@ -240,10 +240,13 @@ class SlabDriver(Driver):
                     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
@@ -1313,9 +1316,10 @@ class SlabDriver(Driver):
     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):
index 8100bb5..ca90163 100644 (file)
@@ -316,7 +316,7 @@ def  TestSfi(arg = None):
     show = os.system("sfi.py show senslab.avakian")
 
     print " =================    SFI.PY SLICES       ============="
-    show_node  = os.system("sfi.py show senslab.node67.grenoble.senslab.info")
+    show_node  = os.system("sfi.py show senslab.node6.devlille.senslab.info")
 
     print " =================    SFI.PY LIST SLICE   ============="
     slices = os.system("sfi.py slices")