Redfish(Ethernet): Send the correct JSON response after creating the IPV4 object.
Before this commit after creating the IPv4 address object,JSON response
was having empty string for the newly added object.
This commit fixes the problem.
Tested By:
Assuming there are already two IP addresses configured then the following
PATCH request would throw the following output
PATCH -D patch.txt -d '{"IPv4Addresses": [{},{},{"Address": "a.a.a.a","Address
Origin": "Static","SubnetMask": "255.255.0.0","Gateway":"g.g.g.g"}]}
{
"@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0",
"HostName": "witherspoon",
"IPv4Addresses": [
{
"Address": "169.254.201.17",
"AddressOrigin": "IPv4LinkLocal",
"Gateway": "9.3.185.1",
"SubnetMask": "255.255.0.0"
},
{
"Address": "9.3.185.83",
"AddressOrigin": "Static",
"Gateway": "9.3.185.1",
"SubnetMask": "255.255.255.0"
},
{
"Address": "a.a.a.a",
"Gateway": "g.g.g.g",
"SubnetMask": "255.255.0.0"
}
],
Change-Id: I6be340051020839ff7f669296c2077ecfdce78ff
Signed-off-by: Ratan Gupta <ratagupt@linux.vnet.ibm.com>
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 1d3cb85..476e03a 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -1200,7 +1200,12 @@
createIPv4(ifaceId, entryIdx, prefixLength, *gateway, *address,
asyncResp);
- asyncResp->res.jsonValue["IPv4Addresses"][entryIdx] = thisJson;
+
+ nlohmann::json &ipv4AddressJson =
+ asyncResp->res.jsonValue["IPv4Addresses"][entryIdx];
+ ipv4AddressJson["Address"] = *address;
+ ipv4AddressJson["SubnetMask"] = *subnetMask;
+ ipv4AddressJson["Gateway"] = *gateway;
}
entryIdx++;
}