Add chassis and inventory associations to PSU Pwm
PSU pwm sensors are not associated with chassis base
board object path. This causes the PSU pwm sensors
not list under chassis redfish object. Added chassis
base board path and inventory object path associations
to PSU Pwm Sensors.
Tested:
Get on redfish chassis/<chassis id>/Thermal and
chassis/<chassis id>/sensors redfish URI shows
PSU Pwm sensors.
Change-Id: Ia862ecff058ca43fee38a6f71bdd57f8c135aae2
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
diff --git a/include/PwmSensor.hpp b/include/PwmSensor.hpp
index 345e7b5..f0dc7e6 100644
--- a/include/PwmSensor.hpp
+++ b/include/PwmSensor.hpp
@@ -8,8 +8,10 @@
{
public:
PwmSensor(const std::string& name, const std::string& sysPath,
+ std::shared_ptr<sdbusplus::asio::connection>& conn,
sdbusplus::asio::object_server& objectServer,
- const std::string& sensorConfiguration);
+ const std::string& sensorConfiguration,
+ const std::string& sensorType);
~PwmSensor();
private:
diff --git a/src/FanMain.cpp b/src/FanMain.cpp
index 8668add..37a4e63 100644
--- a/src/FanMain.cpp
+++ b/src/FanMain.cpp
@@ -356,7 +356,8 @@
pwmSensors.insert(
std::pair<std::string, std::unique_ptr<PwmSensor>>(
sysPath, std::make_unique<PwmSensor>(
- pwmName, sysPath, objectServer, *path)));
+ pwmName, sysPath, dbusConnection,
+ objectServer, *path, "Fan")));
}
}));
getter->getConfiguration(
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index ce96c72..0367d2a 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -172,10 +172,12 @@
}
}
-static void checkPWMSensor(const fs::path& sensorPath, std::string& labelHead,
- const std::string& interfacePath,
- sdbusplus::asio::object_server& objectServer,
- const std::string& psuName)
+static void
+ checkPWMSensor(const fs::path& sensorPath, std::string& labelHead,
+ const std::string& interfacePath,
+ std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
+ sdbusplus::asio::object_server& objectServer,
+ const std::string& psuName)
{
for (const auto& pwmName : pwmTable)
{
@@ -200,8 +202,8 @@
}
pwmSensors[psuName + labelHead] = std::make_unique<PwmSensor>(
- "Pwm_" + psuName + "_" + pwmName.second, pwmPathStr, objectServer,
- interfacePath + "_" + pwmName.second);
+ "Pwm_" + psuName + "_" + pwmName.second, pwmPathStr, dbusConnection,
+ objectServer, interfacePath + "_" + pwmName.second, "PSU");
}
}
@@ -468,8 +470,8 @@
<< "\" label=\"" << labelHead << "\"\n";
}
- checkPWMSensor(sensorPath, labelHead, *interfacePath, objectServer,
- psuNames[0]);
+ checkPWMSensor(sensorPath, labelHead, *interfacePath,
+ dbusConnection, objectServer, psuNames[0]);
if (!findLabels.empty())
{
diff --git a/src/PwmSensor.cpp b/src/PwmSensor.cpp
index 5aa729e..eee29ef 100644
--- a/src/PwmSensor.cpp
+++ b/src/PwmSensor.cpp
@@ -27,8 +27,10 @@
static constexpr double defaultPwm = 30.0;
PwmSensor::PwmSensor(const std::string& name, const std::string& sysPath,
+ std::shared_ptr<sdbusplus::asio::connection>& conn,
sdbusplus::asio::object_server& objectServer,
- const std::string& sensorConfiguration) :
+ const std::string& sensorConfiguration,
+ const std::string& sensorType) :
sysPath(sysPath),
objectServer(objectServer), name(name)
{
@@ -118,12 +120,23 @@
association = objectServer.add_interface(
"/xyz/openbmc_project/sensors/fan_pwm/" + name, association::interface);
- createAssociation(association, sensorConfiguration);
+
+ // PowerSupply sensors should be associated with chassis board path
+ // and inventory along with psu object.
+ if (sensorType == "PSU")
+ {
+ createInventoryAssoc(conn, association, sensorConfiguration);
+ }
+ else
+ {
+ createAssociation(association, sensorConfiguration);
+ }
}
PwmSensor::~PwmSensor()
{
objectServer.remove_interface(sensorInterface);
objectServer.remove_interface(controlInterface);
+ objectServer.remove_interface(association);
}
void PwmSensor::setValue(uint32_t value)