diff options
author | Willy Tu <wltu@google.com> | 2022-03-29 01:25:15 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-05-02 19:13:22 +0300 |
commit | 61b83d0cce255cf98d6a2bbe6924307b69742959 (patch) | |
tree | ac2a28a702cedb5119c08a1de183b307eea605ae /redfish-core/lib | |
parent | 5611d5485a9543c7a745814d8d7bdaf4dc1b7836 (diff) | |
download | bmcweb-61b83d0cce255cf98d6a2bbe6924307b69742959.tar.xz |
storage: Call function only if interfaces exist
Avoid making the dbus call if the interface does not exist and is
expected to error out to reduce the number of dbus calls.
Tested:
Redfish Validator passed for Drives
```
$ wget -qO- \
http://localhost:80/redfish/v1/Systems/system/Storage/1/Drives/drive
{
"@odata.id": "/redfish/v1/Systems/system/Storage/1/Drives/drive",
"@odata.type": "#Drive.v1_7_0.Drive",
"Id": "warthog",
"Links": {
"Chassis": {
"@odata.id": "/redfish/v1/Chassis/chassis"
}
},
"Manufacturer": "XXX",
"MediaType": "SSD",
"Model": "XXX",
"Name": "drive",
"PartNumber": "xxxxxxxxxxxxx",
"Protocol": "SATA",
"SerialNumber": "123456",
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
}
}
```
Change-Id: Ic83c8ee5a49f75b71d443781faf8b65d8fab31b6
Signed-off-by: Willy Tu <wltu@google.com>
Diffstat (limited to 'redfish-core/lib')
-rw-r--r-- | redfish-core/lib/storage.hpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp index 7f1e0de7b2..0f5b0f96b0 100644 --- a/redfish-core/lib/storage.hpp +++ b/redfish-core/lib/storage.hpp @@ -564,10 +564,30 @@ inline void requestRoutesDrive(App& app) const std::string& connectionName = connectionNames[0].first; - getDriveAsset(asyncResp, connectionName, path); - getDrivePresent(asyncResp, connectionName, path); - getDriveState(asyncResp, connectionName, path); - getDriveItemProperties(asyncResp, connectionName, path); + for (const std::string& interface : + connectionNames[0].second) + { + if (interface == + "xyz.openbmc_project.Inventory.Decorator.Asset") + { + getDriveAsset(asyncResp, connectionName, path); + } + else if (interface == + "xyz.openbmc_project.Inventory.Item") + { + getDrivePresent(asyncResp, connectionName, path); + } + else if (interface == "xyz.openbmc_project.State.Drive") + { + getDriveState(asyncResp, connectionName, path); + } + else if (interface == + "xyz.openbmc_project.Inventory.Item.Drive") + { + getDriveItemProperties(asyncResp, connectionName, + path); + } + } }, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", |