Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement vpd-tool dumpObject stub #501

Open
wants to merge 1 commit into
base: 1110
Choose a base branch
from

Conversation

souvik1914581
Copy link

@souvik1914581 souvik1914581 commented Nov 22, 2024

This commit implements vpd-tool --dumpObject stub and some associated
utility methods and constants for the same.
This commit allows user to provide --dumpObject command line option to
vpd-tool.

For a given Object path, the object dump functionality prints the
following properties in a JSON format to the console:

  1. Present property, Pretty Name, Location Code, Sub Model
  2. SN, PN, CC, FN, DR keywords under VINI record
Note: This commit does not include actual implementation of
`--dumpObject`.

souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Nov 22, 2024
This commit includes changes and new files required for implementation
of vpd-tool --dumpObject and --dumpInventory options.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
@PriyangaRamasamy
Copy link

This commit is not just for dump object and dump inventory. this is an initial setup required for vpd-tool APIs.

Can you please update the commit heading and the description.

@souvik1914581 souvik1914581 changed the title Infra setup for vpd-tool dump object and inventory Initial setup for vpd-tool APIs Nov 22, 2024
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Nov 22, 2024
This commit includes changes and new files required for implementation
of vpd-tool APIs.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
@souvik1914581
Copy link
Author

This commit is not just for dump object and dump inventory. this is an initial setup required for vpd-tool APIs.

Can you please update the commit heading and the description.

Done

vpd-tool/include/tool_json_utility.hpp Outdated Show resolved Hide resolved
vpd-tool/include/utils.hpp Outdated Show resolved Hide resolved
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Nov 22, 2024
This commit includes changes and new files required for implementation
of vpd-tool APIs.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
@branupama
Copy link

This commit includes changes and new files required for implementation
of vpd-tool APIs.

The commit message is not giving any hint of why and what this commit is doing.

vpd-tool/include/utils.hpp Outdated Show resolved Hide resolved
@souvik1914581
Copy link
Author

This commit includes changes and new files required for implementation
of vpd-tool APIs.

The commit message is not giving any hint of why and what this commit is doing.

Can you mention what is not clear? So that I can update the commit message accordingly.

@souvik1914581 souvik1914581 marked this pull request as draft November 25, 2024 05:17
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Nov 25, 2024
This commit includes changes and new source code files required for
implementation of vpd-tool APIs.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Nov 25, 2024
This commit includes changes and new source code files required for
implementation of vpd-tool APIs.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Nov 26, 2024
This commit includes changes and new source code files required for
implementation of vpd-tool APIs.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Dec 2, 2024
This commit includes changes and new source code files required for
implementation of vpd-tool APIs.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Dec 2, 2024
This commit includes changes and new source code files required for
implementation of vpd-tool APIs.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Dec 2, 2024
This commit includes changes and new source code files required for
implementation of vpd-tool APIs.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Dec 9, 2024
This commit implements vpd-tool --dumpObject stub and some associated
utility methods and constants for the same.
This commit allows user to provide --dumpObject command line option to
vpd-tool.
Note: This commit does not include actual implementation of
--dumpObject.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Dec 9, 2024
This commit implements vpd-tool --dumpObject stub and some associated
utility methods and constants for the same.
This commit allows user to provide --dumpObject command line option to
vpd-tool.
Note: This commit does not include actual implementation of
--dumpObject.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Dec 9, 2024
This commit implements vpd-tool --dumpObject stub and some associated
utility methods and constants for the same.
This commit allows user to provide --dumpObject command line option to
vpd-tool.
Note: This commit does not include actual implementation of
--dumpObject.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Dec 9, 2024
This commit implements vpd-tool --dumpObject stub and some associated
utility methods and constants for the same.
This commit allows user to provide --dumpObject command line option to
vpd-tool.
Note: This commit does not include actual implementation of
--dumpObject.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Dec 9, 2024
This commit implements vpd-tool --dumpObject stub and some associated
utility methods and constants for the same.
This commit allows user to provide --dumpObject command line option to
vpd-tool.
Note: This commit does not include actual implementation of
--dumpObject.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Dec 9, 2024
This commit implements vpd-tool --dumpObject stub and some associated
utility methods and constants for the same.
This commit allows user to provide --dumpObject command line option to
vpd-tool.
Note: This commit does not include actual implementation of
--dumpObject.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Dec 9, 2024
This commit implements vpd-tool --dumpObject stub and some associated
utility methods and constants for the same.
This commit allows user to provide --dumpObject command line option to
vpd-tool.
Note: This commit does not include actual implementation of
--dumpObject.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
* Note: The caller of this API should
* check for empty JSON object
*
* @throw std::runtime_error

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on error scenarios - sometimes you throw exception and sometimes you return empty JSON object. can we fix with any one ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on failure empty JSON should be sent ?

