Fix empty IPV4 gateway error
If an IPV4 gateway is empty use "0.0.0.0".
The RedfishServiceValidator throws the following error on
a Witherspoon system:
"IPv4Addresses[0].Gateway: String '' does not match pattern
''^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$''"
Tested: Ran RedfishServiceValidator and no longer observe the
error. IPV4 addresses with gateways are untouched.
Change-Id: I423aeeb0bec46fa5cc0c8cf5a017c16d20314984
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index a6ba562..71ad624 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -1232,10 +1232,17 @@
ipv4_array = nlohmann::json::array();
for (auto &ipv4_config : ipv4Data)
{
+
+ std::string gatewayStr = ipv4_config.gateway;
+ if (gatewayStr.empty())
+ {
+ gatewayStr = "0.0.0.0";
+ }
+
ipv4_array.push_back({{"AddressOrigin", ipv4_config.origin},
{"SubnetMask", ipv4_config.netmask},
{"Address", ipv4_config.address},
- {"Gateway", ipv4_config.gateway}});
+ {"Gateway", gatewayStr}});
}
}
}