host-bmc: Implement Availability interface
Adding support to host Availability dbus interface. PLDM hosts this dbus
interface to provide the availability of the FRUs hosted by PLDM. The
Availability interface is defined at [1].
Tested:
Functional test passed
[1]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/State/Decorator/Availability.interface.yaml
Change-Id: Ie5912b3683ce102a249c8b503ea9f455f0fbcabf
Signed-off-by: Archana Kakani <archana.kakani@ibm.com>
diff --git a/host-bmc/host_pdr_handler.cpp b/host-bmc/host_pdr_handler.cpp
index 7c5e33d..524c55b 100644
--- a/host-bmc/host_pdr_handler.cpp
+++ b/host-bmc/host_pdr_handler.cpp
@@ -115,6 +115,9 @@
const auto& [key, value] = item;
return key != TERMINUS_HANDLE;
});
+ // when the host is powered off, set the availability
+ // state of all the dbus objects to false
+ this->setPresenceFrus();
pldm_pdr_remove_remote_pdrs(repo);
pldm_entity_association_tree_destroy_root(entityTree);
pldm_entity_association_tree_copy_root(bmcEntityTree,
@@ -127,6 +130,15 @@
});
}
+void HostPDRHandler::setPresenceFrus()
+{
+ // iterate over all dbus objects
+ for (const auto& [path, entityId] : objPathMap)
+ {
+ CustomDBus::getCustomDBus().setAvailabilityState(path, false);
+ }
+}
+
void HostPDRHandler::fetchPDR(PDRRecordHandles&& recordHandles)
{
pdrRecordHandles.clear();
@@ -1122,11 +1134,21 @@
}
#endif
}
+
+void HostPDRHandler::setAvailabilityState(const std::string& path)
+{
+ CustomDBus::getCustomDBus().setAvailabilityState(path, true);
+}
+
void HostPDRHandler::createDbusObjects(const PDRList& fruRecordSetPDRs)
{
- // TODO: Creating and Refreshing dbus hosted by remote PLDM entity Fru PDRs
+ // Creating and Refreshing dbus hosted by remote PLDM entity Fru PDRs
+
for (const auto& entity : objPathMap)
{
+ // Implement & update the Availability to true
+ setAvailabilityState(entity.first);
+
pldm_entity node = pldm_entity_extract(entity.second);
switch (node.entity_type)
{