summaryrefslogtreecommitdiff
path: root/redfish-core/lib
diff options
context:
space:
mode:
authorSunitha Harish <sunithaharish04@gmail.com>2022-08-09 10:34:30 +0300
committerSunitha Harish <sunithaharish04@gmail.com>2022-10-14 06:31:47 +0300
commit525fc07224884d3640e5c4a1b6a551aee024f7bd (patch)
treeb92f8df261b37af601d12682744549a7457cbdc8 /redfish-core/lib
parent77665bdac1063ae547890a983daeab7f4320457d (diff)
downloadbmcweb-525fc07224884d3640e5c4a1b6a551aee024f7bd.tar.xz
NetworkProtocol: Support NetworkSuppliedServers property
There was no way to differentiate between the static and DHCP assigned NTP servers. Networkd and Dbus has added support for StaticNTPServers to save the static configuration. PATCH command will now set the StaticNTPServers property at the backend. NTPServers property will contain network supplied dynamic NTP Servers at the system. Tested by: 1. PATCH /redfish/v1/Managers/bmc/NetworkProtocol -d '{"NTP":{"NTPServers": [<ip>]}}' Verify that this adds the NTPs server to the NetworkProtocol 2. Enable DHCP to fetch NTP servers list from the DHCP server. Verify that they are listed when GET on NetworkProtocol as below "NTP": { "NTPServers": [ <static ntp server ip> ], "NetworkSuppliedServers": [ <dynamic ntp server ip> ], "ProtocolEnabled": true }, 3. Redfish validator run Signed-off-by: sunharis <sunithaharish04@gmail.com> Change-Id: Ifac77485485839292b770d36def35da17d723c4e
Diffstat (limited to 'redfish-core/lib')
-rw-r--r--redfish-core/lib/network_protocol.hpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index f99cfd3627..de81e5ca0e 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -46,7 +46,8 @@ static constexpr std::array<std::pair<const char*, const char*>, 3>
inline void extractNTPServersAndDomainNamesData(
const dbus::utility::ManagedObjectType& dbusData,
- std::vector<std::string>& ntpData, std::vector<std::string>& dnData)
+ std::vector<std::string>& ntpData, std::vector<std::string>& dynamicNtpData,
+ std::vector<std::string>& dnData)
{
for (const auto& obj : dbusData)
{
@@ -60,7 +61,7 @@ inline void extractNTPServersAndDomainNamesData(
for (const auto& propertyPair : ifacePair.second)
{
- if (propertyPair.first == "NTPServers")
+ if (propertyPair.first == "StaticNTPServers")
{
const std::vector<std::string>* ntpServers =
std::get_if<std::vector<std::string>>(
@@ -70,6 +71,17 @@ inline void extractNTPServersAndDomainNamesData(
ntpData = *ntpServers;
}
}
+ else if (propertyPair.first == "NTPServers")
+ {
+ const std::vector<std::string>* dynamicNtpServers =
+ std::get_if<std::vector<std::string>>(
+ &propertyPair.second);
+ if (dynamicNtpServers != nullptr)
+ {
+ dynamicNtpData = *dynamicNtpServers;
+ }
+ }
+
else if (propertyPair.first == "DomainName")
{
const std::vector<std::string>* domainNames =
@@ -94,17 +106,19 @@ void getEthernetIfaceData(CallbackFunc&& callback)
const boost::system::error_code errorCode,
const dbus::utility::ManagedObjectType& dbusData) {
std::vector<std::string> ntpServers;
+ std::vector<std::string> dynamicNtpServers;
std::vector<std::string> domainNames;
if (errorCode)
{
- callback(false, ntpServers, domainNames);
+ callback(false, ntpServers, dynamicNtpServers, domainNames);
return;
}
- extractNTPServersAndDomainNamesData(dbusData, ntpServers, domainNames);
+ extractNTPServersAndDomainNamesData(dbusData, ntpServers,
+ dynamicNtpServers, domainNames);
- callback(true, ntpServers, domainNames);
+ callback(true, ntpServers, dynamicNtpServers, domainNames);
},
"xyz.openbmc_project.Network", "/xyz/openbmc_project/network",
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
@@ -114,7 +128,7 @@ inline void getNetworkData(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const crow::Request& req)
{
asyncResp->res.jsonValue["@odata.type"] =
- "#ManagerNetworkProtocol.v1_5_0.ManagerNetworkProtocol";
+ "#ManagerNetworkProtocol.v1_9_0.ManagerNetworkProtocol";
asyncResp->res.jsonValue["@odata.id"] =
"/redfish/v1/Managers/bmc/NetworkProtocol";
asyncResp->res.jsonValue["Id"] = "NetworkProtocol";
@@ -140,6 +154,7 @@ inline void getNetworkData(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
getEthernetIfaceData(
[hostName, asyncResp](const bool& success,
const std::vector<std::string>& ntpServers,
+ const std::vector<std::string>& dynamicNtpServers,
const std::vector<std::string>& domainNames) {
if (!success)
{
@@ -148,6 +163,8 @@ inline void getNetworkData(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
return;
}
asyncResp->res.jsonValue["NTP"]["NTPServers"] = ntpServers;
+ asyncResp->res.jsonValue["NTP"]["NetworkSuppliedServers"] =
+ dynamicNtpServers;
if (!hostName.empty())
{
std::string fqdn = hostName;
@@ -349,7 +366,7 @@ inline void
}
},
service, objectPath, "org.freedesktop.DBus.Properties",
- "Set", interface, "NTPServers",
+ "Set", interface, "StaticNTPServers",
dbus::utility::DbusVariantType{currentNtpServers});
}
}
@@ -512,6 +529,7 @@ inline void requestRoutesNetworkProtocol(App& app)
[asyncResp, ntpServerObjects](
const bool success,
std::vector<std::string>& currentNtpServers,
+ std::vector<std::string>& /*dynamicNtpServers*/,
const std::vector<std::string>& /*domainNames*/) {
if (!success)
{