item_updater_mmc: Add service calls to bios reset
Added calls to pldm-reset-phyp-nvram.service and
pldm-reset-phyp-nvram-cksum.service to item_updater_mmc::reset.
Also added a section that deletes files created by the bmcweb app.
Tested: Ran the reset method and verified that the new services
ran based on their journalctl output. Verified that the code deleted
bmcweb app files.
Change-Id: Id2e5272048707487ee480f8435da41be56787548
Signed-off-by: Isaac Kurth <isaac.kurth@ibm.com>
diff --git a/mmc/item_updater_mmc.cpp b/mmc/item_updater_mmc.cpp
index ad91b16..04f237d 100644
--- a/mmc/item_updater_mmc.cpp
+++ b/mmc/item_updater_mmc.cpp
@@ -6,6 +6,7 @@
#include "version.hpp"
#include <filesystem>
+#include <iostream>
namespace openpower
{
@@ -68,31 +69,42 @@
}
}
+ // Remove files related to the Hardware Management Console / BMC web app
+ std::filesystem::path consolePath("/var/lib/bmcweb/ibm-management-console");
+ if (std::filesystem::exists(consolePath))
+ {
+ std::filesystem::remove_all(consolePath);
+ }
+
+ std::filesystem::path bmcdataPath("/home/root/bmcweb_persistent_data.json");
+ if (std::filesystem::exists(bmcdataPath))
+ {
+ std::filesystem::remove(bmcdataPath);
+ }
+
// Recreate default files.
+ const std::string services[] = {"obmc-flash-bios-init.service",
+ "obmc-flash-bios-patch.service",
+ "openpower-process-host-firmware.service",
+ "openpower-update-bios-attr-table.service",
+ "pldm-reset-phyp-nvram.service",
+ "pldm-reset-phyp-nvram-cksum.service"};
+
auto bus = sdbusplus::bus::new_default();
- constexpr auto initService = "obmc-flash-bios-init.service";
- auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
- SYSTEMD_INTERFACE, "StartUnit");
- method.append(initService, "replace");
- bus.call_noreply(method);
-
- constexpr auto patchService = "obmc-flash-bios-patch.service";
- method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
- SYSTEMD_INTERFACE, "StartUnit");
- method.append(patchService, "replace");
- bus.call_noreply(method);
-
- constexpr auto processService = "openpower-process-host-firmware.service";
- method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
- SYSTEMD_INTERFACE, "StartUnit");
- method.append(processService, "replace");
- bus.call_noreply(method);
-
- constexpr auto updateService = "openpower-update-bios-attr-table.service";
- method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
- SYSTEMD_INTERFACE, "StartUnit");
- method.append(updateService, "replace");
- bus.call_noreply(method);
+ for (const auto& service : services)
+ {
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "StartUnit");
+ method.append(service, "replace");
+ // Ignore errors if the service is not found - not all systems
+ // may have these services
+ try
+ {
+ bus.call_noreply(method);
+ }
+ catch (const std::exception& e)
+ {}
+ }
}
bool ItemUpdaterMMC::isVersionFunctional(const std::string& versionId)