diff options
| author | Gunnar Mills <gmills@us.ibm.com> | 2017-05-02 12:20:36 -0500 |
|---|---|---|
| committer | Patrick Williams <patrick@stwcx.xyz> | 2017-05-24 16:50:57 +0000 |
| commit | ec1b41c4808482aaa44aaeb1908c33354b38d412 (patch) | |
| tree | e1e8906027b39cb29744e6004cd4b1ab4387cd5b | |
| parent | 93c12d337370461041f43ebf2c52420a4b551c1d (diff) | |
| download | phosphor-bmc-code-mgmt-ec1b41c4808482aaa44aaeb1908c33354b38d412.tar.gz phosphor-bmc-code-mgmt-ec1b41c4808482aaa44aaeb1908c33354b38d412.zip | |
Create initial BMC Item Updater
This is the initial BMC Item Updater.
Change-Id: I1c4f8ec94d7d35a0e03a363007b79414b20058ac
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
| -rw-r--r-- | .gitignore | 1 | ||||
| -rwxr-xr-x | Makefile.am | 12 | ||||
| -rw-r--r-- | activation.hpp | 35 | ||||
| -rwxr-xr-x | configure.ac | 3 | ||||
| -rw-r--r-- | item_updater.cpp | 28 | ||||
| -rw-r--r-- | item_updater.hpp | 69 | ||||
| -rw-r--r-- | item_updater_main.cpp | 23 |
7 files changed, 169 insertions, 2 deletions
@@ -42,6 +42,7 @@ Makefile.in /config.status /phosphor-version-software-manager /phosphor-download-manager +/phosphor-image-updater Makefile .deps /test/utest diff --git a/Makefile.am b/Makefile.am index 8bbf0c8..62e7ae5 100755 --- a/Makefile.am +++ b/Makefile.am @@ -6,11 +6,13 @@ noinst_HEADERS = \ download_manager.hpp \ watch.hpp \ version.hpp \ - image_manager.hpp + image_manager.hpp \ + item_updater.hpp sbin_PROGRAMS = \ phosphor-version-software-manager \ - phosphor-download-manager + phosphor-download-manager \ + phosphor-image-updater phosphor_version_software_manager_SOURCES = \ bmc_version.cpp \ @@ -32,6 +34,10 @@ phosphor_download_manager_SOURCES = \ download_manager.cpp \ download_manager_main.cpp +phosphor_image_updater_SOURCES = \ + item_updater.cpp \ + item_updater_main.cpp + generic_cxxflags = \ $(SYSTEMD_CFLAGS) \ $(PHOSPHOR_DBUS_INTERFACES_CFLAGS) \ @@ -56,5 +62,7 @@ phosphor_version_software_manager_CXXFLAGS = $(generic_cxxflags) phosphor_version_software_manager_LDFLAGS = $(generic_ldflags) phosphor_download_manager_CXXFLAGS = $(generic_cxxflags) phosphor_download_manager_LDFLAGS = $(generic_ldflags) +phosphor_image_updater_CXXFLAGS = $(generic_cxxflags) +phosphor_image_updater_LDFLAGS = $(generic_ldflags) SUBDIRS = test diff --git a/activation.hpp b/activation.hpp new file mode 100644 index 0000000..99ac986 --- /dev/null +++ b/activation.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include <sdbusplus/bus.hpp> +#include <xyz/openbmc_project/Software/Activation/server.hpp> + +namespace phosphor +{ +namespace software +{ +namespace updater +{ + +using ActivationInherit = sdbusplus::server::object::object< + sdbusplus::xyz::openbmc_project::Software::server::Activation>; + +/** @class Activation + * @brief OpenBMC activation software management implementation. + * @details A concrete implementation for + * xyz.openbmc_project.Software.Activation DBus API. + */ +class Activation : public ActivationInherit +{ + public: + /** @brief Constructs Activation Software Manager + * + * @param[in] bus - The Dbus bus object + * @param[in] path - The Dbus object path + */ + Activation(sdbusplus::bus::bus& bus, const std::string& path) : + ActivationInherit(bus, path.c_str()) {}; +}; + +} // namespace updater +} // namespace software +} // namespace phosphor diff --git a/configure.ac b/configure.ac index a446e9f..ce09489 100755 --- a/configure.ac +++ b/configure.ac @@ -72,6 +72,9 @@ AC_ARG_VAR(MANIFEST_FILE_NAME, [The name of the MANIFEST file]) AS_IF([test "x$MANIFEST_FILE_NAME" == "x"], [MANIFEST_FILE_NAME="MANIFEST"]) AC_DEFINE_UNQUOTED([MANIFEST_FILE_NAME], ["$MANIFEST_FILE_NAME"], [The name of the MANIFEST file]) +AC_DEFINE(BUSNAME_UPDATER, "xyz.openbmc_project.Software.BMC.Updater", + [The item updater DBus busname to own.]) + # Check for header files. AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd developement package required])]) AC_CHECK_HEADER(sdbusplus/server.hpp, ,[AC_MSG_ERROR([Could not find sdbusplus/server.hpp...openbmc/sdbusplus package required])]) diff --git a/item_updater.cpp b/item_updater.cpp new file mode 100644 index 0000000..f35a9a0 --- /dev/null +++ b/item_updater.cpp @@ -0,0 +1,28 @@ +#include <string> +#include "item_updater.hpp" +#include "config.h" + +namespace phosphor +{ +namespace software +{ +namespace updater +{ + +int ItemUpdater::createActivation(sd_bus_message* msg, + void* userData, + sd_bus_error* retErr) +{ + auto versionId = 1; + auto* updater = static_cast<ItemUpdater*>(userData); + updater->activations.insert(std::make_pair( + std::to_string(versionId), + std::make_unique<Activation>( + updater->bus, + SOFTWARE_OBJPATH))); + return 0; +} + +} // namespace updater +} // namespace software +} // namespace phosphor diff --git a/item_updater.hpp b/item_updater.hpp new file mode 100644 index 0000000..1a36226 --- /dev/null +++ b/item_updater.hpp @@ -0,0 +1,69 @@ +#pragma once + +#include <sdbusplus/server.hpp> +#include "activation.hpp" + +namespace phosphor +{ +namespace software +{ +namespace updater +{ + +/** @class ItemUpdater + * @brief Manages the activation of the BMC version items. + */ +class ItemUpdater +{ + public: + ItemUpdater() = delete; + ~ItemUpdater() = default; + ItemUpdater(const ItemUpdater&) = delete; + ItemUpdater& operator=(const ItemUpdater&) = delete; + ItemUpdater(ItemUpdater&&) = delete; + ItemUpdater& operator=(ItemUpdater&&) = delete; + + /** @brief Constructs ItemUpdater + * + * @param[in] bus - The Dbus bus object + */ + ItemUpdater(sdbusplus::bus::bus& bus) : + bus(bus), + versionMatch( + bus, + "type='signal'," + "member='InterfacesAdded'," + "path='/xyz/openbmc_project/software'," + "interface='org.freedesktop.DBus.ObjectManager'", + createActivation, + this) {}; + + private: + /** @brief Callback function for Software.Version match. + * @details Creates an Activation dbus object. + * + * @param[in] msg - Data associated with subscribed signal + * @param[in] userData - Pointer to this object instance + * @param[out] retError - Required param + */ + static int createActivation(sd_bus_message* msg, + void* userData, + sd_bus_error* retError); + + /** @brief Persistent sdbusplus DBus bus connection. */ + sdbusplus::bus::bus& bus; + + /** @brief Persistent map of Activation dbus objects and their + * version id */ + std::map<std::string, std::unique_ptr<Activation>> activations; + + /** @brief sdbusplus signal match for Software.Version */ + sdbusplus::server::match::match versionMatch; + +}; + + + +} // namespace updater +} // namespace software +} // namespace phosphor diff --git a/item_updater_main.cpp b/item_updater_main.cpp new file mode 100644 index 0000000..8426e46 --- /dev/null +++ b/item_updater_main.cpp @@ -0,0 +1,23 @@ +#include <sdbusplus/bus.hpp> +#include <sdbusplus/server/manager.hpp> +#include "config.h" +#include "item_updater.hpp" + +int main(int argc, char* argv[]) +{ + auto bus = sdbusplus::bus::new_default(); + + // Add sdbusplus ObjectManager. + sdbusplus::server::manager::manager objManager(bus, SOFTWARE_OBJPATH); + + phosphor::software::updater::ItemUpdater updater(bus); + + bus.request_name(BUSNAME_UPDATER); + + while (true) + { + bus.process_discard(); + bus.wait(); + } + return 0; +} |

