Lakshminarayana R. Kammath | 16ab00c | 2019-06-03 04:33:33 -0500 | [diff] [blame^] | 1 | /** |
| 2 | * Copyright (C) 2019 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "nmi_interface.hpp" |
| 18 | |
| 19 | #include <phosphor-logging/elog-errors.hpp> |
| 20 | #include <phosphor-logging/elog.hpp> |
| 21 | #include <xyz/openbmc_project/Common/error.hpp> |
| 22 | |
| 23 | namespace openpower |
| 24 | { |
| 25 | namespace proc |
| 26 | { |
| 27 | |
| 28 | NMI::NMI(sdbusplus::bus::bus& bus, const char* path) : |
| 29 | Interface(bus, path), bus(bus), objectPath(path) |
| 30 | { |
| 31 | } |
| 32 | |
| 33 | void NMI::nMI() |
| 34 | { |
| 35 | using namespace phosphor::logging; |
| 36 | using sdbusplus::exception::SdBusError; |
| 37 | using InternalFailure = |
| 38 | sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; |
| 39 | |
| 40 | constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1"; |
| 41 | constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1"; |
| 42 | constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager"; |
| 43 | |
| 44 | auto method = bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH, |
| 45 | SYSTEMD_INTERFACE, "StartUnit"); |
| 46 | method.append("nmi.service", "replace"); |
| 47 | try |
| 48 | { |
| 49 | bus.call_noreply(method); |
| 50 | } |
| 51 | catch (const SdBusError& e) |
| 52 | { |
| 53 | log<level::ALERT>("Error in starting NMI service. "); |
| 54 | report<InternalFailure>(); |
| 55 | } |
| 56 | } |
| 57 | } // namespace proc |
| 58 | } // namespace openpower |