1 #pragma once 2 3 #include <sdbusplus/bus.hpp> 4 #include <util/ffdc_file.hpp> 5 6 #include <string> 7 #include <variant> 8 #include <vector> 9 10 namespace util 11 { 12 13 namespace dbus 14 { 15 16 using DBusValue = std::variant<std::string, bool, std::vector<uint8_t>, 17 std::vector<std::string>>; 18 using DBusProperty = std::string; 19 using DBusInterface = std::string; 20 using DBusService = std::string; 21 using DBusPath = std::string; 22 using DBusInterfaceList = std::vector<DBusInterface>; 23 using DBusSubTree = 24 std::map<DBusPath, std::map<DBusService, DBusInterfaceList>>; 25 26 /** 27 * Find the dbus object path and service that implements the given interface 28 * 29 * @param[in] i_interface Interface to search for 30 * @param[out] o_path Path of dbus object implementing the interface 31 * @param[out] o_service Service implementing the dbus object path 32 * @return non-zero on error 33 */ 34 int find(const std::string& i_interface, std::string& o_path, 35 std::string& o_service); 36 37 /** 38 * Find the dbus service that implements the given dbus object and interface 39 * 40 * @param[in] i_interface Interface that maps to the service 41 * @param[in] i_path Path that maps to the service 42 * @param[out] o_service Service implementing the dbus object and interface 43 * @return non-zer on error 44 */ 45 int findService(const std::string& i_interface, const std::string& i_path, 46 std::string& o_service); 47 48 /** 49 * Read a property from a dbus object interface 50 * 51 * @param[in] i_interface Interface implementing the property 52 * @param[in] i_path Path of the dbus object 53 * @param[in] i_service Service implementing the dbus object and interface 54 * @param[in] i_property Property to read 55 * @return non-zero on error 56 */ 57 int getProperty(const std::string& i_interface, const std::string& i_path, 58 const std::string& i_service, const std::string& i_property, 59 DBusValue& o_response); 60 61 /** 62 * Get the IBM compatible names defined for this system 63 * 64 * @return A vector of strings containing the system names 65 */ 66 std::vector<std::string> systemNames(); 67 68 /** @brief Host transition states for host transition operations */ 69 enum class HostState 70 { 71 Quiesce, 72 Diagnostic, 73 Crash 74 }; 75 76 /** 77 * @brief Transition the host state 78 * 79 * We will transition the host state by starting the appropriate dbus target. 80 * 81 * @param i_hostState the state to transition the host to 82 */ 83 void transitionHost(const HostState i_hostState); 84 85 /** 86 * @brief Read autoRebootEnabled property 87 * 88 * @return false if autoRebootEnabled policy false, else true 89 */ 90 bool autoRebootEnabled(); 91 92 /** @brief Host running states for host running operations */ 93 enum class HostRunningState 94 { 95 Unknown, 96 NotStarted, 97 Started 98 }; 99 100 /** 101 * Get the host running state 102 * 103 * Use host boot progress to determine if a host has been started. If host 104 * boot progress can not be determined then host state will be unknown. 105 * 106 * @return HostType == "Unknown", "Started or "NotStarted" 107 */ 108 HostRunningState hostRunningState(); 109 110 /** 111 * @brief Read dumpPolicyEnabled property 112 * 113 * @return false if dumpPolicyEnabled property is false, else true 114 */ 115 bool dumpPolicyEnabled(); 116 117 /** 118 * Create a PEL 119 * 120 * The additional data provided in the map will be placed in a user data 121 * section of the PEL and may additionally contain key words to trigger 122 * certain behaviors by the backend logging code. Each set of data described 123 * in the vector of ffdc data will be placed in additional user data 124 * sections. Note that the PID of the caller will be added to the additional 125 * data map with key "_PID". 126 * 127 * @param i_message - the event type 128 * @param i_severity - the severity level 129 * @param io_additional - map of additional data 130 * @param i_ffdc - vector of ffdc data 131 * @return Platform log id or 0 if error 132 */ 133 uint32_t createPel(const std::string& i_message, const std::string& i_severity, 134 std::map<std::string, std::string>& io_additional, 135 const std::vector<FFDCTuple>& i_ffdc); 136 137 } // namespace dbus 138 139 } // namespace util 140