Hypervisor: Fix redfish validator errors
Currently, Redfish validator fails for displaying empty mac address
when doing a GET on hypervisor ethernet interfaces.
This commit ensures that the redfish validator passes by making the
macaddress an optional property in EthernetInterfaceData structure and
removing the un-implemented "MACAddress" interface check in the
hypervisor GET handler method.
The following was the validator error:
[1] ERROR - MACAddress: String '' does not match pattern ''^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$''
Tested By:
Validator Passed.
Change-Id: Ib3f8085841093647ee97dee5602a0bb78fdd67c5
Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com>
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index ee1ad78..29b75fa 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -118,7 +118,7 @@
std::string defaultGateway;
std::string ipv6DefaultGateway;
std::string ipv6StaticDefaultGateway;
- std::string macAddress;
+ std::optional<std::string> macAddress;
std::optional<uint32_t> vlanId;
std::vector<std::string> nameServers;
std::vector<std::string> staticNameServers;
@@ -1863,7 +1863,10 @@
jsonResponse["SpeedMbps"] = ethData.speed;
jsonResponse["MTUSize"] = ethData.mtuSize;
- jsonResponse["MACAddress"] = ethData.macAddress;
+ if (ethData.macAddress)
+ {
+ jsonResponse["MACAddress"] = *ethData.macAddress;
+ }
jsonResponse["DHCPv4"]["DHCPEnabled"] =
translateDhcpEnabledToBool(ethData.dhcpEnabled, true);
jsonResponse["DHCPv4"]["UseNTPServers"] = ethData.ntpv4Enabled;