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