AppaRao Puli | 0084047 | 2018-10-03 19:37:46 +0530 | [diff] [blame] | 1 | /*
|
| 2 | // Copyright (c) 2018 Intel 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 | #pragma once
|
| 17 | #include <ctime>
|
| 18 | #include <chrono>
|
| 19 | #include <string>
|
| 20 | #include <sdbusplus/asio/object_server.hpp>
|
| 21 | #include <phosphor-logging/elog-errors.hpp>
|
| 22 | #include <xyz/openbmc_project/Common/error.hpp>
|
| 23 | #include <experimental/filesystem>
|
| 24 | #include <boost/asio.hpp>
|
| 25 |
|
Richard Marian Thomaiyar | 90f2da3 | 2019-05-23 05:37:50 +0530 | [diff] [blame] | 26 | static constexpr const char *sysdStartUnit = "StartUnit";
|
| 27 | static constexpr const char *sysdStopUnit = "StopUnit";
|
| 28 | static constexpr const char *sysdRestartUnit = "RestartUnit";
|
| 29 | static constexpr const char *sysdReloadMethod = "Reload";
|
| 30 | static constexpr const char *sysdGetJobMethod = "GetJob";
|
| 31 | static constexpr const char *sysdReplaceMode = "replace";
|
| 32 | static constexpr const char *dBusGetAllMethod = "GetAll";
|
| 33 | static constexpr const char *dBusGetMethod = "Get";
|
| 34 | static constexpr const char *sysdService = "org.freedesktop.systemd1";
|
| 35 | static constexpr const char *sysdObjPath = "/org/freedesktop/systemd1";
|
| 36 | static constexpr const char *sysdMgrIntf = "org.freedesktop.systemd1.Manager";
|
| 37 | static constexpr const char *sysdUnitIntf = "org.freedesktop.systemd1.Unit";
|
| 38 | static constexpr const char *sysdSocketIntf = "org.freedesktop.systemd1.Socket";
|
| 39 | static constexpr const char *dBusPropIntf = "org.freedesktop.DBus.Properties";
|
| 40 | static constexpr const char *stateMasked = "masked";
|
| 41 | static constexpr const char *stateEnabled = "enabled";
|
| 42 | static constexpr const char *stateDisabled = "disabled";
|
| 43 | static constexpr const char *subStateRunning = "running";
|
| 44 |
|
| 45 | static inline std::string addInstanceName(const std::string &instanceName,
|
| 46 | const std::string &suffix)
|
| 47 | {
|
| 48 | return (instanceName.empty() ? "" : suffix + instanceName);
|
| 49 | }
|
AppaRao Puli | 0084047 | 2018-10-03 19:37:46 +0530 | [diff] [blame] | 50 |
|
| 51 | void systemdDaemonReload(
|
Richard Marian Thomaiyar | 90f2da3 | 2019-05-23 05:37:50 +0530 | [diff] [blame] | 52 | const std::shared_ptr<sdbusplus::asio::connection> &conn,
|
| 53 | boost::asio::yield_context yield);
|
AppaRao Puli | 0084047 | 2018-10-03 19:37:46 +0530 | [diff] [blame] | 54 |
|
| 55 | void systemdUnitAction(const std::shared_ptr<sdbusplus::asio::connection> &conn,
|
Richard Marian Thomaiyar | 90f2da3 | 2019-05-23 05:37:50 +0530 | [diff] [blame] | 56 | boost::asio::yield_context yield,
|
AppaRao Puli | 0084047 | 2018-10-03 19:37:46 +0530 | [diff] [blame] | 57 | const std::string &unitName,
|
| 58 | const std::string &actionMethod);
|
| 59 |
|
AppaRao Puli | e55cfd6 | 2019-02-15 15:35:29 +0530 | [diff] [blame] | 60 | void systemdUnitFilesStateChange(
|
AppaRao Puli | 0084047 | 2018-10-03 19:37:46 +0530 | [diff] [blame] | 61 | const std::shared_ptr<sdbusplus::asio::connection> &conn,
|
Richard Marian Thomaiyar | 90f2da3 | 2019-05-23 05:37:50 +0530 | [diff] [blame] | 62 | boost::asio::yield_context yield, const std::vector<std::string> &unitFiles,
|
| 63 | const std::string &unitState, bool maskedState, bool enabledState);
|