George Keishing | e7e9171 | 2021-09-03 11:28:44 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 -u |
George Keishing | b1d2f49 | 2022-12-15 13:33:42 -0600 | [diff] [blame] | 2 | import imp as imp |
| 3 | import string as string |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 4 | |
| 5 | from robot.libraries.BuiltIn import BuiltIn |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 6 | |
| 7 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 8 | def get_sensor(module_name, value): |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 9 | m = imp.load_source("module.name", module_name) |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 10 | |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 11 | for i in m.ID_LOOKUP["SENSOR"]: |
| 12 | if m.ID_LOOKUP["SENSOR"][i] == value: |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 13 | return i |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 14 | |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 15 | return 0xFF |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 16 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 17 | |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 18 | def get_inventory_sensor(module_name, value): |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 19 | m = imp.load_source("module.name", module_name) |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 20 | |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 21 | value = string.replace(value, m.INVENTORY_ROOT, "<inventory_root>") |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 22 | |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 23 | for i in m.ID_LOOKUP["SENSOR"]: |
| 24 | if m.ID_LOOKUP["SENSOR"][i] == value: |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 25 | return i |
| 26 | |
| 27 | return 0xFF |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 28 | |
| 29 | |
| 30 | def get_inventory_list(module_name): |
George Keishing | e635ddc | 2022-12-08 07:38:02 -0600 | [diff] [blame] | 31 | inventory_list = [] |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 32 | m = imp.load_source("module.name", module_name) |
George Keishing | e635ddc | 2022-12-08 07:38:02 -0600 | [diff] [blame] | 33 | |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 34 | for i in m.ID_LOOKUP["FRU"]: |
| 35 | s = m.ID_LOOKUP["FRU"][i] |
| 36 | s = s.replace("<inventory_root>", m.INVENTORY_ROOT) |
Joy Onyerikwu | 004ad3c | 2018-06-11 16:29:56 -0500 | [diff] [blame] | 37 | inventory_list.append(s) |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 38 | |
Joy Onyerikwu | 004ad3c | 2018-06-11 16:29:56 -0500 | [diff] [blame] | 39 | return inventory_list |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 40 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 41 | |
| 42 | def get_inventory_fru_type_list(module_name, fru_type): |
Joy Onyerikwu | 004ad3c | 2018-06-11 16:29:56 -0500 | [diff] [blame] | 43 | inventory_list = [] |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 44 | m = imp.load_source("module.name", module_name) |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 45 | |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 46 | for i in m.FRU_INSTANCES.keys(): |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 47 | if m.FRU_INSTANCES[i]["fru_type"] == fru_type: |
| 48 | s = i.replace("<inventory_root>", m.INVENTORY_ROOT) |
Joy Onyerikwu | 004ad3c | 2018-06-11 16:29:56 -0500 | [diff] [blame] | 49 | inventory_list.append(s) |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 50 | |
Joy Onyerikwu | 004ad3c | 2018-06-11 16:29:56 -0500 | [diff] [blame] | 51 | return inventory_list |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 52 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 53 | |
| 54 | def call_keyword(keyword): |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 55 | return BuiltIn().run_keyword(keyword) |
Tony Lee | 1e303ca | 2020-02-27 10:53:47 +0800 | [diff] [blame] | 56 | |
| 57 | |
| 58 | def get_FRU_component_name_list(module_name): |
| 59 | name_list = [] |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 60 | m = imp.load_source("module.name", module_name) |
Tony Lee | 1e303ca | 2020-02-27 10:53:47 +0800 | [diff] [blame] | 61 | |
| 62 | for name in m.FRU_COMPONENT_NAME: |
| 63 | name_list.append(name) |
| 64 | print(name) |
| 65 | |
| 66 | return name_list |
| 67 | |
| 68 | |
| 69 | def get_ipmi_rest_fru_field_map(module_name): |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 70 | m = imp.load_source("module.name", module_name) |
Tony Lee | 1e303ca | 2020-02-27 10:53:47 +0800 | [diff] [blame] | 71 | |
| 72 | ipmi_rest_fru_field_map = dict.copy(m.ipmi_rest_fru_field_map) |
| 73 | |
| 74 | return ipmi_rest_fru_field_map |