blob: ecc8d135582c442ff7f98a5bb22661dafe176400 [file] [log] [blame]
Ben Tyner324234b2021-06-28 17:01:17 -05001#pragma once
2
3#include <sdbusplus/bus.hpp>
4
5#include <string>
6#include <variant>
7#include <vector>
8
9namespace util
10{
11
12namespace dbus
13{
14
15using DBusValue = std::variant<std::string, bool, std::vector<uint8_t>,
16 std::vector<std::string>>;
17using DBusProperty = std::string;
18using DBusInterface = std::string;
19using DBusService = std::string;
20using DBusPath = std::string;
21using DBusInterfaceList = std::vector<DBusInterface>;
22using DBusSubTree =
23 std::map<DBusPath, std::map<DBusService, DBusInterfaceList>>;
24
25/**
26 * Find the dbus object path and service that implements the given interface
27 *
28 * @param[in] i_interface Interface to search for
29 * @param[out] o_path Path of dbus object implementing the interface
30 * @param[out] o_service Service implementing the dbus object path
31 * @return non-zero on error
32 */
33int find(const std::string& i_interface, std::string& o_path,
34 std::string& o_service);
35
36/**
37 * Find the dbus service that implements the given dbus object and interface
38 *
39 * @param[in] i_interface Interface that maps to the service
40 * @param[in] i_path Path that maps to the service
41 * @param[out] o_service Service implementing the dbus object and interface
42 * @return non-zer on error
43 */
44int findService(const std::string& i_interface, const std::string& i_path,
45 std::string& o_service);
46
47/**
48 * Read a property from a dbus object interface
49 *
50 * @param[in] i_interface Interface implementing the property
51 * @param[in] i_path Path of the dbus object
52 * @param[in] i_service Service implementing the dbus object and interface
53 * @param[in] i_property Property to read
54 * @return non-zero on error
55 */
56int getProperty(const std::string& i_interface, const std::string& i_path,
57 const std::string& i_service, const std::string& i_property,
58 DBusValue& o_response);
59
60/**
61 * Get the IBM compatible names defined for this system
62 *
63 * @return A vector of strings containing the system names
64 */
65std::vector<std::string> systemNames();
66
Ben Tynerfe2c50d2021-07-23 13:38:53 -050067/** @brief Host transition states for host transition operations */
Ben Tyner93067162021-07-23 10:39:30 -050068enum class HostState
69{
70 Quiesce,
71 Diagnostic,
72 Crash
73};
74
75/**
76 * @brief Transition the host state
77 *
78 * We will transition the host state by starting the appropriate dbus target.
79 *
80 * @param i_hostState the state to transition the host to
81 */
82void transitionHost(const HostState i_hostState);
83
Ben Tynerffb48672021-07-23 12:29:03 -050084/**
Ben Tyner39fcf652021-10-19 20:38:29 -050085 * @brief Read autoRebootEnabled property
Ben Tynerffb48672021-07-23 12:29:03 -050086 *
Ben Tyner39fcf652021-10-19 20:38:29 -050087 * @return false if autoRebootEnabled policy false, else true
Ben Tynerffb48672021-07-23 12:29:03 -050088 */
89bool autoRebootEnabled();
90
Ben Tynerfe2c50d2021-07-23 13:38:53 -050091/** @brief Host running states for host running operations */
92enum class HostRunningState
93{
94 Unknown,
95 NotStarted,
96 Started
97};
98
99/**
100 * Get the host running state
101 *
102 * Use host boot progress to determine if a host has been started. If host
103 * boot progress can not be determined then host state will be unknown.
104 *
105 * @return HostType == "Unknown", "Started or "NotStarted"
106 */
107HostRunningState hostRunningState();
108
Ben Tyner39fcf652021-10-19 20:38:29 -0500109/**
110 * @brief Read dumpPolicyEnabled property
111 *
112 * @return false if dumpPolicyEnabled property is false, else true
113 */
114bool dumpPolicyEnabled();
115
Ben Tyner324234b2021-06-28 17:01:17 -0500116} // namespace dbus
117
118} // namespace util