1#!/usr/bin/env python
2
3r"""
4VPD functions.
5"""
6
7import func_args as fa
8import bmc_ssh_utils as bsu
9import json
10
11
12def vpdtool(option_string, **bsu_options):
13    r"""
14    Run vpdtool on the BMC with the caller's option string and return the result.
15
16    Example:
17
18    ${vpd_results}=  vpd-tool -i
19    Rprint Vars  vpd_results
20
21    vpd_results:
22      [/system/chassis/motherboard]:
23        [PN]:                                         PN12345
24        [SN]:                                         YL2E2D010000
25        [LocationCode]:                               U78DA.ND1.       -P0
26        [CC]:                                         2E2D
27        [DR]:                                         SYSTEM BACKPLANE
28        [FN]:                                         F191014
29        [type]:                                       xyz.openbmc_project.Inventory.Item.Board.Motherboard
30      [/system/chassis/motherboard/ebmc_card_bmc]:
31        [PN]:                                         PN12345
32        [SN]:                                         YL6B58010000
33        [LocationCode]:                               U78DA.ND1.       -P0-C5
34        [CC]:                                         6B58
35        [DR]:                                         EBMC
36        [FN]:                                         F191014
37        [type]:                                       xyz.openbmc_project.Inventory.Item.Bmc
38
39    Description of argument(s):
40    option_string                   A string of options which are to be processed by the vpd-tool command.
41    bsu_options                     Options to be passed directly to bmc_execute_command. See its prolog for
42                                    details.
43    """
44
45    bsu_options = fa.args_to_objects(bsu_options)
46    out_buf, stderr, rc = bsu.bmc_execute_command('vpd-tool ' + option_string, **bsu_options)
47    out_buf = json.loads(out_buf)
48    return out_buf
49