refactor: move types and utils in their own files
Change-Id: I477dd69f0c6c648b63171dc2db264d3e70dafaf4
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/writefru.mako.hpp b/writefru.mako.hpp
index 7066f9a..9275e9f 100755
--- a/writefru.mako.hpp
+++ b/writefru.mako.hpp
@@ -7,10 +7,10 @@
#include <map>
#include <iostream>
-#include <sdbusplus/server.hpp>
-#include <log.hpp>
#include "defines.hpp"
#include "store.hpp"
+#include "types.hpp"
+#include "utils.hpp"
namespace openpower
{
@@ -19,78 +19,6 @@
namespace inventory
{
-using Property = std::string;
-using Value = sdbusplus::message::variant<bool, int64_t, std::string>;
-using PropertyMap = std::map<Property, Value>;
-
-using Interface = std::string;
-using InterfaceMap = std::map<Interface, PropertyMap>;
-
-using Object = sdbusplus::message::object_path;
-using ObjectMap = std::map<Object, InterfaceMap>;
-
-using namespace std::string_literals;
-static const auto pimPath = "/xyz/openbmc_project/Inventory"s;
-static const auto pimIntf = "xyz.openbmc_project.Inventory.Manager"s;
-
-/** @brief Get inventory-manager's d-bus service
- */
-auto getPIMService()
-{
- auto bus = sdbusplus::bus::new_default();
- auto mapper =
- bus.new_method_call(
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/ObjectMapper",
- "xyz.openbmc_project.ObjectMapper",
- "GetObject");
-
- mapper.append(pimPath);
- mapper.append(std::vector<std::string>({pimIntf}));
-
- auto result = bus.call(mapper);
- if(result.is_method_error())
- {
- throw std::runtime_error("ObjectMapper GetObject failed");
- }
-
- std::map<std::string, std::vector<std::string>> response;
- result.read(response);
- if(response.empty())
- {
- throw std::runtime_error("ObjectMapper GetObject bad response");
- }
-
- return response.begin()->first;
-}
-
-auto callPIM(ObjectMap&& objects)
-{
- std::string service;
-
- try
- {
- service = getPIMService();
- auto bus = sdbusplus::bus::new_default();
- auto pimMsg = bus.new_method_call(
- service.c_str(),
- pimPath.c_str(),
- pimIntf.c_str(),
- "Notify");
- pimMsg.append(std::move(objects));
- auto result = bus.call(pimMsg);
- if(result.is_method_error())
- {
- std::cerr << "PIM Notify() failed\n";
- }
- }
- catch (const std::runtime_error& e)
- {
- using namespace phosphor::logging;
- log<level::ERR>(e.what());
- }
-}
-
/** @brief API to write parsed VPD to inventory,
* for a specifc FRU
*