Add update power supply inventory stubs and calls
This function will read values from the power supply
and put them into the inventory.
This commit doesn't deal with what is written, but it is
properties like the part and serial numbers.
It needs to be called:
* On startup, regardless of presence state.
* When a power supply is added, after the hwmon directory
has been determined, to read the values for the new unit
* When a power supply is removed.
When the function is called when the unit isn't present,
it will just write empty values to the inventory. This ensures
when a unit is removed that it doesn't contain stale values.
Change-Id: I432a515cf30321d1c9e327fc9c0332d1c724cf94
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/power-supply/power_supply.cpp b/power-supply/power_supply.cpp
index d7a018f..fbc5b1d 100644
--- a/power-supply/power_supply.cpp
+++ b/power-supply/power_supply.cpp
@@ -61,6 +61,9 @@
// The hwmon path may have changed.
pmbusIntf.findHwmonDir();
this->present = true;
+
+ // Update the inventory for the new device
+ updateInventory();
}),
powerOnInterval(t),
powerOnTimer(e, [this]()
@@ -80,6 +83,9 @@
// Get initial presence state.
updatePresence();
+ // Write the SN, PN, etc to the inventory
+ updateInventory();
+
// Subscribe to power state changes
powerOnMatch = std::make_unique<match_t>(bus,
match::rules::propertiesChanged(
@@ -173,6 +179,9 @@
{
present = false;
presentTimer.stop();
+
+ //Clear out the now outdated inventory properties
+ updateInventory();
}
}
@@ -606,6 +615,10 @@
}
+void PowerSupply::updateInventory()
+{
+}
+
}
}
}
diff --git a/power-supply/power_supply.hpp b/power-supply/power_supply.hpp
index c969734..9ad1570 100644
--- a/power-supply/power_supply.hpp
+++ b/power-supply/power_supply.hpp
@@ -321,6 +321,23 @@
*/
void checkTemperatureFault(const uint16_t statusWord);
+ /**
+ * @brief Adds properties to the inventory.
+ *
+ * Reads the values from the device and writes them to the
+ * associated power supply D-Bus inventory object.
+ *
+ * This needs to be done on startup, and each time the presence
+ * state changes.
+ *
+ * Properties added:
+ * - Serial Number
+ * - Part Number
+ * - CCIN (Customer Card Identification Number) - added as the Model
+ * - Firmware version
+ */
+ void updateInventory();
+
};
}