1#!/usr/bin/python -u
2import sys
3from robot.libraries.BuiltIn import BuiltIn
4import imp
5import string
6
7
8def get_sensor(module_name, value):
9    m = imp.load_source('module.name', module_name)
10
11    for i in m.ID_LOOKUP['SENSOR']:
12
13        if m.ID_LOOKUP['SENSOR'][i] == value:
14            return i
15
16    return 0xFF
17
18
19def get_inventory_sensor(module_name, value):
20    m = imp.load_source('module.name', module_name)
21
22    value = string.replace(value, m.INVENTORY_ROOT, '<inventory_root>')
23
24    for i in m.ID_LOOKUP['SENSOR']:
25
26        if m.ID_LOOKUP['SENSOR'][i] == value:
27            return i
28
29    return 0xFF
30
31
32def get_inventory_list(module_name):
33
34    inventory_list = []
35    m = imp.load_source('module.name', module_name)
36
37    for i in m.ID_LOOKUP['FRU']:
38        s = m.ID_LOOKUP['FRU'][i]
39        s = s.replace('<inventory_root>', m.INVENTORY_ROOT)
40        inventory_list.append(s)
41
42    return inventory_list
43
44
45def get_inventory_fru_type_list(module_name, fru_type):
46
47    inventory_list = []
48    m = imp.load_source('module.name', module_name)
49
50    for i in m.FRU_INSTANCES.keys():
51        if m.FRU_INSTANCES[i]['fru_type'] == fru_type:
52            s = i.replace('<inventory_root>', m.INVENTORY_ROOT)
53            inventory_list.append(s)
54
55    return inventory_list
56
57
58def call_keyword(keyword):
59    return BuiltIn().run_keyword(keyword)
60
61
62def get_FRU_component_name_list(module_name):
63    name_list = []
64    m = imp.load_source('module.name', module_name)
65
66    for name in m.FRU_COMPONENT_NAME:
67        name_list.append(name)
68        print(name)
69
70    return name_list
71
72
73def get_ipmi_rest_fru_field_map(module_name):
74
75    m = imp.load_source('module.name', module_name)
76
77    ipmi_rest_fru_field_map = dict.copy(m.ipmi_rest_fru_field_map)
78
79    return ipmi_rest_fru_field_map
80