1 #pragma once 2 3 #include <sdbusplus/bus.hpp> 4 5 #include <string> 6 #include <variant> 7 #include <vector> 8 9 namespace util 10 { 11 12 namespace dbus 13 { 14 15 using DBusValue = std::variant<std::string, bool, std::vector<uint8_t>, 16 std::vector<std::string>>; 17 using DBusProperty = std::string; 18 using DBusInterface = std::string; 19 using DBusService = std::string; 20 using DBusPath = std::string; 21 using DBusInterfaceList = std::vector<DBusInterface>; 22 using 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 */ 33 int 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 */ 44 int 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 */ 56 int 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 */ 65 std::vector<std::string> systemNames(); 66 67 /** @brief Host states for util::dbus host state operations */ 68 enum 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 */ 82 void transitionHost(const HostState i_hostState); 83 84 /** 85 * @brief Read autoreboot property 86 * 87 * Read the autoreboot property via dbus. This status will be used to 88 * determine whether to either mpipl or quiesce the host on TI condition. 89 */ 90 bool autoRebootEnabled(); 91 92 } // namespace dbus 93 94 } // namespace util 95