1#!/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
11import json
12
13
14def pldmtool(option_string, **bsu_options):
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:
24      pldmtool base GetPLDMVersion -t 0
25      {
26          "Response": "1.0.0"
27      }
28
29     pldmtool base GetTID
30     {
31         "Response": 1
32     }
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)
46    return json.loads(stdout)
47