blob: 93213477c69cd4a8b929d0b68a43a7e5074eaea0 [file] [log] [blame]
George Keishinge7e91712021-09-03 11:28:44 -05001#!/usr/bin/env python3
Rahul Maheshwarifaa5d202020-02-24 23:32:57 -06002
3r"""
4PEL functions.
5"""
6
7import func_args as fa
8import bmc_ssh_utils as bsu
9import json
10
11
Michael Walsha20876d2020-03-18 16:32:37 -050012def peltool(option_string, parse_json=True, **bsu_options):
Rahul Maheshwarifaa5d202020-02-24 23:32:57 -060013 r"""
14 Run peltool on the BMC with the caller's option string and return the result.
15
16 Example:
17
18 ${pel_results}= Peltool -l
19 Rprint Vars pel_results
20
21 pel_results:
22 [0x50000031]:
23 [CompID]: 0x1000
24 [PLID]: 0x50000031
25 [Subsystem]: BMC Firmware
26 [Message]: An application had an internal failure
27 [SRC]: BD8D1002
28 [Commit Time]: 02/25/2020 04:51:31
29 [Sev]: Unrecoverable Error
30 [CreatorID]: BMC
31
32 Description of argument(s):
Michael Walsha20876d2020-03-18 16:32:37 -050033 option_string A string of options which are to be processed by the peltool command.
34 parse_json Indicates that the raw JSON data should parsed into a list of
35 dictionaries.
36 bsu_options Options to be passed directly to bmc_execute_command. See its prolog for
37 details.
Rahul Maheshwarifaa5d202020-02-24 23:32:57 -060038 """
39
40 bsu_options = fa.args_to_objects(bsu_options)
41 out_buf, stderr, rc = bsu.bmc_execute_command('peltool ' + option_string, **bsu_options)
Michael Walsha20876d2020-03-18 16:32:37 -050042 if parse_json:
43 try:
44 return json.loads(out_buf)
45 except json.JSONDecodeError:
46 return {}
Rahul Maheshwarifaa5d202020-02-24 23:32:57 -060047 return out_buf