diff options
Diffstat (limited to 'read_fru_data.cpp')
-rw-r--r-- | read_fru_data.cpp | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/read_fru_data.cpp b/read_fru_data.cpp index 1f99e20..270accf 100644 --- a/read_fru_data.cpp +++ b/read_fru_data.cpp @@ -17,14 +17,13 @@ namespace ipmi namespace fru { -namespace variant_ns = sdbusplus::message::variant_ns; - using namespace phosphor::logging; using InternalFailure = sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; std::unique_ptr<sdbusplus::bus::match_t> matchPtr __attribute__((init_priority(101))); +static constexpr auto XYZ_PREFIX = "/xyz/openbmc_project/"; static constexpr auto INV_INTF = "xyz.openbmc_project.Inventory.Manager"; static constexpr auto OBJ_PATH = "/xyz/openbmc_project/inventory"; static constexpr auto PROP_INTF = "org.freedesktop.DBus.Properties"; @@ -51,21 +50,38 @@ ipmi::PropertyMap readAllProperties(const std::string& intf, { ipmi::PropertyMap properties; sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; - auto service = ipmi::getService(bus, INV_INTF, OBJ_PATH); - std::string objPath = OBJ_PATH + path; + std::string service; + std::string objPath; + + // Is the path the full dbus path? + if (path.find(XYZ_PREFIX) != std::string::npos) + { + service = ipmi::getService(bus, intf, path); + objPath = path; + } + else + { + service = ipmi::getService(bus, INV_INTF, OBJ_PATH); + objPath = OBJ_PATH + path; + } + auto method = bus.new_method_call(service.c_str(), objPath.c_str(), PROP_INTF, "GetAll"); method.append(intf); - auto reply = bus.call(method); - if (reply.is_method_error()) + try + { + auto reply = bus.call(method); + reply.read(properties); + } + catch (const sdbusplus::exception::SdBusError& e) { // If property is not found simply return empty value - log<level::ERR>("Error in reading property values from inventory", + log<level::ERR>("Error in reading property values", + entry("EXCEPTION=%s", e.what()), entry("INTERFACE=%s", intf.c_str()), entry("PATH=%s", objPath.c_str())); - return properties; } - reply.read(properties); + return properties; } @@ -140,9 +156,9 @@ FruInventoryData readDataFromInventory(const FRUId& fruNum) if (iter != allProp.end()) { data[properties.second.section].emplace( - properties.first, - std::move(variant_ns::get<std::string>( - allProp[properties.first]))); + properties.second.property, + std::move( + std::get<std::string>(allProp[properties.first]))); } } } |