Call updateFunctionalAssociation on symlink change
Call updateFunctionalAssociation, to change the functional
association to the new "running" PNOR image, on a symlink change.
The symlink change occurs on chassis poweron.
Look at the RO symlink, /var/lib/phosphor-software-manager/pnor/ro,
for a symlink change.
Change-Id: I2c673635af55da1c642e6d96ab6e12951b3a4fd3
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/item_updater_main.cpp b/item_updater_main.cpp
index c6f7dba..0933505 100755
--- a/item_updater_main.cpp
+++ b/item_updater_main.cpp
@@ -1,23 +1,56 @@
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/manager.hpp>
+#include <system_error>
#include "config.h"
#include "item_updater.hpp"
+#include <phosphor-logging/log.hpp>
+#include "watch.hpp"
int main(int argc, char* argv[])
{
+ using namespace openpower::software::updater;
+ using namespace phosphor::logging;
auto bus = sdbusplus::bus::new_default();
+ sd_event* loop = nullptr;
+ auto rc = sd_event_default(&loop);
+ if (rc < 0)
+ {
+ log<level::ERR>("Error occurred during the sd_event_default",
+ entry("RC=%d", rc));
+ return -1;
+ }
+
// Add sdbusplus ObjectManager.
sdbusplus::server::manager::manager objManager(bus, SOFTWARE_OBJPATH);
- openpower::software::updater::ItemUpdater updater(bus, SOFTWARE_OBJPATH);
+ ItemUpdater updater(bus, SOFTWARE_OBJPATH);
bus.request_name(BUSNAME_UPDATER);
-
- while (true)
+ try
{
- bus.process_discard();
- bus.wait();
+ openpower::software::updater::Watch watch(
+ loop,
+ std::bind(std::mem_fn(
+ &ItemUpdater::updateFunctionalAssociation),
+ &updater,
+ std::placeholders::_1));
+ bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL);
+ auto rc = sd_event_loop(loop);
+ if (rc < 0)
+ {
+ log<level::ERR>("Error occurred during the sd_event_loop",
+ entry("RC=%d", rc));
+ return -1;
+ }
}
+ catch (const std::system_error& e)
+ {
+ log<level::ERR>(e.what());
+ return -1;
+ }
+
+ sd_event_unref(loop);
+
return 0;
}