blob: 8134c996a080b382e4c8b83637d7b9cac4ca2dd6 [file] [log] [blame]
George Keishinge7e91712021-09-03 11:28:44 -05001#!/usr/bin/env python3 -u
Chris Austenb29d2e82016-06-07 12:25:35 -05002import imp
3import string
Patrick Williams20f38712022-12-08 06:18:26 -06004import sys
5
6from robot.libraries.BuiltIn import BuiltIn
Chris Austenb29d2e82016-06-07 12:25:35 -05007
8
Chris Austenb29d2e82016-06-07 12:25:35 -05009def get_sensor(module_name, value):
Patrick Williams20f38712022-12-08 06:18:26 -060010 m = imp.load_source("module.name", module_name)
Chris Austenb29d2e82016-06-07 12:25:35 -050011
Patrick Williams20f38712022-12-08 06:18:26 -060012 for i in m.ID_LOOKUP["SENSOR"]:
13 if m.ID_LOOKUP["SENSOR"][i] == value:
Gunnar Millsdca35792018-03-26 10:05:38 -050014 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):
Patrick Williams20f38712022-12-08 06:18:26 -060020 m = imp.load_source("module.name", module_name)
Chris Austenb29d2e82016-06-07 12:25:35 -050021
Patrick Williams20f38712022-12-08 06:18:26 -060022 value = string.replace(value, m.INVENTORY_ROOT, "<inventory_root>")
Chris Austenb29d2e82016-06-07 12:25:35 -050023
Patrick Williams20f38712022-12-08 06:18:26 -060024 for i in m.ID_LOOKUP["SENSOR"]:
25 if m.ID_LOOKUP["SENSOR"][i] == value:
Gunnar Millsdca35792018-03-26 10:05:38 -050026 return i
27
28 return 0xFF
Chris Austenb29d2e82016-06-07 12:25:35 -050029
30
31def get_inventory_list(module_name):
George Keishinge635ddc2022-12-08 07:38:02 -060032 inventory_list = []
Patrick Williams20f38712022-12-08 06:18:26 -060033 m = imp.load_source("module.name", module_name)
George Keishinge635ddc2022-12-08 07:38:02 -060034
Patrick Williams20f38712022-12-08 06:18:26 -060035 for i in m.ID_LOOKUP["FRU"]:
36 s = m.ID_LOOKUP["FRU"][i]
37 s = s.replace("<inventory_root>", m.INVENTORY_ROOT)
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050038 inventory_list.append(s)
Chris Austenb29d2e82016-06-07 12:25:35 -050039
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050040 return inventory_list
Gunnar Millsdca35792018-03-26 10:05:38 -050041
Chris Austenb29d2e82016-06-07 12:25:35 -050042
43def get_inventory_fru_type_list(module_name, fru_type):
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050044 inventory_list = []
Patrick Williams20f38712022-12-08 06:18:26 -060045 m = imp.load_source("module.name", module_name)
Chris Austenb29d2e82016-06-07 12:25:35 -050046
Gunnar Millsdca35792018-03-26 10:05:38 -050047 for i in m.FRU_INSTANCES.keys():
Patrick Williams20f38712022-12-08 06:18:26 -060048 if m.FRU_INSTANCES[i]["fru_type"] == fru_type:
49 s = i.replace("<inventory_root>", m.INVENTORY_ROOT)
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050050 inventory_list.append(s)
Chris Austenb29d2e82016-06-07 12:25:35 -050051
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -050052 return inventory_list
Gunnar Millsdca35792018-03-26 10:05:38 -050053
Chris Austenb29d2e82016-06-07 12:25:35 -050054
55def call_keyword(keyword):
Gunnar Millsdca35792018-03-26 10:05:38 -050056 return BuiltIn().run_keyword(keyword)
Tony Lee1e303ca2020-02-27 10:53:47 +080057
58
59def get_FRU_component_name_list(module_name):
60 name_list = []
Patrick Williams20f38712022-12-08 06:18:26 -060061 m = imp.load_source("module.name", module_name)
Tony Lee1e303ca2020-02-27 10:53:47 +080062
63 for name in m.FRU_COMPONENT_NAME:
64 name_list.append(name)
65 print(name)
66
67 return name_list
68
69
70def get_ipmi_rest_fru_field_map(module_name):
Patrick Williams20f38712022-12-08 06:18:26 -060071 m = imp.load_source("module.name", module_name)
Tony Lee1e303ca2020-02-27 10:53:47 +080072
73 ipmi_rest_fru_field_map = dict.copy(m.ipmi_rest_fru_field_map)
74
75 return ipmi_rest_fru_field_map