Redfish: Remove the IPv4 AddressOrigin read-only element
The AddressOrigin entry in the IPv4Addresses schema is read-only. It
is not permitted to PATCH the AddressOrigin.
Tested: Added the "AddressOrigin": "DHCP" to an IPv4Addresses PATCH
command. The JSON response is "property is not in the list of valid
properties".
Change-Id: Id7d41e9f1b393738e20725495b3821dd2f9f69d0
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 6ce8065..7dd6f34 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -151,28 +151,6 @@
return "";
}
-inline std::string
- translateAddressOriginRedfishToDbus(const std::string &inputOrigin)
-{
- if (inputOrigin == "Static")
- {
- return "xyz.openbmc_project.Network.IP.AddressOrigin.Static";
- }
- if (inputOrigin == "DHCP" || inputOrigin == "DHCPv6")
- {
- return "xyz.openbmc_project.Network.IP.AddressOrigin.DHCP";
- }
- if (inputOrigin == "IPv4LinkLocal" || inputOrigin == "LinkLocal")
- {
- return "xyz.openbmc_project.Network.IP.AddressOrigin.LinkLocal";
- }
- if (inputOrigin == "SLAAC")
- {
- return "xyz.openbmc_project.Network.IP.AddressOrigin.SLAAC";
- }
- return "";
-}
-
inline bool extractEthernetInterfaceData(const std::string ðiface_id,
const GetManagedObjects &dbus_data,
EthernetInterfaceData ðData)
@@ -632,47 +610,6 @@
}
/**
- * @brief Changes IPv4 address origin property
- *
- * @param[in] ifaceId Id of interface whose IP should be modified
- * @param[in] ipIdx Index of IP in input array that should be
- * modified
- * @param[in] ipHash DBus Hash id of modified IP
- * @param[in] newValue New value in Redfish format
- * @param[in] newValueDbus New value in D-Bus format
- * @param[io] asyncResp Response object that will be returned to client
- *
- * @return true if give IP is valid and has been sent do D-Bus, false
- * otherwise
- */
-inline void changeIPv4Origin(const std::string &ifaceId, int ipIdx,
- const std::string &ipHash,
- const std::string &newValue,
- const std::string &newValueDbus,
- const std::shared_ptr<AsyncResp> asyncResp)
-{
- auto callback = [asyncResp, ipIdx, newValue{std::move(newValue)}](
- const boost::system::error_code ec) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- }
- else
- {
- asyncResp->res.jsonValue["IPv4Addresses"][ipIdx]["AddressOrigin"] =
- newValue;
- }
- };
-
- crow::connections::systemBus->async_method_call(
- std::move(callback), "xyz.openbmc_project.Network",
- "/xyz/openbmc_project/network/" + ifaceId + "/ipv4/" + ipHash,
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Network.IP", "Origin",
- std::variant<std::string>(newValueDbus));
-}
-
-/**
* @brief Modifies SubnetMask for given IP
*
* @param[in] ifaceId Id of interface whose IP should be modified
@@ -1262,14 +1199,12 @@
}
std::optional<std::string> address;
- std::optional<std::string> addressOrigin;
std::optional<std::string> subnetMask;
std::optional<std::string> gateway;
if (!json_util::readJson(thisJson, asyncResp->res, "Address",
- address, "AddressOrigin", addressOrigin,
- "SubnetMask", subnetMask, "Gateway",
- gateway))
+ address, "SubnetMask", subnetMask,
+ "Gateway", gateway))
{
return;
}
@@ -1295,20 +1230,6 @@
return;
}
}
- std::string addressOriginInDBusFormat;
- if (addressOrigin)
- {
- // Get Address origin in proper format
- addressOriginInDBusFormat =
- translateAddressOriginRedfishToDbus(*addressOrigin);
- if (addressOriginInDBusFormat.empty())
- {
- messages::propertyValueNotInList(
- asyncResp->res, *addressOrigin,
- pathString + "/AddressOrigin");
- return;
- }
- }
if (gateway)
{
@@ -1355,13 +1276,6 @@
prefixLength, asyncResp);
}
- if (addressOrigin)
- {
- changeIPv4Origin(ifaceId, entryIdx, thisData->id,
- *addressOrigin, addressOriginInDBusFormat,
- asyncResp);
- }
-
if (gateway)
{
auto callback = [asyncResp, entryIdx,