Implement OriginatedBy interface in dump entry dbus obj
This new interface "OriginatedBy" will be implemented
by all the dump entry dbus objects. It contains a property
"OriginatorId" which stores the unique id of the user that
has initiated the dump. The unique id in this case is a string
that contains the ip address of the client that initiated
the dump.
The dbus interface change for the same is at:
[1] https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-dbus-interfaces/+/47057
Tested By:
[1] busctl call xyz.openbmc_project.Dump.Manager /xyz/openbmc_project/dump/bmc xyz.openbmc_project.Dump.Create CreateDump a{sv} 2 "xyz.openbmc_project.Dump.Create.CreateParameters.OriginatorId" s "<unique-id>" "xyz.openbmc_project.Dump.Create.CreateParameters.OriginatorType" s "xyz.openbmc_project.Common.OriginatedBy.OriginatorTypes.Client" o "/xyz/openbmc_project/dump/bmc/entry/2"
[2] busctl --verbose call xyz.openbmc_project.Dump.Manager /xyz/openbmc_project/dump/resource xyz.openbmc_project.Dump.Create CreateDump a{sv} 4 "com.ibm.Dump.Create.CreateParameters.VSPString" s "vsp" "com.ibm.Dump.Create.CreateParameters.Password" s "password" "com.ibm.Dump.Create.CreateParameters.OriginatorId" s "<unique-id>" "xyz.openbmc_project.Dump.Create.CreateParameters.OriginatorType" s "xyz.openbmc_project.Common.OriginatedBy.OriginatorTypes.Client"
MESSAGE "o" {
OBJECT_PATH "/xyz/openbmc_project/dump/resource/entry/1";
};
[3] busctl call xyz.openbmc_project.Dump.Manager /xyz/openbmc_project/dump/system xyz.openbmc_project.Dump.Create CreateDump a{sv} 2 "com.ibm.Dump.Create.CreateParameters.OriginatorId" s "<unique-id>" "xyz.openbmc_project.Dump.Create.CreateParameters.OriginatorType" s "xyz.openbmc_project.Common.OriginatedBy.OriginatorTypes.Client" o "/xyz/openbmc_project/dump/system/entry/1"
Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com>
Change-Id: I23c9f769fd39cd84e042d6effbb3d71c7af4e889
diff --git a/dump-extensions/openpower-dumps/dump_manager_resource.cpp b/dump-extensions/openpower-dumps/dump_manager_resource.cpp
index a151961..604e796 100644
--- a/dump-extensions/openpower-dumps/dump_manager_resource.cpp
+++ b/dump-extensions/openpower-dumps/dump_manager_resource.cpp
@@ -80,6 +80,9 @@
auto idString = std::to_string(id);
auto objPath = std::filesystem::path(baseEntryPath) / idString;
+ // TODO: Get the originator Id, type from the persisted file.
+ // For now replacing it with null
+
try
{
log<level::INFO>(fmt::format("Resouce Dump Notify: creating new dump "
@@ -90,7 +93,8 @@
id, std::make_unique<resource::Entry>(
bus, objPath.c_str(), id, timeStamp, size, dumpId,
std::string(), std::string(),
- phosphor::dump::OperationStatus::Completed, *this)));
+ phosphor::dump::OperationStatus::Completed, std::string(),
+ originatorTypes::Internal, *this)));
}
catch (const std::invalid_argument& e)
{
@@ -192,13 +196,20 @@
}
}
+ // Get the originator id and type from params
+ std::string originatorId;
+ originatorTypes originatorType;
+
+ phosphor::dump::extractOriginatorProperties(params, originatorId,
+ originatorType);
+
try
{
entries.insert(std::make_pair(
id, std::make_unique<resource::Entry>(
bus, objPath.c_str(), id, timeStamp, 0, INVALID_SOURCE_ID,
vspString, pwd, phosphor::dump::OperationStatus::InProgress,
- *this)));
+ originatorId, originatorType, *this)));
}
catch (const std::invalid_argument& e)
{
diff --git a/dump-extensions/openpower-dumps/dump_manager_system.cpp b/dump-extensions/openpower-dumps/dump_manager_system.cpp
index 7310dec..4aa3049 100644
--- a/dump-extensions/openpower-dumps/dump_manager_system.cpp
+++ b/dump-extensions/openpower-dumps/dump_manager_system.cpp
@@ -53,12 +53,15 @@
auto idString = std::to_string(id);
auto objPath = std::filesystem::path(baseEntryPath) / idString;
+ // TODO: Get the originator Id, Type from the persisted file.
+ // For now replacing it with null
try
{
entries.insert(std::make_pair(
id, std::make_unique<system::Entry>(
bus, objPath.c_str(), id, timeStamp, size, dumpId,
- phosphor::dump::OperationStatus::Completed, *this)));
+ phosphor::dump::OperationStatus::Completed, std::string(),
+ originatorTypes::Internal, *this)));
}
catch (const std::invalid_argument& e)
{
@@ -83,9 +86,10 @@
constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
constexpr auto DIAG_MOD_TARGET = "obmc-host-crash@0.target";
- if (!params.empty())
+ if (params.size() > CREATE_DUMP_MAX_PARAMS)
{
- log<level::WARNING>("System dump accepts no additional parameters");
+ log<level::WARNING>(
+ "System dump accepts not more than 2 additional parameters");
}
using NotAllowed =
@@ -100,6 +104,13 @@
return std::string();
}
+ // Get the originator id and type from params
+ std::string originatorId;
+ originatorTypes originatorType;
+
+ phosphor::dump::extractOriginatorProperties(params, originatorId,
+ originatorType);
+
auto b = sdbusplus::bus::new_default();
auto method = bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
SYSTEMD_INTERFACE, "StartUnit");
@@ -120,7 +131,8 @@
entries.insert(std::make_pair(
id, std::make_unique<system::Entry>(
bus, objPath.c_str(), id, timeStamp, 0, INVALID_SOURCE_ID,
- phosphor::dump::OperationStatus::InProgress, *this)));
+ phosphor::dump::OperationStatus::InProgress, originatorId,
+ originatorType, *this)));
}
catch (const std::invalid_argument& e)
{
diff --git a/dump-extensions/openpower-dumps/resource_dump_entry.hpp b/dump-extensions/openpower-dumps/resource_dump_entry.hpp
index 065438c..9515dc2 100644
--- a/dump-extensions/openpower-dumps/resource_dump_entry.hpp
+++ b/dump-extensions/openpower-dumps/resource_dump_entry.hpp
@@ -2,6 +2,7 @@
#include "com/ibm/Dump/Entry/Resource/server.hpp"
#include "dump_entry.hpp"
+#include "xyz/openbmc_project/Common/OriginatedBy/server.hpp"
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
@@ -18,8 +19,12 @@
using ServerObject = typename sdbusplus::server::object_t<T>;
using EntryIfaces = sdbusplus::server::object_t<
+ sdbusplus::xyz::openbmc_project::Common::server::OriginatedBy,
sdbusplus::com::ibm::Dump::Entry::server::Resource>;
+using originatorTypes = sdbusplus::xyz::openbmc_project::Common::server::
+ OriginatedBy::OriginatorTypes;
+
class Manager;
/** @class Entry
@@ -49,16 +54,18 @@
* @param[in] vspStr- Input to host to generate the resource dump.
* @param[in] pwd - Password needed by host to validate the request.
* @param[in] status - status of the dump.
+ * @param[in] originatorId - Id of the originator of the dump
+ * @param[in] originatorType - Originator type
* @param[in] parent - The dump entry's parent.
*/
Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId,
uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId,
std::string vspStr, std::string pwd,
- phosphor::dump::OperationStatus status,
- phosphor::dump::Manager& parent) :
+ phosphor::dump::OperationStatus status, std::string originatorId,
+ originatorTypes originatorType, phosphor::dump::Manager& parent) :
EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit),
phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize,
- status, parent)
+ status, originatorId, originatorType, parent)
{
sourceDumpId(sourceId);
vspString(vspStr);
diff --git a/dump-extensions/openpower-dumps/system_dump_entry.hpp b/dump-extensions/openpower-dumps/system_dump_entry.hpp
index bc247c9..ef3453e 100644
--- a/dump-extensions/openpower-dumps/system_dump_entry.hpp
+++ b/dump-extensions/openpower-dumps/system_dump_entry.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "dump_entry.hpp"
+#include "xyz/openbmc_project/Common/OriginatedBy/server.hpp"
#include "xyz/openbmc_project/Dump/Entry/System/server.hpp"
#include <sdbusplus/bus.hpp>
@@ -16,8 +17,12 @@
using ServerObject = typename sdbusplus::server::object_t<T>;
using EntryIfaces = sdbusplus::server::object_t<
+ sdbusplus::xyz::openbmc_project::Common::server::OriginatedBy,
sdbusplus::xyz::openbmc_project::Dump::Entry::server::System>;
+using originatorTypes = sdbusplus::xyz::openbmc_project::Common::server::
+ OriginatedBy::OriginatorTypes;
+
class Manager;
/** @class Entry
@@ -44,15 +49,17 @@
* @param[in] dumpSize - Dump size in bytes.
* @param[in] sourceId - DumpId provided by the source.
* @param[in] status - status of the dump.
+ * @param[in] originatorId - Id of the originator of the dump
+ * @param[in] originatorType - Originator type
* @param[in] parent - The dump entry's parent.
*/
Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId,
uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId,
- phosphor::dump::OperationStatus status,
- phosphor::dump::Manager& parent) :
+ phosphor::dump::OperationStatus status, std::string originatorId,
+ originatorTypes originatorType, phosphor::dump::Manager& parent) :
EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit),
phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize,
- status, parent)
+ status, originatorId, originatorType, parent)
{
sourceDumpId(sourceId);
// Emit deferred signal.