VPD Tool: Write keyword command line interface
This commit has the command line interface
for writeKeyword option in the VPD tool.
--help option will provide the user - the argument format
for writeKeyword option.
Note:
The application "vpd-manager" acts as the backend for the keyword updation.
The vpd-manager executable should run in the background while testing in simics.
The commits which points to the vpd-manager backend application are,
< https://gerrit.openbmc-project.xyz/c/openbmc/openpower-vpd-parser/+/28991/43 >
< https://gerrit.openbmc-project.xyz/c/openbmc/openpower-vpd-parser/+/29039/43 >
< https://gerrit.openbmc-project.xyz/c/openbmc/openpower-vpd-parser/+/32439/10 >
Tested on rainier:
root@rainier:/tmp# ./vpd-tool -r -O /system/chassis/motherboard/vdd_vrm1 -R VINI -K FN
{
"/system/chassis/motherboard/vdd_vrm1": {
"FN": "F190827"
}
}
root@rainier:/tmp#
root@rainier:/tmp# ./vpd-tool -w -O /system/chassis/motherboard/vdd_vrm1 -R VINI -K FN -V 0x616263
root@rainier:/tmp#
root@rainier:/tmp# ./vpd-tool -r -O /system/chassis/motherboard/vdd_vrm1 -R VINI -K FN
{
"/system/chassis/motherboard/vdd_vrm1": {
"FN": "abc0827"
}
}
Change-Id: I6c586a9848497e44bf88eda78694989d0287cbba
Signed-off-by: Priyanga Ramasamy <priyanga24@in.ibm.com>
diff --git a/vpd_tool.cpp b/vpd_tool.cpp
index d988f63..0514cc5 100644
--- a/vpd_tool.cpp
+++ b/vpd_tool.cpp
@@ -9,18 +9,24 @@
int main(int argc, char** argv)
{
+ int rc = 0;
App app{"VPD Command line tool to dump the inventory and to read and "
"update the keywords"};
string objectPath{};
string recordName{};
string keyword{};
+ string val{};
auto object =
app.add_option("--object, -O", objectPath, "Enter the Object Path");
auto record =
app.add_option("--record, -R", recordName, "Enter the Record Name");
auto kw = app.add_option("--keyword, -K", keyword, "Enter the Keyword");
+ auto valOption = app.add_option(
+ "--value, -V", val,
+ "Enter the value. The value to be updated should be either in ascii or "
+ "in hex. ascii eg: 01234; hex eg: 0x30313233");
auto dumpObjFlag =
app.add_flag("--dumpObject, -o",
@@ -42,6 +48,18 @@
->needs(record)
->needs(kw);
+ auto writeFlag =
+ app.add_flag(
+ "--writeKeyword, -w, --updateKeyword, -u",
+ "Update the value. { vpd-tool-exe "
+ "--writeKeyword/-w/--updateKeyword/-u "
+ "--object/-O object-name --record/-R record-name --keyword/-K "
+ "keyword-name --value/-V value-to-be-updated }")
+ ->needs(object)
+ ->needs(record)
+ ->needs(kw)
+ ->needs(valOption);
+
CLI11_PARSE(app, argc, argv);
ifstream inventoryJson(INVENTORY_JSON);
@@ -68,6 +86,13 @@
vpdToolObj.readKeyword();
}
+ else if (*writeFlag)
+ {
+ VpdTool vpdToolObj(move(objectPath), move(recordName),
+ move(keyword), move(val));
+ rc = vpdToolObj.updateKeyword();
+ }
+
else
{
throw runtime_error("One of the valid options is required. Refer "
@@ -80,5 +105,5 @@
cerr << e.what();
}
- return 0;
+ return rc;
}