From 0f6efdc1a0c919ffdfc00b2ff8af0929652483dc Mon Sep 17 00:00:00 2001 From: "manojkiran.eda@gmail.com" Date: Thu, 3 Oct 2019 04:53:44 -0500 Subject: Support for NameServers & StaticNameServers - As per the proposal made in the mentioned mailing list thread https://lists.ozlabs.org/pipermail/openbmc/2019-September/018399.html As mentioined in the proposal, it is agreed that configuring the Nameservers by the DHCP server is an optional step, and therefore the Static and Dynamic Configurations can co-exist. The commit supports : 1. NameServers - A readonly property which contains all the nameservers (Static & Dynamic) configured on an interface. 2. StaticNameServers - A writable property which can be used by a redfish client to set a NameServer(Static) on the interface. TestedBy: 1. Redfish Validator - PASS 2. Pass the DNS via DHCP Server and make sure we populate NameServers with the DNS supplied by DHCP. 3. With the DNS supplied via DHCP intact, set another Namserver by PATCH on the StaticNameServers property, and Made sure StaticNameServers and NameServers populates the respective information. 4. PATCH opteration on NameServers should throw an Error Saying it is a Readonly property. Signed-off-by: manojkiran.eda@gmail.com Change-Id: I43b75091cce6938ea2fa094692f2c3f434e5a774 --- redfish-core/lib/ethernet.hpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp index 56e1a1508b..bf5daed7b9 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp @@ -107,7 +107,8 @@ struct EthernetInterfaceData std::string ipv6_default_gateway; std::string mac_address; std::vector vlan_id; - std::vector nameservers; + std::vector nameServers; + std::vector staticNameServers; std::vector domainnames; }; @@ -294,7 +295,19 @@ inline bool extractEthernetInterfaceData(const std::string ðiface_id, &propertyPair.second); if (nameservers != nullptr) { - ethData.nameservers = std::move(*nameservers); + ethData.nameServers = std::move(*nameservers); + } + } + else if (propertyPair.first == "StaticNameServers") + { + const std::vector *staticNameServers = + sdbusplus::message::variant_ns::get_if< + std::vector>( + &propertyPair.second); + if (staticNameServers != nullptr) + { + ethData.staticNameServers = + std::move(*staticNameServers); } } else if (propertyPair.first == "DHCPEnabled") @@ -1606,7 +1619,8 @@ class EthernetInterface : public Node "xyz.openbmc_project.Network", "/xyz/openbmc_project/network/" + ifaceId, "org.freedesktop.DBus.Properties", "Set", - "xyz.openbmc_project.Network.EthernetInterface", "Nameservers", + "xyz.openbmc_project.Network.EthernetInterface", + "StaticNameServers", std::variant>{updatedStaticNameServers}); } @@ -1806,15 +1820,8 @@ class EthernetInterface : public Node {"@odata.id", "/redfish/v1/Managers/bmc/EthernetInterfaces/" + iface_id + "/VLANs"}}; - if (translateDHCPEnabledToBool(ethData.DHCPEnabled, true) && - ethData.DNSEnabled) - { - json_response["StaticNameServers"] = nlohmann::json::array(); - } - else - { - json_response["StaticNameServers"] = ethData.nameservers; - } + json_response["NameServers"] = ethData.nameServers; + json_response["StaticNameServers"] = ethData.staticNameServers; nlohmann::json &ipv4_array = json_response["IPv4Addresses"]; nlohmann::json &ipv4_static_array = -- cgit v1.2.3