blob: 464ed64f0f5bab86481816ea4275932db3d90add [file] [log] [blame]
Asmitha Karunanithieb40f082021-07-22 06:13:04 -05001#pragma once
Asmitha Karunanithieb40f082021-07-22 06:13:04 -05002#include "hyp_network_manager.hpp"
Asmitha Karunanithieb40f082021-07-22 06:13:04 -05003
4#include <sdbusplus/bus.hpp>
5#include <sdbusplus/server/object.hpp>
Asmitha Karunanithieb40f082021-07-22 06:13:04 -05006#include <xyz/openbmc_project/Network/SystemConfiguration/server.hpp>
7
Patrick Williams89d734b2023-05-10 07:50:25 -05008#include <string>
9
Asmitha Karunanithieb40f082021-07-22 06:13:04 -050010namespace phosphor
11{
12namespace network
13{
14
15using SysConfigIntf =
16 sdbusplus::xyz::openbmc_project::Network::server::SystemConfiguration;
17
Patrick Williamsc38b0712022-07-22 19:26:54 -050018using Iface = sdbusplus::server::object_t<SysConfigIntf>;
Asmitha Karunanithieb40f082021-07-22 06:13:04 -050019
20class 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 */
27class HypSysConfig : public Iface
28{
29 public:
William A. Kennington IIIaf77f822023-06-23 02:17:20 -070030 HypSysConfig() = delete;
Asmitha Karunanithieb40f082021-07-22 06:13:04 -050031 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 */
Patrick Williamsc38b0712022-07-22 19:26:54 -050042 HypSysConfig(sdbusplus::bus_t& bus, const std::string& objPath,
Asmitha Karunanithieb40f082021-07-22 06:13:04 -050043 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. */
Patrick Williamsc38b0712022-07-22 19:26:54 -050068 sdbusplus::bus_t& bus;
Asmitha Karunanithieb40f082021-07-22 06:13:04 -050069
70 /** @brief Hyp Network Manager object. */
71 HypNetworkMgr& manager;
72};
73
74} // namespace network
75} // namespace phosphor