VPD tool : Read Keyword option
One of the options the VPD tool provides is
to Read the value of the keyword. This commit has its implementation.
The user should provide a valid object path, valid record name
and valid keyword inorder to get the value of the keyword.
Test:
Tested on simics.
Output:
root@rainier:/tmp# ./vpd-tool -r -O /system/chassis/motherboard/vdd_vrm1 -R VINI -K FN
{
"/system/chassis/motherboard/vdd_vrm1": {
"FN": "F190827"
}
}
Signed-off-by: PriyangaRamasamy <priyanga24@in.ibm.com>
Change-Id: I244b9fe276feefa27e4c99063a9e9aa01aeb2f12
diff --git a/vpd_tool.cpp b/vpd_tool.cpp
index 0498761..d988f63 100644
--- a/vpd_tool.cpp
+++ b/vpd_tool.cpp
@@ -13,9 +13,14 @@
"update the keywords"};
string objectPath{};
+ string recordName{};
+ string keyword{};
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 dumpObjFlag =
app.add_flag("--dumpObject, -o",
@@ -27,6 +32,16 @@
"--dumpInventory, -i", "Dump all the inventory objects. { vpd-tool-exe "
"--dumpInventory/-i }");
+ auto readFlag =
+ app.add_flag("--readKeyword, -r",
+ "Read the data of the given keyword. { "
+ "vpd-tool-exe --readKeyword/-r --object/-O "
+ "\"object-name\" --record/-R \"record-name\" --keyword/-K "
+ "\"keyword-name\" }")
+ ->needs(object)
+ ->needs(record)
+ ->needs(kw);
+
CLI11_PARSE(app, argc, argv);
ifstream inventoryJson(INVENTORY_JSON);
@@ -46,6 +61,13 @@
vpdToolObj.dumpInventory(jsObject);
}
+ else if (*readFlag)
+ {
+ VpdTool vpdToolObj(move(objectPath), move(recordName),
+ move(keyword));
+ vpdToolObj.readKeyword();
+ }
+
else
{
throw runtime_error("One of the valid options is required. Refer "