Skip to content

Commit

Permalink
fru: remove assumption on object owner
Browse files Browse the repository at this point in the history
The fru read yaml configuration allows specifying a dbus path and a dbus
interface.  Dynamically look up what service provides that interface
with that dbus path.  Continue supporting partial paths for devices
owned by the Inventory Manager.

Tested: Verified the module now reads the FRU properties over dbus if
the object is owned by another service (exported via entity-manager).

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I5c0aeb11d0b33fab437a55dea3351a47feab0783
  • Loading branch information
pstrinkle committed Aug 1, 2019
1 parent 45e93cb commit c26cc71
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions read_fru_data.cpp
Expand Up @@ -23,6 +23,7 @@ using 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";
Expand All @@ -49,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;
}

Expand Down

0 comments on commit c26cc71

Please sign in to comment.