{
nlohmann::json l_resultInJson = nlohmann::json::array({});
const nlohmann::json& l_sysCfgJsonObj =
vpd::jsonUtility::getParsedJson(INVENTORY_JSON_SYM_LINK);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getParsedJson() throws exception. can you catch the exception here and take necessary action in this API?
necessary action llike - catch the exception and return empty json from here.

*
* @throw std::runtime_error
*/
nlohmann::json getFruPropertiesJson(const std::string& i_fruPath) const;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name doesn't gives the clarity on what this API is.
can you change it to something like - getFruProperties() -> as return type tells the format, it's not required to mention JSON format in API name.

@@ -46,6 +51,9 @@ int main(int argc, char** argv)
auto l_hardwareFlag = l_app.add_flag("--Hardware, -H",
"CAUTION: Developer only option.");

auto l_dumpObjFlag = l_app.add_flag("--dumpObject, -o", "Dump Object")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description something like : "Dump inventory object properties."

@@ -13,7 +13,7 @@ sources = ['src/vpd_tool_main.cpp',

vpd_tool_exe = executable('vpd-tool',
sources,
include_directories : ['include/'],
include_directories : ['include/','../'],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you include the directory out of vpd-tool directory? ( ../)

* of the FRU in JSON format to console:
* - Present property, Pretty Name, Location Code, Sub Model
* - SN, PN, CC, FN, DR keywords under VINI record.
* - type and TYPE of the FRU

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is type and TYPE of the FRU?

Copy link
Author

@souvik1914581 souvik1914581 Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the old vpd-tool ,

  1. "type" property in object dump specifies the first extraInterfaces interface name which is null.Eg. xyz.openbmc_project.Inventory.Item.Cpu
  2. "TYPE" tag default value is "FRU", unless there is a "type" tag in the System Config JSON. As per new requirement, since vpd-tool doesn't have System Config JSON, I think we may have to skip dumping this "TYPE" tag.

@souvik1914581 souvik1914581 marked this pull request as draft December 10, 2024 09:22
@souvik1914581
Copy link
Author

As per discussion on 10th December, 2024, following new design changes need to be implemented in dumpObject option:

  • Tool shouldn’t depend on the JSON
  • Use object paths from PIM
  • Dump Object in dictionary format(same as existing).
  • If Present is false: don’t show anything (for single object).
  • Display “FRU is not present in the system” to user.
    See https://ibm.ent.box.com/file/1610305628598

souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Dec 10, 2024
This commit implements vpd-tool --dumpObject stub and some associated
utility methods and constants for the same.
This commit allows user to provide --dumpObject command line option to
vpd-tool.
Note: This commit does not include actual implementation of
--dumpObject.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Dec 10, 2024
This commit implements vpd-tool --dumpObject stub and some associated
utility methods and constants for the same.
This commit allows user to provide --dumpObject command line option to
vpd-tool.
Note: This commit does not include actual implementation of
--dumpObject.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Dec 10, 2024
This commit implements vpd-tool --dumpObject stub and some associated
utility methods and constants for the same.
This commit allows user to provide --dumpObject command line option to
vpd-tool.
Note: This commit does not include actual implementation of
--dumpObject.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
@souvik1914581 souvik1914581 marked this pull request as ready for review December 10, 2024 09:54
This commit implements vpd-tool --dumpObject stub and some associated
utility methods and constants for the same.
This commit allows user to provide --dumpObject command line option to
vpd-tool.
Note: This commit does not include actual implementation of
--dumpObject.

Change-Id: I821777237a3080d390e2bba151cd685ef8994bf9
Signed-off-by: Souvik Roy <[email protected]>
"vpd-tool -r -H -O <EEPROM Path> -R <Record Name> -K <Keyword Name> --file <File Path>");
"vpd-tool -r -H -O <EEPROM Path> -R <Record Name> -K <Keyword Name> --file <File Path>\n"
"Dump Object:\n"
" From dbus to console: "

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to consistent with existing, use DBus

* Note: The caller of this API should
* check for empty JSON object
*
* @throw std::runtime_error

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on failure empty JSON should be sent ?

/**
* @brief Dump the given inventory object in JSON format to console.
*
* For a given Object Path of a FRU, this API dumps the following properties

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object path

else if (!l_dumpObjFlag->empty())
{
vpd::VpdTool l_vpdToolObj;
l_rc = l_vpdToolObj.dumpObject(l_vpdPath);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we check l_vpdPath is empty, incase if Object path is provided like -O "" ?

}
catch (std::exception& l_ex)
{
std::cerr << "Dump Object failed for FRU: " << i_fruPath

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add todo for enable log when verbose is enabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants