Fix merge conflict
Got a couple patches that collided in air, and now builds are broken.
This resolves the collision by moving the new patches forward to the
latest #defines
Change-Id: I1fe35d17a68c61ad90752ae73000e2579131bf5d
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 293e802..4c44527 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -196,9 +196,8 @@
// single ethernet interface, loop over all of them
for (auto &objpath : dbus_data) {
// Check if proper patter for object path appears
- if (boost::starts_with(
- static_cast<const std::string &>(objpath.first),
- "/xyz/openbmc_project/network/" + ethifaceId + "/ipv4/")) {
+ if (boost::starts_with(static_cast<const std::string &>(objpath.first),
+ pathStart)) {
// and get approrpiate interface
const auto &interface =
objpath.second.find("xyz.openbmc_project.Network.IP");
@@ -236,7 +235,7 @@
// Attach IPv4 only if address is present
if (ipv4Address.address != nullptr) {
- // Check if given addres is local, or global
+ // Check if given address is local, or global
if (boost::starts_with(*ipv4Address.address, "169.254")) {
ipv4Address.global = false;
} else {
@@ -391,18 +390,17 @@
const std::string &name,
const std::string &newValue,
const std::shared_ptr<AsyncResp> &asyncResp) {
- auto callback = [
- asyncResp, ipIdx{std::move(ipIdx)}, name{std::move(name)},
- newValue{std::move(newValue)}
- ](const boost::system::error_code ec) {
- if (ec) {
- messages::addMessageToJson(
- asyncResp->res.jsonValue, messages::internalError(),
- "/IPv4Addresses/" + std::to_string(ipIdx) + "/" + name);
- } else {
- asyncResp->res.jsonValue["IPv4Addresses"][ipIdx][name] = newValue;
- }
- };
+ auto callback =
+ [asyncResp, ipIdx{std::move(ipIdx)}, name{std::move(name)},
+ newValue{std::move(newValue)}](const boost::system::error_code ec) {
+ if (ec) {
+ messages::addMessageToJson(
+ asyncResp->res.jsonValue, messages::internalError(),
+ "/IPv4Addresses/" + std::to_string(ipIdx) + "/" + name);
+ } else {
+ asyncResp->res.jsonValue["IPv4Addresses"][ipIdx][name] = newValue;
+ }
+ };
crow::connections::systemBus->async_method_call(
std::move(callback), "xyz.openbmc_project.Network",
@@ -430,17 +428,17 @@
const std::string &newValueDbus,
const std::shared_ptr<AsyncResp> &asyncResp) {
auto callback =
- [ asyncResp, ipIdx{std::move(ipIdx)},
- newValue{std::move(newValue)} ](const boost::system::error_code ec) {
- if (ec) {
- messages::addMessageToJson(
- asyncResp->res.jsonValue, messages::internalError(),
- "/IPv4Addresses/" + std::to_string(ipIdx) + "/AddressOrigin");
- } else {
- asyncResp->res.jsonValue["IPv4Addresses"][ipIdx]["AddressOrigin"] =
- newValue;
- }
- };
+ [asyncResp, ipIdx{std::move(ipIdx)},
+ newValue{std::move(newValue)}](const boost::system::error_code ec) {
+ if (ec) {
+ messages::addMessageToJson(
+ asyncResp->res.jsonValue, messages::internalError(),
+ "/IPv4Addresses/" + std::to_string(ipIdx) + "/AddressOrigin");
+ } else {
+ asyncResp->res.jsonValue["IPv4Addresses"][ipIdx]["AddressOrigin"] =
+ newValue;
+ }
+ };
crow::connections::systemBus->async_method_call(
std::move(callback), "xyz.openbmc_project.Network",
@@ -466,9 +464,9 @@
const std::string &ifaceId, int ipIdx, const std::string &ipHash,
const std::string &newValueStr, uint8_t &newValue,
const std::shared_ptr<AsyncResp> &asyncResp) {
- auto callback = [
- asyncResp, ipIdx{std::move(ipIdx)}, newValueStr{std::move(newValueStr)}
- ](const boost::system::error_code ec) {
+ auto callback = [asyncResp, ipIdx{std::move(ipIdx)},
+ newValueStr{std::move(newValueStr)}](
+ const boost::system::error_code ec) {
if (ec) {
messages::addMessageToJson(
asyncResp->res.jsonValue, messages::internalError(),
@@ -535,8 +533,8 @@
unsigned int ipIdx,
const std::shared_ptr<AsyncResp> &asyncResp) {
crow::connections::systemBus->async_method_call(
- [ ipIdx{std::move(ipIdx)}, asyncResp{std::move(asyncResp)} ](
- const boost::system::error_code ec) {
+ [ipIdx{std::move(ipIdx)},
+ asyncResp{std::move(asyncResp)}](const boost::system::error_code ec) {
if (ec) {
messages::addMessageToJson(
asyncResp->res.jsonValue, messages::internalError(),
@@ -564,15 +562,15 @@
uint8_t subnetMask, const std::string &gateway,
const std::string &address,
const std::shared_ptr<AsyncResp> &asyncResp) {
- auto createIpHandler = [
- ipIdx{std::move(ipIdx)}, asyncResp{std::move(asyncResp)}
- ](const boost::system::error_code ec) {
- if (ec) {
- messages::addMessageToJson(
- asyncResp->res.jsonValue, messages::internalError(),
- "/IPv4Addresses/" + std::to_string(ipIdx) + "/");
- }
- };
+ auto createIpHandler =
+ [ipIdx{std::move(ipIdx)},
+ asyncResp{std::move(asyncResp)}](const boost::system::error_code ec) {
+ if (ec) {
+ messages::addMessageToJson(
+ asyncResp->res.jsonValue, messages::internalError(),
+ "/IPv4Addresses/" + std::to_string(ipIdx) + "/");
+ }
+ };
crow::connections::systemBus->async_method_call(
std::move(createIpHandler), "xyz.openbmc_project.Network",
@@ -642,12 +640,10 @@
void getEthernetIfaceData(const std::string ðifaceId,
CallbackFunc &&callback) {
crow::connections::systemBus->async_method_call(
- [
- this, ethifaceId{std::move(ethifaceId)},
- callback{std::move(callback)}
- ](const boost::system::error_code error_code,
- const GetManagedObjectsType &resp) {
-
+ [this, ethifaceId{std::move(ethifaceId)},
+ callback{std::move(callback)}](
+ const boost::system::error_code error_code,
+ const GetManagedObjectsType &resp) {
EthernetInterfaceData ethData{};
std::vector<IPv4AddressData> ipv4Data;
ipv4Data.reserve(maxIpV4AddressesPerInterface);
@@ -681,7 +677,7 @@
}
}
- // Finally make a callback with usefull data
+ // Finally make a callback with useful data
callback(true, ethData, ipv4Data);
},
"xyz.openbmc_project.Network", "/xyz/openbmc_project/network",
@@ -697,7 +693,7 @@
template <typename CallbackFunc>
void getEthernetIfaceList(CallbackFunc &&callback) {
crow::connections::systemBus->async_method_call(
- [ this, callback{std::move(callback)} ](
+ [this, callback{std::move(callback)}](
const boost::system::error_code error_code,
GetManagedObjectsType &resp) {
// Callback requires vector<string> to retrieve all available ethernet
@@ -721,7 +717,7 @@
// this is what we're looking for.
if (interface.first ==
"xyz.openbmc_project.Network.EthernetInterface") {
- // Cut out everyting until last "/", ...
+ // Cut out everything until last "/", ...
const std::string &ifaceId =
static_cast<const std::string &>(objpath.first);
std::size_t lastPos = ifaceId.rfind("/");
@@ -732,7 +728,7 @@
}
}
}
- // Finally make a callback with usefull data
+ // Finally make a callback with useful data
callback(true, ifaceList);
},
"xyz.openbmc_project.Network", "/xyz/openbmc_project/network",
@@ -780,26 +776,27 @@
std::string managerId = "openbmc";
// get eth interface list, and call the below callback for JSON preparation
- ethernetProvider.getEthernetIfaceList([&, managerId{std::move(managerId)} ](
- const bool &success, const std::vector<std::string> &iface_list) {
- if (success) {
- nlohmann::json ifaceArray = nlohmann::json::array();
- for (const std::string &ifaceItem : iface_list) {
- ifaceArray.push_back(
- {{"@odata.id", "/redfish/v1/Managers/" + managerId +
- "/EthernetInterfaces/" + ifaceItem}});
- }
- Node::json["Members"] = ifaceArray;
- Node::json["Members@odata.count"] = ifaceArray.size();
- Node::json["@odata.id"] =
- "/redfish/v1/Managers/" + managerId + "/EthernetInterfaces";
- res.jsonValue = Node::json;
- } else {
- // No success, best what we can do is return INTERNALL ERROR
- res.result(boost::beast::http::status::internal_server_error);
- }
- res.end();
- });
+ ethernetProvider.getEthernetIfaceList(
+ [&, managerId{std::move(managerId)}](
+ const bool &success, const std::vector<std::string> &iface_list) {
+ if (success) {
+ nlohmann::json ifaceArray = nlohmann::json::array();
+ for (const std::string &ifaceItem : iface_list) {
+ ifaceArray.push_back(
+ {{"@odata.id", "/redfish/v1/Managers/" + managerId +
+ "/EthernetInterfaces/" + ifaceItem}});
+ }
+ Node::json["Members"] = ifaceArray;
+ Node::json["Members@odata.count"] = ifaceArray.size();
+ Node::json["@odata.id"] =
+ "/redfish/v1/Managers/" + managerId + "/EthernetInterfaces";
+ res.jsonValue = Node::json;
+ } else {
+ // No success, best what we can do is return INTERNALL ERROR
+ res.result(boost::beast::http::status::internal_server_error);
+ }
+ res.end();
+ });
}
// Ethernet Provider object
@@ -905,7 +902,7 @@
paramsJson["VLANId"] = inputVlanId;
OnDemandEthernetProvider::changeVlanId(
ifaceId, static_cast<uint32_t>(inputVlanId),
- [&, asyncResp, pathPrefx{std::move(pathPrefix)} ](
+ [&, asyncResp, pathPrefx{std::move(pathPrefix)}](
const boost::system::error_code ec) {
if (ec) {
messages::addMessageToJson(asyncResp->res.jsonValue,
@@ -917,7 +914,7 @@
} else if (inputVlanEnabled == false) {
// Disable VLAN
OnDemandEthernetProvider::disableVlan(
- ifaceId, [&, asyncResp, pathPrefx{std::move(pathPrefix)} ](
+ ifaceId, [&, asyncResp, pathPrefx{std::move(pathPrefix)}](
const boost::system::error_code ec) {
if (ec) {
messages::addMessageToJson(asyncResp->res.jsonValue,
@@ -1289,7 +1286,7 @@
// get single eth interface data, and call the below callback for JSON
// preparation
ethernetProvider.getEthernetIfaceData(
- ifaceId, [&, ifaceId, patchReq = std::move(patchReq) ](
+ ifaceId, [&, ifaceId, patchReq = std::move(patchReq)](
const bool &success, const EthernetInterfaceData ð_data,
const std::vector<IPv4AddressData> &ipv4_data) {
if (!success) {
@@ -1390,12 +1387,6 @@
// Copy JSON object to avoid race condition
nlohmann::json jsonResponse(Node::json);
- if (eth_data.vlanId == nullptr) {
- // Interface not a VLAN - abort
- messages::addMessageToErrorJson(jsonResponse, messages::internalError());
- return jsonResponse;
- }
-
// Fill out obvious data...
jsonResponse["Id"] = ifaceId;
jsonResponse["@odata.id"] =
@@ -1441,16 +1432,19 @@
const std::string &parentIfaceId = params[0];
const std::string &ifaceId = params[1];
+ if (!verifyNames(res, parentIfaceId, ifaceId)) {
+ return;
+ }
+
// Get single eth interface data, and call the below callback for JSON
// preparation
ethernetProvider.getEthernetIfaceData(
- ifaceId,
- [&, parentIfaceId, ifaceId](
- const bool &success, const EthernetInterfaceData ð_data,
- const std::vector<IPv4AddressData> &ipv4_data) {
+ ifaceId, [&, parentIfaceId, ifaceId](
+ const bool &success, const EthernetInterfaceData ð_data,
+ const std::vector<IPv4AddressData> &ipv4_data) {
if (success && eth_data.vlanId != nullptr) {
- res.jsonValue = parseInterfaceData(parentIfaceId, ifaceId,
- eth_data, ipv4_data);
+ res.jsonValue =
+ parseInterfaceData(parentIfaceId, ifaceId, eth_data, ipv4_data);
} else {
// ... otherwise return error
// TODO(Pawel)consider distinguish between non existing object, and
@@ -1488,10 +1482,9 @@
// Get single eth interface data, and call the below callback for JSON
// preparation
ethernetProvider.getEthernetIfaceData(
- ifaceId,
- [&, parent_ifaceId, ifaceId, patchReq = std::move(patchReq) ](
- const bool &success, const EthernetInterfaceData ð_data,
- const std::vector<IPv4AddressData> &ipv4_data) {
+ ifaceId, [&, parent_ifaceId, ifaceId, patchReq = std::move(patchReq)](
+ const bool &success, const EthernetInterfaceData ð_data,
+ const std::vector<IPv4AddressData> &ipv4_data) {
if (!success) {
// ... otherwise return error
// TODO(Pawel)consider distinguish between non existing object,
@@ -1506,8 +1499,8 @@
return;
}
- res.jsonValue = parseInterfaceData(parent_ifaceId, ifaceId,
- eth_data, ipv4_data);
+ res.jsonValue =
+ parseInterfaceData(parent_ifaceId, ifaceId, eth_data, ipv4_data);
std::shared_ptr<AsyncResp> asyncResp =
std::make_shared<AsyncResp>(res);
@@ -1521,8 +1514,7 @@
if (fieldInJsonIt == res.jsonValue.end()) {
// Field not in scope of defined fields
messages::addMessageToJsonRoot(
- res.jsonValue,
- messages::propertyUnknown(propertyIt.key()));
+ res.jsonValue, messages::propertyUnknown(propertyIt.key()));
} else if (*fieldInJsonIt != *propertyIt) {
// User attempted to modify non-writable field
messages::addMessageToJsonRoot(
@@ -1555,13 +1547,12 @@
// Get single eth interface data, and call the below callback for JSON
// preparation
ethernetProvider.getEthernetIfaceData(
- ifaceId,
- [&, parent_ifaceId, ifaceId](
- const bool &success, const EthernetInterfaceData ð_data,
- const std::vector<IPv4AddressData> &ipv4_data) {
+ ifaceId, [&, parent_ifaceId, ifaceId](
+ const bool &success, const EthernetInterfaceData ð_data,
+ const std::vector<IPv4AddressData> &ipv4_data) {
if (success && eth_data.vlanId != nullptr) {
res.jsonValue = parseInterfaceData(parent_ifaceId, ifaceId,
- eth_data, ipv4_data);
+ eth_data, ipv4_data);
// Disable VLAN
OnDemandEthernetProvider::disableVlan(
@@ -1653,45 +1644,47 @@
std::string rootInterfaceName = params[0];
// get eth interface list, and call the below callback for JSON preparation
- ethernetProvider.getEthernetIfaceList([
- &, managerId{std::move(managerId)},
- rootInterfaceName{std::move(rootInterfaceName)}
- ](const bool &success, const std::vector<std::string> &iface_list) {
- if (success) {
- bool rootInterfaceFound = false;
- nlohmann::json ifaceArray = nlohmann::json::array();
+ ethernetProvider.getEthernetIfaceList(
+ [&, managerId{std::move(managerId)},
+ rootInterfaceName{std::move(rootInterfaceName)}](
+ const bool &success, const std::vector<std::string> &iface_list) {
+ if (success) {
+ bool rootInterfaceFound = false;
+ nlohmann::json ifaceArray = nlohmann::json::array();
- for (const std::string &ifaceItem : iface_list) {
- if (ifaceItem == rootInterfaceName) {
- rootInterfaceFound = true;
- } else if (boost::starts_with(ifaceItem, rootInterfaceName + "_")) {
- ifaceArray.push_back(
- {{"@odata.id", "/redfish/v1/Managers/" + managerId +
- "/EthernetInterfaces/" + rootInterfaceName +
- "/VLANs/" + ifaceItem}});
+ for (const std::string &ifaceItem : iface_list) {
+ if (ifaceItem == rootInterfaceName) {
+ rootInterfaceFound = true;
+ } else if (boost::starts_with(ifaceItem,
+ rootInterfaceName + "_")) {
+ ifaceArray.push_back(
+ {{"@odata.id", "/redfish/v1/Managers/" + managerId +
+ "/EthernetInterfaces/" +
+ rootInterfaceName + "/VLANs/" +
+ ifaceItem}});
+ }
+ }
+
+ if (rootInterfaceFound) {
+ Node::json["Members"] = ifaceArray;
+ Node::json["Members@odata.count"] = ifaceArray.size();
+ Node::json["@odata.id"] = "/redfish/v1/Managers/" + managerId +
+ "/EthernetInterfaces/" +
+ rootInterfaceName + "/VLANs";
+ res.jsonValue = Node::json;
+ } else {
+ messages::addMessageToErrorJson(
+ res.jsonValue, messages::resourceNotFound("EthernetInterface",
+ rootInterfaceName));
+ res.result(boost::beast::http::status::not_found);
+ res.end();
+ }
+ } else {
+ // No success, best what we can do is return INTERNALL ERROR
+ res.result(boost::beast::http::status::internal_server_error);
}
- }
-
- if (rootInterfaceFound) {
- Node::json["Members"] = ifaceArray;
- Node::json["Members@odata.count"] = ifaceArray.size();
- Node::json["@odata.id"] = "/redfish/v1/Managers/" + managerId +
- "/EthernetInterfaces/" + rootInterfaceName +
- "/VLANs";
- res.jsonValue = Node::json;
- } else {
- messages::addMessageToErrorJson(
- res.jsonValue, messages::resourceNotFound("EthernetInterface",
- rootInterfaceName));
- res.result(boost::beast::http::status::not_found);
res.end();
- }
- } else {
- // No success, best what we can do is return INTERNALL ERROR
- res.result(boost::beast::http::status::internal_server_error);
- }
- res.end();
- });
+ });
}
void doPost(crow::Response &res, const crow::Request &req,
@@ -1726,49 +1719,49 @@
}
// get eth interface list, and call the below callback for JSON preparation
- ethernetProvider.getEthernetIfaceList([
- &, managerId{std::move(managerId)},
- rootInterfaceName{std::move(rootInterfaceName)}
- ](const bool &success, const std::vector<std::string> &iface_list) {
- if (success) {
- bool rootInterfaceFound = false;
+ ethernetProvider.getEthernetIfaceList(
+ [&, managerId{std::move(managerId)},
+ rootInterfaceName{std::move(rootInterfaceName)}](
+ const bool &success, const std::vector<std::string> &iface_list) {
+ if (success) {
+ bool rootInterfaceFound = false;
- for (const std::string &ifaceItem : iface_list) {
- if (ifaceItem == rootInterfaceName) {
- rootInterfaceFound = true;
- break;
+ for (const std::string &ifaceItem : iface_list) {
+ if (ifaceItem == rootInterfaceName) {
+ rootInterfaceFound = true;
+ break;
+ }
+ }
+
+ if (rootInterfaceFound) {
+ ethernetProvider.createVlan(
+ rootInterfaceName, vlanId,
+ [&, vlanId, rootInterfaceName,
+ req{std::move(req)}](const boost::system::error_code ec) {
+ if (ec) {
+ messages::addMessageToErrorJson(
+ res.jsonValue, messages::internalError());
+ res.end();
+ } else {
+ memberVlan.doGet(
+ res, req,
+ {rootInterfaceName,
+ rootInterfaceName + "_" + std::to_string(vlanId)});
+ }
+ });
+ } else {
+ messages::addMessageToErrorJson(
+ res.jsonValue, messages::resourceNotFound("EthernetInterface",
+ rootInterfaceName));
+ res.result(boost::beast::http::status::not_found);
+ res.end();
+ }
+ } else {
+ // No success, best what we can do is return INTERNALL ERROR
+ res.result(boost::beast::http::status::internal_server_error);
+ res.end();
}
- }
-
- if (rootInterfaceFound) {
- ethernetProvider.createVlan(
- rootInterfaceName, vlanId,
- [&, vlanId, rootInterfaceName,
- req{std::move(req)} ](const boost::system::error_code ec) {
- if (ec) {
- messages::addMessageToErrorJson(res.jsonValue,
- messages::internalError());
- res.end();
- } else {
- memberVlan.doGet(
- res, req,
- {rootInterfaceName,
- rootInterfaceName + "_" + std::to_string(vlanId)});
- }
- });
- } else {
- messages::addMessageToErrorJson(
- res.jsonValue, messages::resourceNotFound("EthernetInterface",
- rootInterfaceName));
- res.result(boost::beast::http::status::not_found);
- res.end();
- }
- } else {
- // No success, best what we can do is return INTERNALL ERROR
- res.result(boost::beast::http::status::internal_server_error);
- res.end();
- }
- });
+ });
}
// Ethernet Provider object