1faa5d20aSRahul Maheshwari#!/usr/bin/env python 2faa5d20aSRahul Maheshwari 3faa5d20aSRahul Maheshwarir""" 4faa5d20aSRahul MaheshwariPEL functions. 5faa5d20aSRahul Maheshwari""" 6faa5d20aSRahul Maheshwari 7faa5d20aSRahul Maheshwariimport func_args as fa 8faa5d20aSRahul Maheshwariimport bmc_ssh_utils as bsu 9faa5d20aSRahul Maheshwariimport json 10faa5d20aSRahul Maheshwari 11faa5d20aSRahul Maheshwari 12*a20876d3SMichael Walshdef peltool(option_string, parse_json=True, **bsu_options): 13faa5d20aSRahul Maheshwari r""" 14faa5d20aSRahul Maheshwari Run peltool on the BMC with the caller's option string and return the result. 15faa5d20aSRahul Maheshwari 16faa5d20aSRahul Maheshwari Example: 17faa5d20aSRahul Maheshwari 18faa5d20aSRahul Maheshwari ${pel_results}= Peltool -l 19faa5d20aSRahul Maheshwari Rprint Vars pel_results 20faa5d20aSRahul Maheshwari 21faa5d20aSRahul Maheshwari pel_results: 22faa5d20aSRahul Maheshwari [0x50000031]: 23faa5d20aSRahul Maheshwari [CompID]: 0x1000 24faa5d20aSRahul Maheshwari [PLID]: 0x50000031 25faa5d20aSRahul Maheshwari [Subsystem]: BMC Firmware 26faa5d20aSRahul Maheshwari [Message]: An application had an internal failure 27faa5d20aSRahul Maheshwari [SRC]: BD8D1002 28faa5d20aSRahul Maheshwari [Commit Time]: 02/25/2020 04:51:31 29faa5d20aSRahul Maheshwari [Sev]: Unrecoverable Error 30faa5d20aSRahul Maheshwari [CreatorID]: BMC 31faa5d20aSRahul Maheshwari 32faa5d20aSRahul Maheshwari Description of argument(s): 33faa5d20aSRahul Maheshwari option_string A string of options which are to be processed by the peltool command. 34*a20876d3SMichael Walsh parse_json Indicates that the raw JSON data should parsed into a list of 35*a20876d3SMichael Walsh dictionaries. 36faa5d20aSRahul Maheshwari bsu_options Options to be passed directly to bmc_execute_command. See its prolog for 37faa5d20aSRahul Maheshwari details. 38faa5d20aSRahul Maheshwari """ 39faa5d20aSRahul Maheshwari 40faa5d20aSRahul Maheshwari bsu_options = fa.args_to_objects(bsu_options) 41faa5d20aSRahul Maheshwari out_buf, stderr, rc = bsu.bmc_execute_command('peltool ' + option_string, **bsu_options) 42*a20876d3SMichael Walsh if parse_json: 43*a20876d3SMichael Walsh try: 44*a20876d3SMichael Walsh return json.loads(out_buf) 45*a20876d3SMichael Walsh except json.JSONDecodeError: 46*a20876d3SMichael Walsh return {} 47faa5d20aSRahul Maheshwari return out_buf 48