blob: f485516fede06256da5e5fead4fcd9027e564f0b [file] [log] [blame]
Andrew Geissler1c1bd752017-03-20 21:17:04 -05001#include <queue>
2#include <phosphor-logging/log.hpp>
Andrew Geissler1b9d4e52017-03-21 15:04:05 -05003#include <utils.hpp>
Andrew Geisslerdd2c6fd2017-03-16 15:53:20 -05004#include "host-interface.hpp"
5
6namespace phosphor
7{
8namespace host
9{
10
Andrew Geissler1b9d4e52017-03-21 15:04:05 -050011constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
12constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
13constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
14
Andrew Geissler1c1bd752017-03-20 21:17:04 -050015using namespace phosphor::logging;
16
17// When you see base:: you know we're referencing our base class
18namespace base = sdbusplus::xyz::openbmc_project::Control::server;
19
20std::queue<base::Host::Command> workQueue{};
21
22void Host::execute(base::Host::Command command)
Andrew Geissler62817fa92017-03-20 14:20:49 -050023{
Andrew Geissler1c1bd752017-03-20 21:17:04 -050024 log<level::INFO>("Pushing cmd on to queue",
25 entry("CONTROL_HOST_CMD=%s",
26 convertForMessage(command)));
27 workQueue.push(command);
Andrew Geissler1b9d4e52017-03-21 15:04:05 -050028
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 Geissler62817fa92017-03-20 14:20:49 -050053 return;
54}
55
Andrew Geisslerdd2c6fd2017-03-16 15:53:20 -050056} // namespace host
57} // namepsace phosphor