Activation: Create UBI volume on RequestedActivation

When the RequestedActivation property is set to Active, call
the ubimount service with the version id to create a ubi
volume with the version id as its name.

Change-Id: I0479cb7daa82c845ef87f319180f8c0e0d5535a5
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/activation.cpp b/activation.cpp
index 4f2706d..0a455c3 100755
--- a/activation.cpp
+++ b/activation.cpp
@@ -1,4 +1,5 @@
 #include "activation.hpp"
+#include "config.h"
 
 namespace openpower
 {
@@ -32,6 +33,23 @@
 auto Activation::requestedActivation(RequestedActivations value) ->
         RequestedActivations
 {
+    if ((value == softwareServer::Activation::RequestedActivations::Active) &&
+        (softwareServer::Activation::requestedActivation() !=
+                  softwareServer::Activation::RequestedActivations::Active))
+    {
+        constexpr auto ubimountService = "obmc-flash-bios-ubimount@";
+        auto ubimountServiceFile = std::string(ubimountService) +
+                                   versionId +
+                                   ".service";
+        auto method = bus.new_method_call(
+                SYSTEMD_BUSNAME,
+                SYSTEMD_PATH,
+                SYSTEMD_INTERFACE,
+                "StartUnit");
+        method.append(ubimountServiceFile,
+                      "replace");
+        bus.call_noreply(method);
+    }
     return softwareServer::Activation::requestedActivation(value);
 }
 
diff --git a/configure.ac b/configure.ac
index 5253703..c0ba7b4 100755
--- a/configure.ac
+++ b/configure.ac
@@ -78,6 +78,13 @@
 AC_DEFINE(MAPPER_INTERFACE, "xyz.openbmc_project.ObjectMapper",
     [The object mapper interface.])
 
+AC_DEFINE(SYSTEMD_BUSNAME, "org.freedesktop.systemd1",
+    [systemd busname.])
+AC_DEFINE(SYSTEMD_PATH, "/org/freedesktop/systemd1",
+    [systemd path.])
+AC_DEFINE(SYSTEMD_INTERFACE, "org.freedesktop.systemd1.Manager",
+    [systemd interface.])
+
 AC_CONFIG_FILES([Makefile test/Makefile])
 AC_OUTPUT