summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRatan Gupta <ratagupt@linux.vnet.ibm.com>2019-03-03 08:47:22 +0530
committerRatan Gupta <ratagupt@linux.vnet.ibm.com>2019-03-19 09:08:21 +0530
commitd577665b5dddb29d2bf2ecffb43063c36a4a954f (patch)
tree4fb1873bb326c11ffcc333002849e44fcfd8f815
parentf476acbf885119861a1fecad47399a8eeeff0086 (diff)
downloadbmcweb-d577665b5dddb29d2bf2ecffb43063c36a4a954f.tar.gz
bmcweb-d577665b5dddb29d2bf2ecffb43063c36a4a954f.zip
Redfish(Network): Support the PATCH opertration of MACAddress property
TestedBy: PATCH '{"MACAddress": "x2:xx:xx:xx:xx:xx"}' Change-Id: I6dc421ea509506a2f3062fc0531778ffa2b00310 Signed-off-by: Ratan Gupta <ratagupt@linux.vnet.ibm.com>
-rw-r--r--redfish-core/lib/ethernet.hpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 2a0b618..1d3cb85 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -964,6 +964,26 @@ class EthernetInterface : public Node
std::variant<std::string>(hostname));
}
+ void handleMACAddressPatch(const std::string &ifaceId,
+ const std::string &macAddress,
+ const std::shared_ptr<AsyncResp> &asyncResp)
+ {
+ crow::connections::systemBus->async_method_call(
+ [asyncResp, macAddress](const boost::system::error_code ec) {
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue["MACAddress"] = std::move(macAddress);
+ },
+ "xyz.openbmc_project.Network",
+ "/xyz/openbmc_project/network/" + ifaceId,
+ "org.freedesktop.DBus.Properties", "Set",
+ "xyz.openbmc_project.Network.MACAddress", "MACAddress",
+ std::variant<std::string>(macAddress));
+ }
+
void handleIPv4Patch(
const std::string &ifaceId, nlohmann::json &input,
const boost::container::flat_set<IPv4AddressData> &ipv4Data,
@@ -1302,12 +1322,14 @@ class EthernetInterface : public Node
std::optional<nlohmann::json> vlan;
std::optional<std::string> hostname;
+ std::optional<std::string> macAddress;
std::optional<nlohmann::json> ipv4Addresses;
std::optional<nlohmann::json> ipv6Addresses;
if (!json_util::readJson(req, res, "VLAN", vlan, "HostName", hostname,
"IPv4Addresses", ipv4Addresses,
- "IPv6Addresses", ipv6Addresses))
+ "IPv6Addresses", ipv6Addresses, "MACAddress",
+ macAddress))
{
return;
}
@@ -1343,7 +1365,7 @@ class EthernetInterface : public Node
getEthernetIfaceData(
iface_id,
[this, asyncResp, iface_id, vlanId, vlanEnable,
- hostname = std::move(hostname),
+ hostname = std::move(hostname), macAddress = std::move(macAddress),
ipv4Addresses = std::move(ipv4Addresses),
ipv6Addresses = std::move(ipv6Addresses)](
const bool &success, const EthernetInterfaceData &ethData,
@@ -1372,6 +1394,11 @@ class EthernetInterface : public Node
handleHostnamePatch(*hostname, asyncResp);
}
+ if (macAddress)
+ {
+ handleMACAddressPatch(iface_id, *macAddress, asyncResp);
+ }
+
if (ipv4Addresses)
{
// TODO(ed) for some reason the capture of ipv4Addresses
OpenPOWER on IntegriCloud