blob: 9008d5756554fcea74791915cdb166e100265311 [file] [log] [blame]
Rahul Maheshwari4d488572019-12-10 23:53:05 -06001#!/usr/bin/env python
2
3r"""
4PLDM functions.
5"""
6
7import re
8import var_funcs as vf
9import func_args as fa
10import bmc_ssh_utils as bsu
Sridevi Ramesh961050b2020-11-12 11:04:30 -060011import json
Rahul Maheshwari4d488572019-12-10 23:53:05 -060012
13
Sridevi Ramesh961050b2020-11-12 11:04:30 -060014def pldmtool(option_string, **bsu_options):
Rahul Maheshwari4d488572019-12-10 23:53:05 -060015 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 Ramesh961050b2020-11-12 11:04:30 -060024 pldmtool base GetPLDMVersion -t 0
25 {
26 "Response": "1.0.0"
27 }
28
29 pldmtool base GetTID
30 {
31 "Response": 1
32 }
Rahul Maheshwari4d488572019-12-10 23:53:05 -060033
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 Ramesh961050b2020-11-12 11:04:30 -060046 return json.loads(stdout)