Skip to content

Commit

Permalink
item_updater_mmc: Add service calls to bios reset
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Isaac Kurth authored and anoo1 committed Oct 25, 2021
1 parent 6fc7fcd commit bde5d7d
Showing 1 changed file with 35 additions and 23 deletions.
58 changes: 35 additions & 23 deletions mmc/item_updater_mmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "version.hpp"

#include <filesystem>
#include <iostream>

namespace openpower
{
Expand Down Expand Up @@ -68,31 +69,42 @@ void ItemUpdaterMMC::reset()
}
}

// 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)
Expand Down

0 comments on commit bde5d7d

Please sign in to comment.