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 32################################################################ 33# This will return the URI's of the FRU type 34# 35# i.e. get_inventory_list('../data/Palmetto.py') 36# 37# [/org/openbmc/inventory//system/chassis/motherboard/cpu0/core0, 38# /org/openbmc/inventory/system/chassis/motherboard/dimm0] 39################################################################ 40def get_inventory_list(module_name): 41 42 l = [] 43 m = imp.load_source('module.name', module_name) 44 45 46 for i in m.ID_LOOKUP['FRU']: 47 s = m.ID_LOOKUP['FRU'][i] 48 s = s.replace('<inventory_root>',m.INVENTORY_ROOT) 49 l.append(s) 50 51 return l 52 53 54################################################################ 55# This will return the URI's of the FRU type 56# 57# i.e. get_inventory_fru_type_list('../data/Barreleye.py', 'CPU') 58# 59# [/org/openbmc/inventory//system/chassis/motherboard/cpu0, 60# /org/openbmc/inventory//system/chassis/motherboard/cpu1] 61################################################################ 62def get_inventory_fru_type_list(module_name, fru): 63 l = [] 64 m = imp.load_source('module.name', module_name) 65 66 for i in m.FRU_INSTANCES.keys(): 67 if m.FRU_INSTANCES[i]['fru_type'] == fru: 68 s = i.replace('<inventory_root>',m.INVENTORY_ROOT) 69 l.append(s) 70 71 return l 72 73 74################################################################ 75# This will return the URI's of the FRU type that contain VPD 76# 77# i.e. get_vpd_inventory_list('../data/Palmetto.py', 'DIMM') 78# 79# [/org/openbmc/inventory/system/chassis/motherboard/dimm0, 80# /org/openbmc/inventory/system/chassis/motherboard/dimm1] 81################################################################ 82def get_vpd_inventory_list(module_name, fru): 83 l = [] 84 m = imp.load_source('module.name', module_name) 85 86 for i in m.ID_LOOKUP['FRU_STR']: 87 x = m.ID_LOOKUP['FRU_STR'][i] 88 89 if m.FRU_INSTANCES[x]['fru_type'] == fru: 90 s = x.replace('<inventory_root>',m.INVENTORY_ROOT) 91 l.append(s) 92 93 return l 94 95 96def call_keyword(keyword): 97 return BuiltIn().run_keyword(keyword) 98 99 100def main(): 101 print get_vpd_inventory_list('../data/Palmetto.py', 'DIMM') 102 103 104if __name__ == "__main__": 105 main() 106