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 #include "srvcfg_manager.hpp"
17 
18 std::shared_ptr<boost::asio::deadline_timer> timer = nullptr;
19 std::map<std::string, std::shared_ptr<phosphor::service::ServiceConfig>>
20     srvMgrObjects;
21 
22 static std::map<std::string, std::string> serviceList = {
23     {"netipmid", "phosphor-ipmi-net"}, {"web", "bmcweb"}, {"ssh", "dropbear"}};
24 
25 int main()
26 {
27     // setup connection to dbus
28     boost::asio::io_service io;
29     auto conn = std::make_shared<sdbusplus::asio::connection>(io);
30     timer = std::make_shared<boost::asio::deadline_timer>(io);
31     conn->request_name(phosphor::service::serviceConfigSrvName);
32     auto server = sdbusplus::asio::object_server(conn, true);
33     auto mgrInterface =
34         server.add_interface("/xyz/openbmc_project/control/service", "");
35     mgrInterface->initialize();
36     server.add_manager("/xyz/openbmc_project/control/service");
37     for (const auto &service : serviceList)
38     {
39         std::string objPath("/xyz/openbmc_project/control/service/" +
40                             service.first);
41         auto srvCfgObj = std::make_unique<phosphor::service::ServiceConfig>(
42             server, conn, objPath, service.second);
43         srvMgrObjects.emplace(
44             std::make_pair(std::move(service.first), std::move(srvCfgObj)));
45     }
46     io.run();
47 
48     return 0;
49 }
50