Cleaning and documenting cortexlabdriver.
[sfa.git] / sfa / cortexlab / cortexlabaggregate.py
index e91b57b..7cc1294 100644 (file)
@@ -68,14 +68,13 @@ class CortexlabAggregate:
         self.driver = driver
 
     def get_slice_and_slivers(self, slice_xrn, login=None):
-        """
+        """Returns a dict of slivers based on the sliver's node_id.
+
         Get the slices and the associated leases if any, from the cortexlab
-            testbed. One slice can have mutliple leases.
-            For each slice, get the nodes in the  associated lease
-            and create a sliver with the necessary info and insert it into the
-            sliver dictionary, keyed on the node hostnames.
-            Returns a dict of slivers based on the sliver's node_id.
-            Called by get_rspec.
+        testbed. One slice can have mutliple leases. For each slice, get the
+        nodes in the  associated lease and create a sliver with the necessary
+        info and insert it into the sliver dictionary, keyed on the node
+        hostnames.Called by get_rspec.
 
 
         :param slice_xrn: xrn of the slice
@@ -101,7 +100,7 @@ class CortexlabAggregate:
         slice_name = slice_hrn
 
         # GetSlices always returns a list, even if there is only one element
-        slices = self.driver.cortexlab_api.GetSlices(slice_filter=str(slice_name),
+        slices = self.driver.testbed_shell.GetSlices(slice_filter=str(slice_name),
                                                   slice_filter_type='slice_hrn',
                                                   login=login)
 
@@ -155,7 +154,7 @@ class CortexlabAggregate:
         researchers = [sfa_slice['reg_researchers'][0].__dict__]
         # look in ldap:
         ldap_username = None
-        ret =  self.driver.iotlab_api.GetPersons(researchers)
+        ret =  self.driver.testbed_shell.GetPersons(researchers)
         if len(ret) != 0:
             ldap_username = ret[0]['uid']
 
@@ -203,9 +202,9 @@ class CortexlabAggregate:
                     return []
 
         # get the granularity in second for the reservation system
-        grain = self.driver.cortexlab_api.GetLeaseGranularity()
+        grain = self.driver.testbed_shell.GetLeaseGranularity()
 
-        nodes = self.driver.cortexlab_api.GetNodes()
+        nodes = self.driver.testbed_shell.GetNodes()
 
         nodes_dict = {}
 
@@ -217,7 +216,7 @@ class CortexlabAggregate:
         logger.debug("CortexlabAggregate api get_nodes slices  %s "
                      % (slices))
 
-        reserved_nodes = self.driver.cortexlab_api.GetNodesCurrentlyInUse()
+        reserved_nodes = self.driver.testbed_shell.GetNodesCurrentlyInUse()
         logger.debug("CortexlabAggregate api get_nodes slice_nodes_list  %s "
                      % (slice_nodes_list))
         for node in nodes:
@@ -228,12 +227,12 @@ class CortexlabAggregate:
 
 
 
-                cortexlab_xrn = cortexlab_xrn_object(self.driver.cortexlab_api.root_auth,
+                cortexlab_xrn = cortexlab_xrn_object(self.driver.testbed_shell.root_auth,
                                                node['hostname'])
                 rspec_node['component_id'] = cortexlab_xrn.urn
                 rspec_node['component_name'] = node['hostname']
                 rspec_node['component_manager_id'] = \
-                                hrn_to_urn(self.driver.cortexlab_api.root_auth,
+                                hrn_to_urn(self.driver.testbed_shell.root_auth,
                                 'authority+sa')
 
                 # Iotlab's nodes are federated : there is only one authority
@@ -279,13 +278,12 @@ class CortexlabAggregate:
 
     def get_all_leases(self, ldap_username):
         """
-
-        Get list of lease dictionaries which all have the mandatory keys
-        ('lease_id', 'hostname', 'site_id', 'name', 'start_time', 'duration').
-        All the leases running or scheduled are returned.
+        Get list of lease dictionaries which all have the following
+        mandatory keys ('lease_id', 'hostname', 'site_id', 'name', 'start_time',
+        'duration'). All the leases running or scheduled are returned.
 
         :param ldap_username: if ldap uid is not None, looks for the leases
-        belonging to this user.
+            belonging to this user.
         :type ldap_username: string
         :returns: rspec lease dictionary with keys lease_id, component_id,
             slice_id, start_time, duration.
@@ -305,8 +303,8 @@ class CortexlabAggregate:
 
         logger.debug("CortexlabAggregate  get_all_leases ldap_username %s "
                      % (ldap_username))
-        leases = self.driver.cortexlab_api.GetLeases(login=ldap_username)
-        grain = self.driver.cortexlab_api.GetLeaseGranularity()
+        leases = self.driver.testbed_shell.GetLeases(login=ldap_username)
+        grain = self.driver.testbed_shell.GetLeaseGranularity()
         # site_ids = []
         rspec_leases = []
         for lease in leases:
@@ -316,7 +314,7 @@ class CortexlabAggregate:
                 rspec_lease['lease_id'] = lease['lease_id']
 
                 cortexlab_xrn = cortexlab_xrn_object(
-                    self.driver.cortexlab_api.root_auth, node)
+                    self.driver.testbed_shell.root_auth, node)
                 rspec_lease['component_id'] = cortexlab_xrn.urn
                 #rspec_lease['component_id'] = hostname_to_urn(self.driver.hrn,\
                                         #site, node['hostname'])