summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--http/http_connection.h4
-rw-r--r--include/dump_offload.hpp299
-rw-r--r--redfish-core/include/redfish.hpp3
-rw-r--r--redfish-core/lib/event_service.hpp107
-rw-r--r--redfish-core/lib/log_services.hpp70
-rw-r--r--redfish-core/lib/redfish_sessions.hpp7
6 files changed, 0 insertions, 490 deletions
diff --git a/http/http_connection.h b/http/http_connection.h
index 109a272253..7781ca60a7 100644
--- a/http/http_connection.h
+++ b/http/http_connection.h
@@ -348,10 +348,6 @@ class Connection :
if (!isInvalidRequest)
{
- req->socket = [self = shared_from_this()]() -> Adaptor& {
- return self->socket();
- };
-
res.completeRequestHandler = [] {};
res.isAliveHelper = [this]() -> bool { return isAlive(); };
diff --git a/include/dump_offload.hpp b/include/dump_offload.hpp
deleted file mode 100644
index bc885cf573..0000000000
--- a/include/dump_offload.hpp
+++ /dev/null
@@ -1,299 +0,0 @@
-#pragma once
-
-#include <signal.h>
-#include <sys/select.h>
-
-#include <boost/beast/core/flat_static_buffer.hpp>
-#include <boost/beast/http.hpp>
-#include <boost/process.hpp>
-
-#include <cstdio>
-#include <cstdlib>
-
-namespace crow
-{
-namespace obmc_dump
-{
-
-inline void handleDumpOffloadUrl(const crow::Request& req, crow::Response& res,
- const std::string& entryId);
-inline void resetHandler();
-
-// The max network block device buffer size is 128kb plus 16bytes
-// for the message header
-static constexpr auto nbdBufferSize = 131088;
-
-/** class Handler
- * handles data transfer between nbd-client and nbd-server.
- * This handler invokes nbd-proxy and reads data from socket
- * and writes on to nbd-client and vice-versa
- */
-class Handler : public std::enable_shared_from_this<Handler>
-{
- public:
- Handler(const std::string& mediaIn, boost::asio::io_context& ios,
- const std::string& entryIDIn) :
- pipeOut(ios),
- pipeIn(ios), media(mediaIn), entryID(entryIDIn), doingWrite(false),
- negotiationDone(false), writeonnbd(false),
- outputBuffer(std::make_unique<
- boost::beast::flat_static_buffer<nbdBufferSize>>()),
- inputBuffer(
- std::make_unique<boost::beast::flat_static_buffer<nbdBufferSize>>())
- {}
-
- ~Handler()
- {}
-
- /**
- * @brief Invokes InitiateOffload method of dump manager which
- * directs pldm to start writing on the nbd device.
- *
- * @return void
- */
- void initiateOffloadOnNbdDevice()
- {
- crow::connections::systemBus->async_method_call(
- [this,
- self(shared_from_this())](const boost::system::error_code ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << "DBUS response error: " << ec;
- resetBuffers();
- resetHandler();
- return;
- }
- },
- "xyz.openbmc_project.Dump.Manager",
- "/xyz/openbmc_project/dump/entry/" + entryID,
- "xyz.openbmc_project.Dump.Entry", "InitiateOffload", "/dev/nbd1");
- }
-
- /**
- * @brief Kills nbd-proxy
- *
- * @return void
- */
- void doClose()
- {
- int rc = kill(proxy.id(), SIGTERM);
- if (rc)
- {
- return;
- }
- proxy.wait();
- }
-
- /**
- * @brief Starts nbd-proxy
- *
- * @return void
- */
- void connect()
- {
- std::error_code ec;
- proxy = boost::process::child("/usr/sbin/nbd-proxy", media,
- boost::process::std_out > pipeOut,
- boost::process::std_in < pipeIn, ec);
- if (ec)
- {
- BMCWEB_LOG_ERROR << "Couldn't connect to nbd-proxy: "
- << ec.message();
- resetHandler();
- return;
- }
- doRead();
- }
-
- /**
- * @brief Wait for data on tcp socket from nbd-server.
- *
- * @return void
- */
- void waitForMessageOnSocket()
- {
-
- std::size_t bytes = inputBuffer->capacity() - inputBuffer->size();
-
- (*stream).async_read_some(
- inputBuffer->prepare(bytes),
- [this,
- self(shared_from_this())](const boost::system::error_code& ec,
- std::size_t bytes_transferred) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG << "Error while reading on socket";
- doClose();
- resetBuffers();
- resetHandler();
- return;
- }
-
- inputBuffer->commit(bytes_transferred);
- doWrite();
- });
- }
-
- /**
- * @brief Writes data on input pipe of nbd-client.
- *
- * @return void
- */
- void doWrite()
- {
-
- if (doingWrite)
- {
- BMCWEB_LOG_DEBUG << "Already writing. Bailing out";
- return;
- }
-
- if (inputBuffer->size() == 0)
- {
- BMCWEB_LOG_DEBUG << "inputBuffer empty. Bailing out";
- return;
- }
-
- doingWrite = true;
- boost::asio::async_write(
- pipeIn, inputBuffer->data(),
- [this, self(shared_from_this())](const boost::beast::error_code& ec,
- std::size_t bytesWritten) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG << "VM socket port closed";
- doClose();
- resetBuffers();
- resetHandler();
- return;
- }
-
- doingWrite = false;
-
- if (negotiationDone == false)
- {
- // "gDf" is NBD reply magic
- std::string reply_magic("gDf");
- std::string reply_string(
- static_cast<char*>(inputBuffer->data().data()),
- bytesWritten);
- std::size_t found = reply_string.find(reply_magic);
- if (found != std::string::npos)
- {
- negotiationDone = true;
- writeonnbd = true;
- }
- }
-
- inputBuffer->consume(bytesWritten);
- waitForMessageOnSocket();
- if (writeonnbd)
- {
- // NBD Negotiation Complete!!!!. Notify Dump manager to
- // start dumping the actual data over NBD device
- initiateOffloadOnNbdDevice();
- writeonnbd = false;
- }
- });
- }
-
- /**
- * @brief Reads data on output pipe of nbd-client and write on
- * tcp socket.
- *
- * @return void
- */
- void doRead()
- {
- std::size_t bytes = outputBuffer->capacity() - outputBuffer->size();
-
- pipeOut.async_read_some(
- outputBuffer->prepare(bytes),
- [this, self(shared_from_this())](
- const boost::system::error_code& ec, std::size_t bytesRead) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << "Couldn't read from VM port: " << ec;
- doClose();
- resetBuffers();
- resetHandler();
- return;
- }
-
- outputBuffer->commit(bytesRead);
-
- boost::asio::async_write(
- *stream, outputBuffer->data(),
- [this](const boost::system::error_code& ec2,
- std::size_t bytes_transferred) {
- if (ec2)
- {
- BMCWEB_LOG_DEBUG << "Error while writing on socket";
- doClose();
- resetBuffers();
- resetHandler();
- return;
- }
-
- outputBuffer->consume(bytes_transferred);
- doRead();
- });
- });
- }
-
- /**
- * @brief Resets input and output buffers.
- * @return void
- */
- void resetBuffers()
- {
- this->inputBuffer->clear();
- this->outputBuffer->clear();
- }
-
- boost::process::async_pipe pipeOut;
- boost::process::async_pipe pipeIn;
- boost::process::child proxy;
- std::string media;
- std::string entryID;
- bool doingWrite;
- bool negotiationDone;
- bool writeonnbd;
- std::unique_ptr<boost::beast::flat_static_buffer<nbdBufferSize>>
- outputBuffer;
- std::unique_ptr<boost::beast::flat_static_buffer<nbdBufferSize>>
- inputBuffer;
- std::shared_ptr<crow::Request::Adaptor> stream;
-};
-
-static std::shared_ptr<Handler> handler;
-inline void resetHandler()
-{
-
- handler.reset();
-}
-inline void handleDumpOffloadUrl(const crow::Request& req, crow::Response& res,
- const std::string& entryId)
-{
-
- // Run only one instance of Handler, one dump offload can happen at a time
- if (handler != nullptr)
- {
- BMCWEB_LOG_ERROR << "Handler already running";
- res.result(boost::beast::http::status::service_unavailable);
- res.jsonValue["Description"] = "Service is already being used";
- res.end();
- return;
- }
-
- const char* media = "1";
- boost::asio::io_context* io_con = req.ioService;
-
- handler = std::make_shared<Handler>(media, *io_con, entryId);
- handler->stream =
- std::make_shared<crow::Request::Adaptor>(std::move(req.socket()));
- handler->connect();
- handler->waitForMessageOnSocket();
-}
-} // namespace obmc_dump
-} // namespace crow
diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp
index 18a0353e49..8a2b972ed3 100644
--- a/redfish-core/include/redfish.hpp
+++ b/redfish-core/include/redfish.hpp
@@ -108,14 +108,12 @@ class RedfishService
nodes.emplace_back(std::make_unique<SystemDumpEntryCollection>(app));
nodes.emplace_back(std::make_unique<SystemDumpEntry>(app));
nodes.emplace_back(std::make_unique<SystemDumpCreate>(app));
- nodes.emplace_back(std::make_unique<SystemDumpEntryDownload>(app));
nodes.emplace_back(std::make_unique<SystemDumpClear>(app));
nodes.emplace_back(std::make_unique<BMCDumpService>(app));
nodes.emplace_back(std::make_unique<BMCDumpEntryCollection>(app));
nodes.emplace_back(std::make_unique<BMCDumpEntry>(app));
nodes.emplace_back(std::make_unique<BMCDumpCreate>(app));
- nodes.emplace_back(std::make_unique<BMCDumpEntryDownload>(app));
nodes.emplace_back(std::make_unique<BMCDumpClear>(app));
#endif
@@ -199,7 +197,6 @@ class RedfishService
nodes.emplace_back(std::make_unique<TaskCollection>(app));
nodes.emplace_back(std::make_unique<Task>(app));
nodes.emplace_back(std::make_unique<EventService>(app));
- nodes.emplace_back(std::make_unique<EventServiceSSE>(app));
nodes.emplace_back(std::make_unique<EventDestinationCollection>(app));
nodes.emplace_back(std::make_unique<EventDestination>(app));
nodes.emplace_back(std::make_unique<SubmitTestEvent>(app));
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index 7d17ceacb2..e1c06ec3f2 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -59,8 +59,6 @@ class EventService : public Node
{"@odata.type", "#EventService.v1_5_0.EventService"},
{"Id", "EventService"},
{"Name", "Event Service"},
- {"ServerSentEventUri",
- "/redfish/v1/EventService/Subscriptions/SSE"},
{"Subscriptions",
{{"@odata.id", "/redfish/v1/EventService/Subscriptions"}}},
{"Actions",
@@ -447,111 +445,6 @@ class EventDestinationCollection : public Node
}
};
-class EventServiceSSE : public Node
-{
- public:
- EventServiceSSE(App& app) :
- Node(app, "/redfish/v1/EventService/Subscriptions/SSE/")
- {
- entityPrivileges = {
- {boost::beast::http::verb::get, {{"ConfigureManager"}}},
- {boost::beast::http::verb::head, {{"ConfigureManager"}}},
- {boost::beast::http::verb::patch, {{"ConfigureManager"}}},
- {boost::beast::http::verb::put, {{"ConfigureManager"}}},
- {boost::beast::http::verb::delete_, {{"ConfigureManager"}}},
- {boost::beast::http::verb::post, {{"ConfigureManager"}}}};
- }
-
- private:
- void doGet(crow::Response& res, const crow::Request& req,
- const std::vector<std::string>&) override
- {
- if (EventServiceManager::getInstance().getNumberOfSubscriptions() >=
- maxNoOfSubscriptions)
- {
- messages::eventSubscriptionLimitExceeded(res);
- res.end();
- return;
- }
-
- std::shared_ptr<crow::Request::Adaptor> sseConn =
- std::make_shared<crow::Request::Adaptor>(std::move(req.socket()));
- std::shared_ptr<Subscription> subValue =
- std::make_shared<Subscription>(sseConn);
-
- // GET on this URI means, Its SSE subscriptionType.
- subValue->subscriptionType = "SSE";
-
- // Default values
- subValue->protocol = "Redfish";
- subValue->retryPolicy = "TerminateAfterRetries";
-
- boost::urls::url_view::params_type::iterator it =
- req.urlParams.find("$filter");
- if (it == req.urlParams.end())
- {
- subValue->eventFormatType = "Event";
- }
-
- else
- {
- std::string filters = it->value();
- // Reading from query params.
- bool status = readSSEQueryParams(
- filters, subValue->eventFormatType, subValue->registryMsgIds,
- subValue->registryPrefixes, subValue->metricReportDefinitions);
-
- if (!status)
- {
- messages::invalidObject(res, filters);
- return;
- }
-
- if (!subValue->eventFormatType.empty())
- {
- if (std::find(supportedEvtFormatTypes.begin(),
- supportedEvtFormatTypes.end(),
- subValue->eventFormatType) ==
- supportedEvtFormatTypes.end())
- {
- messages::propertyValueNotInList(
- res, subValue->eventFormatType, "EventFormatType");
- return;
- }
- }
- else
- {
- // If nothing specified, using default "Event"
- subValue->eventFormatType = "Event";
- }
-
- if (!subValue->registryPrefixes.empty())
- {
- for (const std::string& it : subValue->registryPrefixes)
- {
- if (std::find(supportedRegPrefixes.begin(),
- supportedRegPrefixes.end(),
- it) == supportedRegPrefixes.end())
- {
- messages::propertyValueNotInList(res, it,
- "RegistryPrefixes");
- return;
- }
- }
- }
- }
-
- std::string id =
- EventServiceManager::getInstance().addSubscription(subValue, false);
- if (id.empty())
- {
- messages::internalError(res);
- res.end();
- return;
- }
- }
-};
-
class EventDestination : public Node
{
public:
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index c96a297d3a..1cda61c182 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -27,7 +27,6 @@
#include <boost/beast/core/span.hpp>
#include <boost/container/flat_map.hpp>
#include <boost/system/linux_error.hpp>
-#include <dump_offload.hpp>
#include <error_messages.hpp>
#include <filesystem>
@@ -533,20 +532,12 @@ inline void getDumpEntryCollection(std::shared_ptr<AsyncResp>& asyncResp,
{
thisEntry["Oem"]["OpenBmc"]["DiagnosticDataType"] =
"Manager";
- thisEntry["Oem"]["OpenBmc"]["AdditionalDataURI"] =
- "/redfish/v1/Managers/bmc/LogServices/Dump/"
- "attachment/" +
- entryID;
}
else if (dumpType == "System")
{
thisEntry["Oem"]["OpenBmc"]["DiagnosticDataType"] = "OEM";
thisEntry["Oem"]["OpenBmc"]["OEMDiagnosticDataType"] =
"System";
- thisEntry["Oem"]["OpenBmc"]["AdditionalDataURI"] =
- "/redfish/v1/Systems/system/LogServices/Dump/"
- "attachment/" +
- entryID;
}
}
asyncResp->res.jsonValue["Members@odata.count"] =
@@ -2164,36 +2155,6 @@ class BMCDumpCreate : public Node
}
};
-class BMCDumpEntryDownload : public Node
-{
- public:
- BMCDumpEntryDownload(App& app) :
- Node(app, "/redfish/v1/Managers/bmc/LogServices/Dump/attachment/<str>/",
- std::string())
- {
- entityPrivileges = {
- {boost::beast::http::verb::get, {{"Login"}}},
- {boost::beast::http::verb::head, {{"Login"}}},
- {boost::beast::http::verb::patch, {{"ConfigureManager"}}},
- {boost::beast::http::verb::put, {{"ConfigureManager"}}},
- {boost::beast::http::verb::delete_, {{"ConfigureManager"}}},
- {boost::beast::http::verb::post, {{"ConfigureManager"}}}};
- }
-
- private:
- void doGet(crow::Response& res, const crow::Request& req,
- const std::vector<std::string>& params) override
- {
- if (params.size() != 1)
- {
- messages::internalError(res);
- return;
- }
- const std::string& entryID = params[0];
- crow::obmc_dump::handleDumpOffloadUrl(req, res, entryID);
- }
-};
-
class BMCDumpClear : public Node
{
public:
@@ -2366,37 +2327,6 @@ class SystemDumpCreate : public Node
}
};
-class SystemDumpEntryDownload : public Node
-{
- public:
- SystemDumpEntryDownload(App& app) :
- Node(app,
- "/redfish/v1/Systems/system/LogServices/Dump/attachment/<str>/",
- std::string())
- {
- entityPrivileges = {
- {boost::beast::http::verb::get, {{"Login"}}},
- {boost::beast::http::verb::head, {{"Login"}}},
- {boost::beast::http::verb::patch, {{"ConfigureManager"}}},
- {boost::beast::http::verb::put, {{"ConfigureManager"}}},
- {boost::beast::http::verb::delete_, {{"ConfigureManager"}}},
- {boost::beast::http::verb::post, {{"ConfigureManager"}}}};
- }
-
- private:
- void doGet(crow::Response& res, const crow::Request& req,
- const std::vector<std::string>& params) override
- {
- if (params.size() != 1)
- {
- messages::internalError(res);
- return;
- }
- const std::string& entryID = params[0];
- crow::obmc_dump::handleDumpOffloadUrl(req, res, entryID);
- }
-};
-
class SystemDumpClear : public Node
{
public:
diff --git a/redfish-core/lib/redfish_sessions.hpp b/redfish-core/lib/redfish_sessions.hpp
index 1d8e3c4fcc..fbbffcb22b 100644
--- a/redfish-core/lib/redfish_sessions.hpp
+++ b/redfish-core/lib/redfish_sessions.hpp
@@ -227,13 +227,6 @@ class SessionCollection : public Node
}
#endif
-#ifdef BMCWEB_ENABLE_SSL
- clientIp =
- req.socket().next_layer().remote_endpoint().address().to_string();
-#else
- clientIp = req.socket().remote_endpoint().address().to_string();
-#endif
-
// User is authenticated - create session
std::shared_ptr<persistent_data::UserSession> session =
persistent_data::SessionStore::getInstance().generateUserSession(