Renaming variable holding a reference to the iotlab database.
[sfa.git] / sfa / iotlab / iotlabshell.py
index 1bed89c..f1efa73 100644 (file)
@@ -37,7 +37,7 @@ class IotlabShell():
         :param config: configuration object from sfa.util.config
         :type config: Config object
         """
-        self.iotlab_db = TestbedAdditionalSfaDB(config)
+        self.leases_db = TestbedAdditionalSfaDB(config)
         self.oar = OARrestapi()
         self.ldap = LDAPapi()
         self.time_format = "%Y-%m-%d %H:%M:%S"
@@ -57,8 +57,8 @@ class IotlabShell():
         """
         return IotlabShell._MINIMUM_DURATION
 
-    @staticmethod
-    def GetPeers(peer_filter=None ):
+
+    def GetPeers(self, peer_filter=None ):
         """ Gathers registered authorities in SFA DB and looks for specific peer
         if peer_filter is specified.
         :param peer_filter: name of the site authority looked for.
@@ -405,9 +405,7 @@ class IotlabShell():
         return return_node_list
 
 
-
-    @staticmethod
-    def AddSlice(slice_record, user_record):
+    def AddSlice(self, slice_record, user_record):
         """
 
         Add slice to the local iotlab sfa tables if the slice comes
@@ -526,8 +524,8 @@ class IotlabShell():
                     delete_failed))
         return delete_failed or True
 
-    @staticmethod
-    def __add_person_to_db(user_dict):
+
+    def __add_person_to_db(self, user_dict):
         """
         Add a federated user straight to db when the user issues a lease
         request with iotlab nodes and that he has not registered with iotlab
@@ -847,8 +845,8 @@ class IotlabShell():
 
         logger.debug("IOTLAB_API \r\n \r\n \t AddLeases iotlab_ex_row %s" \
                 %(iotlab_ex_row))
-        self.iotlab_db.testbed_session.add(iotlab_ex_row)
-        self.iotlab_db.testbed_session.commit()
+        self.leases_db.testbed_session.add(iotlab_ex_row)
+        self.leases_db.testbed_session.commit()
 
         logger.debug("IOTLAB_API \t AddLeases hostname_list start_time %s " \
                 %(start_time))
@@ -954,7 +952,7 @@ class IotlabShell():
         #the same user in LDAP SA 27/07/12
         job_oar_list = []
 
-        jobs_psql_query = self.iotlab_db.testbed_session.query(LeaseTableXP).all()
+        jobs_psql_query = self.leases_db.testbed_session.query(LeaseTableXP).all()
         jobs_psql_dict = dict([(row.experiment_id, row.__dict__)
                                for row in jobs_psql_query])
         #jobs_psql_dict = jobs_psql_dict)
@@ -1020,7 +1018,7 @@ class IotlabShell():
         if lease_filter_dict is None:
             reservation_list = unfiltered_reservation_list
 
-        self.iotlab_db.update_experiments_in_additional_sfa_db(job_oar_list, jobs_psql_id_list)
+        self.leases_db.update_experiments_in_additional_sfa_db(job_oar_list, jobs_psql_id_list)
 
         logger.debug(" IOTLAB_API.PY \tGetLeases reservation_list %s"
                      % (reservation_list))
@@ -1101,14 +1099,14 @@ class IotlabShell():
 
         #"""
         ##new_row = FederatedToIotlab(iotlab_hrn, federated_hrn)
-        ##self.iotlab_db.testbed_session.add(new_row)
-        ##self.iotlab_db.testbed_session.commit()
+        ##self.leases_db.testbed_session.add(new_row)
+        ##self.leases_db.testbed_session.commit()
 
         #logger.debug("IOTLAB_API UpdatePerson EMPTY - DO NOTHING \r\n ")
         #return
 
-    @staticmethod
-    def GetKeys(key_filter=None):
+
+    def GetKeys(self, key_filter=None):
         """Returns a dict of dict based on the key string. Each dict entry
         contains the key id, the ssh key, the user's email and the
         user's hrn.
@@ -1162,10 +1160,7 @@ class IotlabShell():
         return ret['bool']
 
 
-
-
-    @staticmethod
-    def _sql_get_slice_info(slice_filter):
+    def _sql_get_slice_info(self, slice_filter):
         """
         Get the slice record based on the slice hrn. Fetch the record of the
         user associated with the slice by using joinedload based on the
@@ -1201,8 +1196,7 @@ class IotlabShell():
         else:
             return None
 
-    @staticmethod
-    def _sql_get_slice_info_from_user(slice_filter):
+    def _sql_get_slice_info_from_user(self, slice_filter):
         """
         Get the slice record based on the user recordid by using a joinedload
         on the relationship reg_slices_as_researcher. Format the sql record