2 File used to handle all the nodes querying:
3 - get nodes list along with their properties
5 from sfa.util.sfalogging import logger
7 class CortexlabQueryTestbed:
12 def get_all_nodes(self, node_filter_dict=None, return_fields_list=None):
13 """Get all the nodes and their properties. Called by GetNodes.
15 Filtering on nodes properties can be done here or in GetNodes.
16 Search for specific nodes if some filters are specified. Returns all
17 the nodes properties if no return_fields_list given.
20 :param node_filter_dict: dictionary of lists with node properties. For
21 instance, if you want to look for a specific node with its hrn, the
22 node_filter_dict should be {'hrn': [hrn_of_the_node]}.
23 :type node_filter_dict: dict
24 :param return_fields_list: list of specific fields the user wants to be
26 :type return_fields_list: list
27 :returns: list of dictionaries with node properties
30 TODO: Define which properties have to be listed here. Useful ones:
31 node architecture, radio type, position (x,y,z)
34 # Get the nodes here, eventually filter here
35 # See iotlabapi.py GetNodes to get the filtering (node_filter_dict and
36 # return_fields_list ) part, if necessary
39 {'hrn': 'iotlab.wsn430-11.devlille.iot-lab.info',
40 'archi': 'wsn430', 'mobile': 'True',
41 'hostname': 'wsn430-11.devlille.iot-lab.info',
42 'site': 'devlille', 'mobility_type': 'None',
43 'boot_state': 'Suspected',
44 'node_id': 'wsn430-11.devlille.iot-lab.info',
45 'radio': 'cc2420', 'posx': '2.3', 'posy': '2.3',
46 'node_number': 11, 'posz': '1'},
47 {'hrn': 'iotlab.wsn430-10.devlille.iot-lab.info',
48 'archi': 'wsn430', 'mobile': 'True',
49 'hostname': 'wsn430-10.devlille.iot-lab.info',
50 'site': 'devlille', 'mobility_type': 'None',
51 'boot_state': 'Alive', 'node_id': 'wsn430-10.devlille.iot-lab.info',
52 'radio': 'cc2420', 'posx': '1.3', 'posy': '2.3', 'node_number': 10,
54 {'hrn': 'iotlab.wsn430-1.devlille.iot-lab.info',
55 'archi': 'wsn430', 'mobile': 'False',
56 'hostname': 'wsn430-1.devlille.iot-lab.info',
57 'site': 'devlille', 'mobility_type': 'None',
58 'boot_state': 'Alive', 'node_id': 'wsn430-1.devlille.iot-lab.info',
59 'radio': 'cc2420', 'posx': '0.3', 'posy': '0.3', 'node_number': 1,
66 def get_sites(self, site_filter_name_list=None, return_fields_list=None):
68 """Get the different cortexlab sites and for each sites, the nodes
69 hostnames on this site.
71 :param site_filter_name_list: used to specify specific sites
72 :param return_fields_list: fields that has to be returned
73 :type site_filter_name_list: list
74 :type return_fields_list: list
75 :rtype: list of dictionaries
79 {'address_ids': [], 'slice_ids': [], 'name': 'iotlab',
80 'node_ids': [u'wsn430-11.devlille.iot-lab.info',
81 u'wsn430-10.devlille.iot-lab.info', u'wsn430-1.devlille.iot-lab.info'],
82 'url': 'https://portal.senslab.info', 'person_ids': [],
83 'site_tag_ids': [], 'enabled': True, 'site': 'devlille',
84 'longitude': '- 2.10336', 'pcu_ids': [], 'max_slivers': None,
85 'max_slices': None, 'ext_consortium_id': None, 'date_created': None,
86 'latitude': '48.83726', 'is_public': True, 'peer_site_id': None,
87 'peer_id': None, 'abbreviated_name': 'iotlab'}]
88 # list of dict with mandatory keys ['name', 'node_ids', 'longitude',
89 # 'site' ]. Value for key node_ids is a hostname list.
90 # See iotlabapi.py GetSites to get the filtering
94 def get_reserved_nodes(self, username):
95 """Get list of leases.
97 Get the leases for the username if specified, otherwise get all the
100 :param username: user's LDAP login
101 :type username: string
102 :returns: list of reservations dict
103 :rtype: list of dictionaries
106 reserved_nodes_list_dict = None
108 reserved_nodes_list_dict = [{'lease_id': 1658,
109 'reserved_nodes': [ 'wsn430-11.devlille.iot-lab.info'], 'state':
110 'Waiting', 'user': 'avakian', 'resource_ids': [11],
111 't_from': 1412938800, 't_until': 1412942640}]
113 return reserved_nodes_list_dict
115 def schedule_experiment(self, lease_dict):
116 """Schedule/ run an experiment based on the information provided in the
119 :param lease_dict: contains lease_start_time, lease_duration,
120 added_nodes, slice_name , slice_user, grain:
121 :type lease_dict: dictionary
125 answer['id'] = None #experiment id
126 answer['msg'] = None #message in case of error
131 # Launch the experiment here
135 def delete_experiment(self, experiment_id, username):
136 """Delete the experiment designated by its experiment id and its user.
138 :param experiment_id: experiment identifier
139 :param username: user's LDAP login
140 :type experiment_id: integer
141 :type username: string
142 :returns: dict with delete status {'status': True of False}
145 TODO: If the username is not necessary to delete the lease, then you can
146 remove it from the parameters, given that you propagate the changes
148 # Delete the experiment here. Ret['status'] should be True or False
149 # depending if the delete was effective or not.