Rahul Maheshwari | faa5d20 | 2020-02-24 23:32:57 -0600 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | r""" |
| 4 | PEL functions. |
| 5 | """ |
| 6 | |
| 7 | import func_args as fa |
| 8 | import bmc_ssh_utils as bsu |
| 9 | import json |
| 10 | |
| 11 | |
Michael Walsh | a20876d | 2020-03-18 16:32:37 -0500 | [diff] [blame] | 12 | def peltool(option_string, parse_json=True, **bsu_options): |
Rahul Maheshwari | faa5d20 | 2020-02-24 23:32:57 -0600 | [diff] [blame] | 13 | 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 Walsh | a20876d | 2020-03-18 16:32:37 -0500 | [diff] [blame] | 33 | 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 Maheshwari | faa5d20 | 2020-02-24 23:32:57 -0600 | [diff] [blame] | 38 | """ |
| 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 Walsh | a20876d | 2020-03-18 16:32:37 -0500 | [diff] [blame] | 42 | if parse_json: |
| 43 | try: |
| 44 | return json.loads(out_buf) |
| 45 | except json.JSONDecodeError: |
| 46 | return {} |
Rahul Maheshwari | faa5d20 | 2020-02-24 23:32:57 -0600 | [diff] [blame] | 47 | return out_buf |