blob: 78a72842b75f9030c91fd011c7a050e0ad96e2a1 [file] [log] [blame]
George Keishinge7e91712021-09-03 11:28:44 -05001#!/usr/bin/env python3 -u
George Keishingb1d2f492022-12-15 13:33:42 -06002import imp as imp
3import string as string
Patrick Williams20f38712022-12-08 06:18:26 -06004
5from robot.libraries.BuiltIn import BuiltIn
Chris Austenb29d2e82016-06-07 12:25:35 -05006
7
Chris Austenb29d2e82016-06-07 12:25:35 -05008def get_sensor(module_name, value):
Patrick Williams20f38712022-12-08 06:18:26 -06009 m = imp.load_source("module.name", module_name)
Chris Austenb29d2e82016-06-07 12:25:35 -050010
Patrick Williams20f38712022-12-08 06:18:26 -060011 for i in m.ID_LOOKUP["SENSOR"]:
12 if m.ID_LOOKUP["SENSOR"][i] == value:
Gunnar Millsdca35792018-03-26 10:05:38 -050013 return i
Chris Austenb29d2e82016-06-07 12:25:35 -050014
Gunnar Millsdca35792018-03-26 10:05:38 -050015 return 0xFF
Chris Austenb29d2e82016-06-07 12:25:35 -050016
Chris Austenb29d2e82016-06-07 12:25:35 -050017
Gunnar Millsdca35792018-03-26 10:05:38 -050018def get_inventory_sensor(module_name, value):
Patrick Williams20f38712022-12-08 06:18:26 -060019 m = imp.load_source("module.name", module_name)
Chris Austenb29d2e82016-06-07 12:25:35 -050020
Patrick Williams20f38712022-12-08 06:18:26 -060021 value = string.replace(value, m.INVENTORY_ROOT, "<inventory_root>")
Chris Austenb29d2e82016-06-07 12:25:35 -050022
Patrick Williams20f38712022-12-08 06:18:26 -060023 for i in m.ID_LOOKUP["SENSOR"]:
24 if m.ID_LOOKUP["SENSOR"][i] == value:
Gunnar Millsdca35792018-03-26 10:05:38 -050025 return i
26
27 return 0xFF
Chris Austenb29d2e82016-06-07 12:25:35 -050028
29
30def get_inventory_list(module_name):
George Keishinge635ddc2022-12-08 07:38:02 -060031 inventory_list = []
Patrick Williams20f38712022-12-08 06:18:26 -060032 m = imp.load_source("module.name", module_name)
George Keishinge635ddc2022-12-08 07:38:02 -060033
Patrick Williams20f38712022-12-08 06:18:26 -060034 for i in m.ID_LOOKUP["FRU"]:
35 s = m.ID_LOOKUP["FRU"][i]
36 s = s.replace("<inventory_root>", m.INVENTORY_ROOT)
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050037 inventory_list.append(s)
Chris Austenb29d2e82016-06-07 12:25:35 -050038
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050039 return inventory_list
Gunnar Millsdca35792018-03-26 10:05:38 -050040
Chris Austenb29d2e82016-06-07 12:25:35 -050041
42def get_inventory_fru_type_list(module_name, fru_type):
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050043 inventory_list = []
Patrick Williams20f38712022-12-08 06:18:26 -060044 m = imp.load_source("module.name", module_name)
Chris Austenb29d2e82016-06-07 12:25:35 -050045
Gunnar Millsdca35792018-03-26 10:05:38 -050046 for i in m.FRU_INSTANCES.keys():
Patrick Williams20f38712022-12-08 06:18:26 -060047 if m.FRU_INSTANCES[i]["fru_type"] == fru_type:
48 s = i.replace("<inventory_root>", m.INVENTORY_ROOT)
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050049 inventory_list.append(s)
Chris Austenb29d2e82016-06-07 12:25:35 -050050
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050051 return inventory_list
Gunnar Millsdca35792018-03-26 10:05:38 -050052
Chris Austenb29d2e82016-06-07 12:25:35 -050053
54def call_keyword(keyword):
Gunnar Millsdca35792018-03-26 10:05:38 -050055 return BuiltIn().run_keyword(keyword)
Tony Lee1e303ca2020-02-27 10:53:47 +080056
57
58def get_FRU_component_name_list(module_name):
59 name_list = []
Patrick Williams20f38712022-12-08 06:18:26 -060060 m = imp.load_source("module.name", module_name)
Tony Lee1e303ca2020-02-27 10:53:47 +080061
62 for name in m.FRU_COMPONENT_NAME:
63 name_list.append(name)
64 print(name)
65
66 return name_list
67
68
69def get_ipmi_rest_fru_field_map(module_name):
Patrick Williams20f38712022-12-08 06:18:26 -060070 m = imp.load_source("module.name", module_name)
Tony Lee1e303ca2020-02-27 10:53:47 +080071
72 ipmi_rest_fru_field_map = dict.copy(m.ipmi_rest_fru_field_map)
73
74 return ipmi_rest_fru_field_map