blob: e54210336b50afca3d2b2af07059cb45c8eaeaf4 [file] [log] [blame]
SunnySrivastava1984b59fd092020-02-03 09:58:56 -06001#pragma once
2
3#include "types.hpp"
4
5#include <com/ibm/VPD/Manager/server.hpp>
6#include <sdbusplus/server.hpp>
7
8namespace sdbusplus
9{
10namespace bus
11{
12class bus;
13}
14} // namespace sdbusplus
15
16namespace openpower
17{
18namespace vpd
19{
20namespace manager
21{
22
23template <typename T>
24using ServerObject = T;
25
26using ManagerIface = sdbusplus::com::ibm::VPD::server::Manager;
27
28/** @class Manager
29 * @brief OpenBMC VPD Manager implementation.
30 *
31 * A concrete implementation for the
32 * com.ibm.vpd.Manager
33 */
34class Manager : public ServerObject<ManagerIface>
35{
36 public:
37 /* Define all of the basic class operations:
38 * Not allowed:
39 * - Default constructor to avoid nullptrs.
40 * - Copy operations due to internal unique_ptr.
41 * - Move operations due to 'this' being registered as the
42 * 'context' with sdbus.
43 * Allowed:
44 * - Destructor.
45 */
46 Manager() = delete;
47 Manager(const Manager&) = delete;
48 Manager& operator=(const Manager&) = delete;
49 Manager(Manager&&) = delete;
50 ~Manager() = default;
51
52 /** @brief Constructor to put object onto bus at a dbus path.
53 * @param[in] bus - Bus connection.
54 * @param[in] busName - Name to be requested on Bus
55 * @param[in] objPath - Path to attach at.
56 * @param[in] iFace - interface to implement
57 */
58 Manager(sdbusplus::bus::bus&& bus, const char* busName, const char* objPath,
59 const char* iFace);
60
61 /** @brief Implementation for WriteKeyword
62 * Api to update the keyword value for a given inventory.
63 *
64 * @param[in] path - Path to the D-Bus object that represents the FRU.
65 * @param[in] recordName - name of the record for which the keyword value
66 * has to be modified
67 * @param[in] keyword - keyword whose value needs to be updated
68 * @param[in] value - value that needs to be updated
69 */
70 void writeKeyword(const sdbusplus::message::object_path path,
71 const std::string recordName, const std::string keyword,
72 const Binary value);
73
74 /** @brief Implementation for GetFRUsByUnexpandedLocationCode
75 * A method to get list of FRU D-BUS object paths for a given unexpanded
76 * location code. Returns empty vector if no FRU found for that location
77 * code.
78 *
79 * @param[in] locationCode - An un-expanded Location code.
80 * @param[in] nodeNumber - Denotes the node in case of a multi-node
81 * configuration, ignored on a single node system.
82 *
83 * @return inventoryList[std::vector<sdbusplus::message::object_path>] -
84 * List of all the FRUs D-Bus object paths for the given location code.
85 */
86 std::vector<sdbusplus::message::object_path>
87 getFRUsByUnexpandedLocationCode(const std::string locationCode,
88 const uint16_t nodeNumber);
89
90 /** @brief Implementation for GetFRUsByExpandedLocationCode
91 * A method to get list of FRU D-BUS object paths for a given expanded
92 * location code. Returns empty vector if no FRU found for that location
93 * code.
94 *
95 * @param[in] locationCode - Location code in expanded format.
96 *
97 * @return inventoryList[std::vector<sdbusplus::message::object_path>] -
98 * List of all the FRUs D-Bus object path for the given location code.
99 */
100 std::vector<sdbusplus::message::object_path>
101 getFRUsByExpandedLocationCode(const std::string locationCode);
102
103 /** @brief Implementation for GetExpandedLocationCode
104 * An api to get expanded location code corresponding to a given
105 * un-expanded location code.
106 *
107 * @param[in] locationCode - Location code in un-expaned format.
108 * @param[in] nodeNumber - Denotes the node in case of multi-node
109 * configuration. Ignored in case of single node configuration.
110 *
111 * @return locationCode[std::string] - Location code in expanded format.
112 */
113 std::string getExpandedLocationCode(const std::string locationCode,
114 const uint16_t nodeNumber);
115
116 /** @brief Start processing DBus messages. */
117 void run();
118
119 private:
120 /** @brief Persistent sdbusplus DBus bus connection. */
121 sdbusplus::bus::bus _bus;
122
123 /** @brief sdbusplus org.freedesktop.DBus.ObjectManager reference. */
124 sdbusplus::server::manager::manager _manager;
125};
126
127} // namespace manager
128} // namespace vpd
129} // namespace openpower