Redfish(Network): Allow empty list item for ipv4 address.
Tested by:
Assuming there are two IP addresses in the IPv4Addresses for the
following PATCH request.
1) PATCH {"IPv4Addresses": [{},{}]} =>No change in the existing list.
2) PATCH {"IPv4Addresses": [{},{},{}]}
Following error for the third list item.
"IPv4Addresses/0/Address@Message.ExtendedInfo": [
{
"@odata.type": "/redfish/v1/$metadata#Message.v1_0_0.Message",
"Message": "The property IPv4Addresses/2/Address is a required property
and must be included in the request.",
"MessageArgs": [
"IPv4Addresses/2/Address"
],
"MessageId": "Base.1.4.0.PropertyMissing",
"Resolution": "Ensure that the property is in the request body and has a
valid value and resubmit the request if the operation failed.",
"Severity": "Warning"
}
Change-Id: I24d11ca82cf6843611f72912499878bcbe1aecac
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 8d7eddc..71cde15 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -923,6 +923,27 @@
std::string pathString =
"IPv4Addresses/" + std::to_string(entryIdx);
+ if (thisJson.empty())
+ {
+ if (thisData != ipv4Data.end())
+ {
+ thisData++;
+ }
+ else
+ {
+ messages::propertyMissing(asyncResp->res,
+ pathString + "/Address");
+ return;
+ // TODO Not sure about the property where value is
+ // list and if unable to update one of the
+ // list value then should we proceed further or
+ // break there, would ask in the redfish forum
+ // till then we stop processing the next list item.
+ }
+ entryIdx++;
+ continue; // not an error as per the redfish spec.
+ }
+
std::optional<std::string> address;
std::optional<std::string> addressOrigin;
std::optional<std::string> subnetMask;