summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2017-02-03 15:17:21 -0500
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2017-02-09 20:37:04 -0500
commit03f4cd957800210c1763605d755904c95f6079f9 (patch)
tree9174957ad3970d9794a76f180d81595dada84094
parenta6fcd567f6aa01746471fd639db63fecadbf166b (diff)
downloadphosphor-inventory-manager-03f4cd957800210c1763605d755904c95f6079f9.tar.gz
phosphor-inventory-manager-03f4cd957800210c1763605d755904c95f6079f9.zip
Link with libphosphor_dbus
Link with libphosphor_dbus. Update the manager implementation to match the new server binding in libphosphor_dbus (bool types for notify and notify signature change). Change-Id: I033d224965caf737591e363b3e2fd666605bff13 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
-rw-r--r--Makefile.am4
-rw-r--r--configure.ac2
-rw-r--r--manager.cpp4
-rw-r--r--manager.hpp5
-rw-r--r--test/test.cpp26
-rw-r--r--types.hpp3
-rw-r--r--xyz.openbmc_project.Inventory.Manager.cpp88
-rw-r--r--xyz/openbmc_project/Inventory/Manager/server.hpp79
8 files changed, 22 insertions, 189 deletions
diff --git a/Makefile.am b/Makefile.am
index 1673362..b684c4a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,10 +13,10 @@ phosphor_inventory_LDFLAGS = $(SDBUSPLUS_LIBS)
phosphor_inventory_CFLAGS = $(SDBUSPLUS_CFLAGS)
libmanagercommon_la_SOURCES = \
- xyz.openbmc_project.Inventory.Manager.cpp \
events.cpp \
manager.cpp
-libmanagercommon_la_LIBADD = $(SDBUSPLUS_LIBS)
+libmanagercommon_la_LIBADD = $(SDBUSPLUS_LIBS) $(PHOSPHOR_DBUS_INTERFACES_LIBS)
+libmanagercommon_la_CFLAGS = $(SDBUSPLUS_CFLAGS) $(PHOSPHOR_DBUS_INTERACES_CFLAGS)
libmanager_la_SOURCES = \
extra_ifaces.cpp \
diff --git a/configure.ac b/configure.ac
index e9b30fe..526770c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,8 @@ AM_PATH_PYTHON([2.7],
PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221])
PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus],,
AC_MSG_ERROR(["Requires sdbusplus package."]))
+PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces],,
+ AC_MSG_ERROR(["Requires phosphor-dbus-interfaces package."]))
# Checks for typedefs, structures, and compiler characteristics.
AX_CXX_COMPILE_STDCXX_14([noext])
diff --git a/manager.cpp b/manager.cpp
index 8026bf0..bb94c21 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -144,11 +144,11 @@ void Manager::run() noexcept
}
}
-void Manager::notify(sdbusplus::message::object_path path, Object object)
+void Manager::notify(std::map<sdbusplus::message::object_path, Object> objs)
{
try
{
- createObjects({std::make_pair(path, object)});
+ createObjects(objs);
}
catch (const std::exception& e)
{
diff --git a/manager.hpp b/manager.hpp
index e6c08bf..8b59c1b 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -5,7 +5,7 @@
#include <string>
#include <vector>
#include <sdbusplus/server.hpp>
-#include "xyz/openbmc_project/Inventory/Manager/server.hpp"
+#include <xyz/openbmc_project/Inventory/Manager/server.hpp>
#include "events.hpp"
#include "actions.hpp"
#include "types.hpp"
@@ -92,7 +92,8 @@ class Manager final :
void shutdown() noexcept;
/** @brief sd_bus Notify method implementation callback. */
- void notify(sdbusplus::message::object_path, Object) override;
+ void notify(
+ std::map<sdbusplus::message::object_path, Object> objs) override;
/** @brief Event processing entry point. */
void handleEvent(sdbusplus::message::message&,
diff --git a/test/test.cpp b/test/test.cpp
index 6ffad51..0a941f7 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -26,6 +26,9 @@
using namespace std::literals::chrono_literals;
using namespace std::literals::string_literals;
+using Object = phosphor::inventory::manager::Object;
+using ObjectMap = std::map<sdbusplus::message::object_path, Object>;
+
constexpr auto MGR_SERVICE = "phosphor.inventory.test.mgr";
constexpr auto MGR_INTERFACE = IFACE;
constexpr auto MGR_ROOT = "/testing/inventory";
@@ -94,7 +97,6 @@ struct ExampleService
sdbusplus::server::manager::manager objmgr;
};
-using Object = phosphor::inventory::manager::Object;
/** @class SignalQueue
* @brief Store DBus signals in a queue.
@@ -201,11 +203,11 @@ void runTests()
{
{
"xyz.openbmc_project.Example.Iface1",
- {{"ExampleProperty1", "test1"}}
+ {{"ExampleProperty1", "test1"s}}
},
{
"xyz.openbmc_project.Example.Iface2",
- {{"ExampleProperty2", "test2"}}
+ {{"ExampleProperty2", "test2"s}}
},
};
@@ -236,8 +238,7 @@ void runTests()
"path='" + root + "',member='InterfacesAdded'");
auto m = notify();
- m.append(relPath);
- m.append(obj);
+ m.append(ObjectMap({{relPath, obj}}));
b.call(m);
auto sig{queue.pop()};
@@ -257,8 +258,7 @@ void runTests()
// Create an object to be deleted.
{
auto m = notify();
- m.append(relDeleteMeThree);
- m.append(obj);
+ m.append(ObjectMap({{relDeleteMeThree, obj}}));
b.call(m);
}
@@ -330,20 +330,17 @@ void runTests()
// Create some objects to be deleted by an action.
{
auto m = notify();
- m.append(relDeleteMeOne);
- m.append(obj);
+ m.append(ObjectMap({{relDeleteMeOne, obj}}));
b.call(m);
}
{
auto m = notify();
- m.append(relDeleteMeTwo);
- m.append(obj);
+ m.append(ObjectMap({{relDeleteMeTwo, obj}}));
b.call(m);
}
{
auto m = notify();
- m.append(relDeleteMeThree);
- m.append(obj);
+ m.append(ObjectMap({{relDeleteMeThree, obj}}));
b.call(m);
}
@@ -448,8 +445,7 @@ void runTests()
// Create an object to be updated by the set property action.
{
auto m = notify();
- m.append(relChangeMe);
- m.append(obj);
+ m.append(ObjectMap({{relChangeMe, obj}}));
b.call(m);
}
diff --git a/types.hpp b/types.hpp
index 3643bb1..ce43d11 100644
--- a/types.hpp
+++ b/types.hpp
@@ -12,7 +12,8 @@ namespace manager
{
/** @brief Inventory manager supported property types. */
-using InterfaceVariantType = sdbusplus::message::variant<int64_t, std::string>;
+using InterfaceVariantType =
+ sdbusplus::message::variant<bool, int64_t, std::string>;
template <typename T>
using InterfaceType = std::map<std::string, T>;
diff --git a/xyz.openbmc_project.Inventory.Manager.cpp b/xyz.openbmc_project.Inventory.Manager.cpp
deleted file mode 100644
index 787b65f..0000000
--- a/xyz.openbmc_project.Inventory.Manager.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-#include <algorithm>
-#include <sdbusplus/server.hpp>
-#include <sdbusplus/exception.hpp>
-#include <xyz/openbmc_project/Inventory/Manager/server.hpp>
-
-
-namespace sdbusplus
-{
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Inventory
-{
-namespace server
-{
-
-Manager::Manager(bus::bus& bus, const char* path)
- : _xyz_openbmc_project_Inventory_Manager_interface(
- bus, path, _interface, _vtable, this)
-{
-}
-
-
-int Manager::_callback_Notify(
- sd_bus_message* msg, void* context, sd_bus_error* error)
-{
- using sdbusplus::server::binding::details::convertForMessage;
-
- try
- {
- auto m = message::message(msg);
-
- sdbusplus::message::object_path path{};
- std::map<std::string, std::map<std::string, sdbusplus::message::variant<int64_t, std::string>>> object{};
-
- m.read(path, object);
-
- auto o = static_cast<Manager*>(context);
- o->notify(path, object);
-
- auto reply = m.new_method_return();
- // No data to append on reply.
-
- reply.method_return();
- }
- catch(sdbusplus::internal_exception_t& e)
- {
- sd_bus_error_set_const(error, e.name(), e.description());
- return -EINVAL;
- }
-
- return true;
-}
-
-namespace details
-{
-namespace Manager
-{
-static const auto _param_Notify =
- utility::tuple_to_array(message::types::type_id<
- sdbusplus::message::object_path, std::map<std::string, std::map<std::string, sdbusplus::message::variant<int64_t, std::string>>>>());
-static const auto _return_Notify =
- utility::tuple_to_array(std::make_tuple('\0'));
-}
-}
-
-
-
-
-const vtable::vtable_t Manager::_vtable[] = {
- vtable::start(),
-
- vtable::method("Notify",
- details::Manager::_param_Notify
- .data(),
- details::Manager::_return_Notify
- .data(),
- _callback_Notify),
- vtable::end()
-};
-
-} // namespace server
-} // namespace Inventory
-} // namespace openbmc_project
-} // namespace xyz
-} // namespace sdbusplus
-
diff --git a/xyz/openbmc_project/Inventory/Manager/server.hpp b/xyz/openbmc_project/Inventory/Manager/server.hpp
deleted file mode 100644
index 302bee5..0000000
--- a/xyz/openbmc_project/Inventory/Manager/server.hpp
+++ /dev/null
@@ -1,79 +0,0 @@
-#pragma once
-#include <tuple>
-#include <systemd/sd-bus.h>
-#include <sdbusplus/server.hpp>
-
-namespace sdbusplus
-{
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Inventory
-{
-namespace server
-{
-
-class Manager
-{
- public:
- /* Define all of the basic class operations:
- * Not allowed:
- * - Default constructor to avoid nullptrs.
- * - Copy operations due to internal unique_ptr.
- * - Move operations due to 'this' being registered as the
- * 'context' with sdbus.
- * Allowed:
- * - Destructor.
- */
- Manager() = delete;
- Manager(const Manager&) = delete;
- Manager& operator=(const Manager&) = delete;
- Manager(Manager&&) = delete;
- Manager& operator=(Manager&&) = delete;
- virtual ~Manager() = default;
-
- /** @brief Constructor to put object onto bus at a dbus path.
- * @param[in] bus - Bus to attach to.
- * @param[in] path - Path to attach at.
- */
- Manager(bus::bus& bus, const char* path);
-
-
-
- /** @brief Implementation for Notify
- * Signal the implementing service that an item is ready to have its state managed.
- *
- * @param[in] path - The path of the item to be managed, relative to the inventory namespace root.
- * @param[in] object - The fully enumerated item to be managed.
- */
- virtual void notify(
- sdbusplus::message::object_path path,
- std::map<std::string, std::map<std::string, sdbusplus::message::variant<int64_t, std::string>>> object) = 0;
-
-
-
-
- private:
-
- /** @brief sd-bus callback for Notify
- */
- static int _callback_Notify(
- sd_bus_message*, void*, sd_bus_error*);
-
-
- static constexpr auto _interface = "xyz.openbmc_project.Inventory.Manager";
- static const vtable::vtable_t _vtable[];
- sdbusplus::server::interface::interface
- _xyz_openbmc_project_Inventory_Manager_interface;
-
-
-};
-
-
-} // namespace server
-} // namespace Inventory
-} // namespace openbmc_project
-} // namespace xyz
-} // namespace sdbusplus
-
OpenPOWER on IntegriCloud