diff options
author | RAJESWARAN THILLAIGOVINDAN <rajeswgo@in.ibm.com> | 2019-04-04 13:18:53 +0300 |
---|---|---|
committer | Ed Tanous <ed.tanous@intel.com> | 2019-04-05 23:29:53 +0300 |
commit | f85837bf66a635b816e92c2fdd47dd43851f02cd (patch) | |
tree | 8227744ae781fda68fb2bbf66db88632398126d9 | |
parent | 08244d0221ff404a2e240706138a827d97892039 (diff) | |
download | bmcweb-f85837bf66a635b816e92c2fdd47dd43851f02cd.tar.xz |
Redfish(Network): Implemented PATCH of StaticNameServers array
Testing:
PATCH -D patch.txt -d '{"StaticNameServers": ["3.3.3.3"]}'
PATCH -D patch.txt -d '{"StaticNameServers": ["3.3.3.3","6.6.6.6"]}'
PATCH -D patch.txt -d '{"StaticNameServers": []}'
Signed-off-by: RAJESWARAN THILLAIGOVINDAN <rajeswgo@in.ibm.com>
Change-Id: I3ffb7f5b704437b31ddfeb6a74eae3e6a582164a
-rw-r--r-- | redfish-core/lib/ethernet.hpp | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp index 8ba3f1c668..a6ba562271 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp @@ -220,7 +220,7 @@ inline void extractEthernetInterfaceData(const std::string ðiface_id, ethData.speed = *speed; } } - else if (propertyPair.first == "NameServers") + else if (propertyPair.first == "Nameservers") { const std::vector<std::string> *nameservers = sdbusplus::message::variant_ns::get_if< @@ -1160,6 +1160,31 @@ class EthernetInterface : public Node } } + void handleStaticNameServersPatch( + const std::string &ifaceId, + const std::vector<std::string> &updatedStaticNameServers, + const std::shared_ptr<AsyncResp> &asyncResp) + { + crow::connections::systemBus->async_method_call( + [asyncResp, + updatedStaticNameServers](const boost::system::error_code ec) { + if (ec) + { + messages::internalError(asyncResp->res); + return; + } + asyncResp->res.jsonValue["NameServers"] = + updatedStaticNameServers; + asyncResp->res.jsonValue["StaticNameServers"] = + updatedStaticNameServers; + }, + "xyz.openbmc_project.Network", + "/xyz/openbmc_project/network/" + ifaceId, + "org.freedesktop.DBus.Properties", "Set", + "xyz.openbmc_project.Network.EthernetInterface", "Nameservers", + std::variant<std::vector<std::string>>{updatedStaticNameServers}); + } + void parseInterfaceData( nlohmann::json &json_response, const std::string &iface_id, const EthernetInterfaceData ðData, @@ -1199,6 +1224,7 @@ class EthernetInterface : public Node iface_id + "/VLANs"}}; json_response["NameServers"] = ethData.nameservers; + json_response["StaticNameServers"] = ethData.nameservers; if (ipv4Data.size() > 0) { @@ -1270,10 +1296,12 @@ class EthernetInterface : public Node std::optional<std::string> macAddress; std::optional<nlohmann::json> ipv4Addresses; std::optional<nlohmann::json> ipv6Addresses; + std::optional<std::vector<std::string>> staticNameServers; if (!json_util::readJson( req, res, "HostName", hostname, "IPv4Addresses", ipv4Addresses, - "IPv6Addresses", ipv6Addresses, "MACAddress", macAddress)) + "IPv6Addresses", ipv6Addresses, "MACAddress", macAddress, + "StaticNameServers", staticNameServers)) { return; } @@ -1285,7 +1313,8 @@ class EthernetInterface : public Node [this, asyncResp, iface_id, hostname = std::move(hostname), macAddress = std::move(macAddress), ipv4Addresses = std::move(ipv4Addresses), - ipv6Addresses = std::move(ipv6Addresses)]( + ipv6Addresses = std::move(ipv6Addresses), + staticNameServers = std::move(staticNameServers)]( const bool &success, const EthernetInterfaceData ðData, const boost::container::flat_set<IPv4AddressData> &ipv4Data) { if (!success) @@ -1329,6 +1358,12 @@ class EthernetInterface : public Node messages::propertyNotWritable(asyncResp->res, "IPv6Addresses"); } + + if (staticNameServers) + { + handleStaticNameServersPatch(iface_id, *staticNameServers, + asyncResp); + } }); } }; |