1 #pragma once
2 #include "hyp_network_manager.hpp"
3 
4 #include <sdbusplus/bus.hpp>
5 #include <sdbusplus/server/object.hpp>
6 #include <xyz/openbmc_project/Network/SystemConfiguration/server.hpp>
7 
8 #include <string>
9 
10 namespace phosphor
11 {
12 namespace network
13 {
14 
15 using SysConfigIntf =
16     sdbusplus::xyz::openbmc_project::Network::server::SystemConfiguration;
17 
18 using Iface = sdbusplus::server::object_t<SysConfigIntf>;
19 
20 class HypNetworkMgr; // forward declaration of network manager.
21 
22 /** @class HypSysConfig
23  *  @brief Network system configuration.
24  *  @details A concrete implementation for the
25  *  xyz.openbmc_project.Network.HypSysConfig DBus API.
26  */
27 class HypSysConfig : public Iface
28 {
29   public:
30     HypSysConfig() = delete;
31     HypSysConfig(const HypSysConfig&) = delete;
32     HypSysConfig& operator=(const HypSysConfig&) = delete;
33     HypSysConfig(HypSysConfig&&) = delete;
34     HypSysConfig& operator=(HypSysConfig&&) = delete;
35     virtual ~HypSysConfig() = default;
36 
37     /** @brief Constructor to put object onto bus at a dbus path.
38      *  @param[in] bus - Bus to attach to.
39      *  @param[in] objPath - Path to attach at.
40      *  @param[in] parent - Parent object.
41      */
42     HypSysConfig(sdbusplus::bus_t& bus, const std::string& objPath,
43                  HypNetworkMgr& parent) :
44         Iface(bus, objPath.c_str(), Iface::action::defer_emit),
45         bus(bus), manager(parent){};
46 
47     /** @brief set the hostname of the system.
48      *  @param[in] name - host name of the system.
49      */
50     std::string hostName(std::string name) override;
51 
52     /** @brief get hostname from bios and set the data member
53      */
54     void setHostName();
55 
56   protected:
57     /** @brief get the hostname from the system by doing
58      *         dbus call to hostnamed service.
59      */
60     std::string getHostNameFromBios() const;
61 
62     /** @brief set the hostname set in dbus obj in the basebiostable
63      *  @param[in] name - hostname that is set in dbus obj
64      */
65     void setHostNameInBios(const std::string& name);
66 
67     /** @brief Persistent sdbusplus DBus bus connection. */
68     sdbusplus::bus_t& bus;
69 
70     /** @brief Hyp Network Manager object. */
71     HypNetworkMgr& manager;
72 };
73 
74 } // namespace network
75 } // namespace phosphor
76