Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | r""" |
| 4 | PLDM functions. |
| 5 | """ |
| 6 | |
| 7 | import re |
| 8 | import var_funcs as vf |
| 9 | import func_args as fa |
| 10 | import bmc_ssh_utils as bsu |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 11 | import json |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 12 | |
| 13 | |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 14 | def pldmtool(option_string, **bsu_options): |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 15 | r""" |
| 16 | Run pldmtool on the BMC with the caller's option string and return the result. |
| 17 | |
| 18 | Example: |
| 19 | |
| 20 | ${pldm_results}= Pldmtool base GetPLDMTypes |
| 21 | Rprint Vars pldm_results |
| 22 | |
| 23 | pldm_results: |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 24 | pldmtool base GetPLDMVersion -t 0 |
| 25 | { |
| 26 | "Response": "1.0.0" |
| 27 | } |
| 28 | |
| 29 | pldmtool base GetTID |
| 30 | { |
| 31 | "Response": 1 |
| 32 | } |
Rahul Maheshwari | 4d48857 | 2019-12-10 23:53:05 -0600 | [diff] [blame] | 33 | |
| 34 | Description of argument(s): |
| 35 | option_string A string of options which are to be processed by the pldmtool command. |
| 36 | parse_results Parse the pldmtool results and return a dictionary rather than the raw |
| 37 | pldmtool output. |
| 38 | bsu_options Options to be passed directly to bmc_execute_command. See its prolog for |
| 39 | details. |
| 40 | """ |
| 41 | |
| 42 | # This allows callers to specify arguments in python style (e.g. print_out=1 vs. print_out=${1}). |
| 43 | bsu_options = fa.args_to_objects(bsu_options) |
| 44 | |
| 45 | stdout, stderr, rc = bsu.bmc_execute_command('pldmtool ' + option_string, **bsu_options) |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 46 | return json.loads(stdout) |