diff options
author | Jiaqing Zhao <jiaqing.zhao@intel.com> | 2023-03-03 06:23:08 +0300 |
---|---|---|
committer | Ed Tanous <edtanous@google.com> | 2023-06-09 00:00:24 +0300 |
commit | 7857cb8d830209fdf82db6250f5bd36c5ff01837 (patch) | |
tree | 189351cd54e00c6bffc3fe06286d40fba21c65ce | |
parent | 93bbc953e80362ca17219d5e457680e952c23036 (diff) | |
download | bmcweb-7857cb8d830209fdf82db6250f5bd36c5ff01837.tar.xz |
Expose VLAN interfaces as EthernetInterface
In OpenBMC, VLAN is a virtual interface that has its own configuration
like IP address. Redfish schema 2021.2+ also suggests using individual
EthernetInterface to show VLAN information. This patch exposes VLAN
interfaces as EthernetInterface for configuring them.
Now bmcweb also shows BMC VLAN interfaces under /redfish/v1/Managers
/bmc/EthernetInterfaces.
Fixes bmcweb issue #79 (Unable configure IP on VLAN interface via
redfish).
Tested:
* Both physical and VLAN interfaces are now in the interface collection
* Only VLAN interfaces have the VLAN property and RelatedInterfaces
property pointing to its parent interface
* IP address of both physical and VLAN interfaces can be modified by
PATCH request successfully
* Redfish validator passed
Change-Id: I608892275cfbef4af8e7a03a10d67a9c2fa3ff53
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
Signed-off-by: Ed Tanous <edtanous@google.com>
-rw-r--r-- | Redfish.md | 5 | ||||
-rw-r--r-- | redfish-core/lib/ethernet.hpp | 41 |
2 files changed, 36 insertions, 10 deletions
diff --git a/Redfish.md b/Redfish.md index 4c2dcfb17f..c416a5476b 100644 --- a/Redfish.md +++ b/Redfish.md @@ -489,6 +489,7 @@ Fields common to all schemas - DHCPv4 - DHCPv6 - Description +- EthernetInterfaceType - FQDN - HostName - IPv4Addresses @@ -498,12 +499,16 @@ Fields common to all schemas - IPv6DefaultGateway - IPv6StaticAddresses - InterfaceEnabled +- Links/RelatedInterfaces - LinkStatus - MACAddress - NameServers - SpeedMbps - StaticNameServers - Status +- VLAN/VLANEnable +- VLAN/VLANId +- VLAN/Tagged ### /redfish/v1/Managers/bmc/LogServices/ diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp index 0d3ba7a357..a5e397f1e8 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp @@ -1554,6 +1554,12 @@ inline void handleIPv6StaticAddressesPatch( } } +inline std::string extractParentInterfaceName(const std::string& ifaceId) +{ + std::size_t pos = ifaceId.find('_'); + return ifaceId.substr(0, pos); +} + inline void parseInterfaceData(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& ifaceId, @@ -1629,6 +1635,26 @@ inline void jsonResponse["FQDN"] = fqdn; } + if (ethData.vlanId) + { + jsonResponse["EthernetInterfaceType"] = "Virtual"; + jsonResponse["VLAN"]["VLANEnable"] = true; + jsonResponse["VLAN"]["VLANId"] = *ethData.vlanId; + jsonResponse["VLAN"]["Tagged"] = true; + + nlohmann::json::array_t relatedInterfaces; + nlohmann::json& parentInterface = relatedInterfaces.emplace_back(); + parentInterface["@odata.id"] = + boost::urls::format("/redfish/v1/Managers/bmc/EthernetInterfaces", + extractParentInterfaceName(ifaceId)); + jsonResponse["Links"]["RelatedInterfaces"] = + std::move(relatedInterfaces); + } + else + { + jsonResponse["EthernetInterfaceType"] = "Physical"; + } + jsonResponse["NameServers"] = ethData.nameServers; jsonResponse["StaticNameServers"] = ethData.staticNameServers; @@ -1724,18 +1750,13 @@ inline void requestEthernetInterfacesRoutes(App& app) nlohmann::json& ifaceArray = asyncResp->res.jsonValue["Members"]; ifaceArray = nlohmann::json::array(); - std::string tag = "_"; for (const std::string& ifaceItem : ifaceList) { - std::size_t found = ifaceItem.find(tag); - if (found == std::string::npos) - { - nlohmann::json::object_t iface; - iface["@odata.id"] = boost::urls::format( - "/redfish/v1/Managers/bmc/EthernetInterfaces/{}", - ifaceItem); - ifaceArray.emplace_back(std::move(iface)); - } + nlohmann::json::object_t iface; + iface["@odata.id"] = boost::urls::format( + "/redfish/v1/Managers/bmc/EthernetInterfaces/{}", + ifaceItem); + ifaceArray.push_back(std::move(iface)); } asyncResp->res.jsonValue["Members@odata.count"] = ifaceArray.size(); |