Adding docs in cortexlab.
[sfa.git] / sfa / cortexlab / cortexlabnodes.py
index 15ef6e6..a264b4e 100644 (file)
@@ -1,6 +1,15 @@
 """
 File used to handle all the nodes querying:
-- get nodes list along with their properties
+* get nodes list along with their properties with get_all_nodes
+
+* get sites and their properties with get_sites.
+
+* get nodes involved in leases sorted by lease id, with get_reserved_nodes.
+
+* create a lease (schedule an experiment) with schedule_experiment.
+
+* delete a lease with delete_experiment.
+
 """
 
 class CortexlabQueryNodes:
@@ -12,11 +21,9 @@ class CortexlabQueryNodes:
         """
         Get all the nodes and their properties. Called by GetNodes.
         Filtering on nodes properties can be done here or in GetNodes.
-        Search for specific nodes if some filters are
-        specified.Returns all the nodes properties if no return_fields_list
-        given.
-        TODO: Define which properties have to be listed here. Useful ones:
-        node architecture, radio type, position (x,y,z)
+        Search for specific nodes if some filters are specified. Returns all
+        the nodes properties if return_fields_list is None.
+
 
         :param node_filter_dict: dictionary of lists with node properties. For
             instance, if you want to look for a specific node with its hrn,
@@ -27,11 +34,15 @@ class CortexlabQueryNodes:
         :type return_fields_list: list
         :returns: list of dictionaries with node properties
         :rtype: list
+
+        TODO: Define which properties have to be listed here. Useful ones:
+        node architecture, radio type, position (x,y,z)
         """
         node_dict_list = None
         # Get the nodes here, eventually filter here
         # See iotlabapi.py GetNodes to get the filtering (node_filter_dict and
         # return_fields_list ) part, if necessary
+        # Format used in iotlab
         node_dict_list = [
         {'hrn': 'iotlab.wsn430-11.devlille.iot-lab.info',
         'archi': 'wsn430', 'mobile': 'True',
@@ -69,6 +80,7 @@ class CortexlabQueryNodes:
         :param return_fields_list: fields that has to be returned
         :type site_filter_name_list: list
         :type return_fields_list: list
+        :rtype: list of dictionaries
         """
         site_dict_list = None
         site_dict_list = [
@@ -93,25 +105,34 @@ class CortexlabQueryNodes:
         :param username: user's LDAP login
         :type username: string
         :returns: list of reservations dict
-        :rtype: dict list
+        :rtype: list of dictionaries
 
         """
         reserved_nodes_list_dict = None
+
+        reserved_nodes_list_dict = [{'lease_id': 1658,
+        'reserved_nodes': [ 'wsn430-11.devlille.iot-lab.info'], 'state':
+        'Waiting', 'user': 'avakian', 'resource_ids': [11],
+        't_from': 1412938800, 't_until': 1412942640}]
+
         return reserved_nodes_list_dict
 
     def schedule_experiment(self, lease_dict):
         """Schedule/ run an experiment based on the information provided in the
         lease dictionary.
 
-        :param lease_dict: contains  lease_start_time,
-        lease_duration, added_nodes, slice_name , slice_user, grain:
+        :param lease_dict: contains  lease_start_time, lease_duration,
+            added_nodes, slice_name , slice_user, grain:
         :type lease_dict: dictionary
-
+        :rtype: dict
         """
         answer = {}
         answer['id'] = None #experiment id
         answer['msg'] = None #message in case of error
 
+
+        answer['id'] = 1659
+
         # Launch the experiment here
 
         return answer
@@ -126,6 +147,7 @@ class CortexlabQueryNodes:
         :param experiment_id: experiment identifier
         :type experiment_id : integer
         :param username: user's LDAP login
+        :type experiment_id: integer
         :type username: string
         :returns: dict with delete status {'status': True of False}
         :rtype: dict
@@ -134,4 +156,4 @@ class CortexlabQueryNodes:
         # depending if the delete was effective or not.
         ret = {}
         ret['status'] = None
-        return ret
\ No newline at end of file
+        return ret