Andrew Geissler | 1c1bd75 | 2017-03-20 21:17:04 -0500 | [diff] [blame] | 1 | #include <queue> |
| 2 | #include <phosphor-logging/log.hpp> |
Andrew Geissler | 1b9d4e5 | 2017-03-21 15:04:05 -0500 | [diff] [blame^] | 3 | #include <utils.hpp> |
Andrew Geissler | dd2c6fd | 2017-03-16 15:53:20 -0500 | [diff] [blame] | 4 | #include "host-interface.hpp" |
| 5 | |
| 6 | namespace phosphor |
| 7 | { |
| 8 | namespace host |
| 9 | { |
| 10 | |
Andrew Geissler | 1b9d4e5 | 2017-03-21 15:04:05 -0500 | [diff] [blame^] | 11 | constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper"; |
| 12 | constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper"; |
| 13 | constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper"; |
| 14 | |
Andrew Geissler | 1c1bd75 | 2017-03-20 21:17:04 -0500 | [diff] [blame] | 15 | using namespace phosphor::logging; |
| 16 | |
| 17 | // When you see base:: you know we're referencing our base class |
| 18 | namespace base = sdbusplus::xyz::openbmc_project::Control::server; |
| 19 | |
| 20 | std::queue<base::Host::Command> workQueue{}; |
| 21 | |
| 22 | void Host::execute(base::Host::Command command) |
Andrew Geissler | 62817fa9 | 2017-03-20 14:20:49 -0500 | [diff] [blame] | 23 | { |
Andrew Geissler | 1c1bd75 | 2017-03-20 21:17:04 -0500 | [diff] [blame] | 24 | log<level::INFO>("Pushing cmd on to queue", |
| 25 | entry("CONTROL_HOST_CMD=%s", |
| 26 | convertForMessage(command))); |
| 27 | workQueue.push(command); |
Andrew Geissler | 1b9d4e5 | 2017-03-21 15:04:05 -0500 | [diff] [blame^] | 28 | |
| 29 | // If this was the only entry then send the SMS attention |
| 30 | if(workQueue.size() == 1) |
| 31 | { |
| 32 | log<level::INFO>("Asserting SMS Attention"); |
| 33 | |
| 34 | std::string IPMI_PATH("/org/openbmc/HostIpmi/1"); |
| 35 | std::string IPMI_INTERFACE("org.openbmc.HostIpmi"); |
| 36 | |
| 37 | auto host = ipmi::getService(this->bus,IPMI_INTERFACE,IPMI_PATH); |
| 38 | |
| 39 | auto method = this->bus.new_method_call(host.c_str(), |
| 40 | IPMI_PATH.c_str(), |
| 41 | IPMI_INTERFACE.c_str(), |
| 42 | "setAttention"); |
| 43 | auto reply = this->bus.call(method); |
| 44 | |
| 45 | if (reply.is_method_error()) |
| 46 | { |
| 47 | log<level::ERR>("Error in setting SMS attention"); |
| 48 | throw std::runtime_error("ERROR in call to setAttention"); |
| 49 | } |
| 50 | log<level::INFO>("SMS Attention asserted"); |
| 51 | } |
| 52 | |
Andrew Geissler | 62817fa9 | 2017-03-20 14:20:49 -0500 | [diff] [blame] | 53 | return; |
| 54 | } |
| 55 | |
Andrew Geissler | dd2c6fd | 2017-03-16 15:53:20 -0500 | [diff] [blame] | 56 | } // namespace host |
| 57 | } // namepsace phosphor |