Add code to kill restperfclient if hung.
[integration/test.git] / csit / libraries / SwitchManager.py
1 """
2 Library for the robot based system test tool of the OpenDaylight project.
3 Authors: Baohua Yang@IBM, Denghui Huang@IBM
4 Updated: 2013-11-10
5 """
6 from robot.libraries.BuiltIn import BuiltIn
7
8
9 class SwitchManager(object):
10     def __init__(self):
11         self.builtin = BuiltIn()
12
13     def extract_all_nodes(self, content):
14         """
15         Return all nodes.
16         """
17         if isinstance(content, dict) and 'nodeProperties' in content:
18             self.builtin.log("18")
19             return [e.get('node') for e in content['nodeProperties']]
20         else:
21             self.builtin.log("21")
22             return None
23
24     def extract_all_properties(self, content, property_type):
25         if isinstance(content, dict) and property_type in content:
26             self.builtin.log("26")
27             list1 = [e.get('properties') for e in content[property_type]]
28             self.builtin.log(list1)
29             return [e.get('properties') for e in content[property_type]]
30         else:
31             self.builtin.log("29")
32             return None
33
34     def extract_property_value(self, content, property, property_type):
35         res = self.extract_all_properties(content, property_type)
36         return [e.get(property) for e in res]
37
38     def extract_all_node_properties(self, content):
39         return self.extract_all_properties(content, 'nodeProperties')
40
41     def extract_node_property_values(self, content, property):
42         return self.extract_property_value(content, property, 'nodeProperties')
43
44     def extract_all_nodeconnector_properties(self, content):
45         return self.extract_all_properties(content, 'nodeConnectorProperties')
46
47     def extract_nodeconnector_property_values(self, content, property):
48         return self.extract_property_value(content, property, 'nodeConnectorProperties')