blob: 27a744a5e2ac73f54c82afc306a514f5ab246f23 [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001#!/usr/bin/python -u
2import sys
3from robot.libraries.BuiltIn import BuiltIn
4import imp
5import string
6
7
Chris Austenb29d2e82016-06-07 12:25:35 -05008def get_sensor(module_name, value):
Gunnar Millsdca35792018-03-26 10:05:38 -05009 m = imp.load_source('module.name', module_name)
Chris Austenb29d2e82016-06-07 12:25:35 -050010
Gunnar Millsdca35792018-03-26 10:05:38 -050011 for i in m.ID_LOOKUP['SENSOR']:
Chris Austenb29d2e82016-06-07 12:25:35 -050012
Gunnar Millsdca35792018-03-26 10:05:38 -050013 if m.ID_LOOKUP['SENSOR'][i] == value:
14 return i
Chris Austenb29d2e82016-06-07 12:25:35 -050015
Gunnar Millsdca35792018-03-26 10:05:38 -050016 return 0xFF
Chris Austenb29d2e82016-06-07 12:25:35 -050017
Chris Austenb29d2e82016-06-07 12:25:35 -050018
Gunnar Millsdca35792018-03-26 10:05:38 -050019def get_inventory_sensor(module_name, value):
20 m = imp.load_source('module.name', module_name)
Chris Austenb29d2e82016-06-07 12:25:35 -050021
Gunnar Millsdca35792018-03-26 10:05:38 -050022 value = string.replace(value, m.INVENTORY_ROOT, '<inventory_root>')
Chris Austenb29d2e82016-06-07 12:25:35 -050023
Gunnar Millsdca35792018-03-26 10:05:38 -050024 for i in m.ID_LOOKUP['SENSOR']:
25
26 if m.ID_LOOKUP['SENSOR'][i] == value:
27 return i
28
29 return 0xFF
Chris Austenb29d2e82016-06-07 12:25:35 -050030
31
32def get_inventory_list(module_name):
33
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050034 inventory_list = []
Gunnar Millsdca35792018-03-26 10:05:38 -050035 m = imp.load_source('module.name', module_name)
Chris Austenb29d2e82016-06-07 12:25:35 -050036
Gunnar Millsdca35792018-03-26 10:05:38 -050037 for i in m.ID_LOOKUP['FRU']:
38 s = m.ID_LOOKUP['FRU'][i]
39 s = s.replace('<inventory_root>', m.INVENTORY_ROOT)
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050040 inventory_list.append(s)
Chris Austenb29d2e82016-06-07 12:25:35 -050041
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050042 return inventory_list
Gunnar Millsdca35792018-03-26 10:05:38 -050043
Chris Austenb29d2e82016-06-07 12:25:35 -050044
45def get_inventory_fru_type_list(module_name, fru_type):
46
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050047 inventory_list = []
Gunnar Millsdca35792018-03-26 10:05:38 -050048 m = imp.load_source('module.name', module_name)
Chris Austenb29d2e82016-06-07 12:25:35 -050049
Gunnar Millsdca35792018-03-26 10:05:38 -050050 for i in m.FRU_INSTANCES.keys():
51 if m.FRU_INSTANCES[i]['fru_type'] == fru_type:
Gunnar Millsdca35792018-03-26 10:05:38 -050052 s = i.replace('<inventory_root>', m.INVENTORY_ROOT)
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050053 inventory_list.append(s)
Chris Austenb29d2e82016-06-07 12:25:35 -050054
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050055 return inventory_list
Gunnar Millsdca35792018-03-26 10:05:38 -050056
Chris Austenb29d2e82016-06-07 12:25:35 -050057
58def call_keyword(keyword):
Gunnar Millsdca35792018-03-26 10:05:38 -050059 return BuiltIn().run_keyword(keyword)
Tony Lee1e303ca2020-02-27 10:53:47 +080060
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