Add Id to Trigger
Currently, Trigger is using Name as unique identifier. By adding Id, we
can be compliant with redfish specification:
- Id will be used as unique identifier
- Name will be used as human readable, non-unique name
AddTrigger dbus method is now requiring both id and name. Each of them
can be passed as empty string and the service will fill them with
correct values. If only id is an empty string, name will be used to
generate its value.
Dbus object path and persistent storage filename are now be based on id,
instead of name.
Added validation for AddTrigger:
- correct characters in id
- max id length
Added Name property for Trigger object, which can be modified from dbus.
Testing done:
- Unit test added and passing
- Trigger was added using dbus, without errors
- Id generation is working properly
- Name property is accessible and writable from dbus
Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
Change-Id: Ibb553586eaf51943044c93a35bc0725e6ef67ce9
diff --git a/tests/src/dbus_environment.hpp b/tests/src/dbus_environment.hpp
index 0ddf241..087daef 100644
--- a/tests/src/dbus_environment.hpp
+++ b/tests/src/dbus_environment.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "types/duration_type.hpp"
+#include "utils/set_exception.hpp"
#include <sdbusplus/asio/object_server.hpp>
#include <sdbusplus/asio/property.hpp>
@@ -92,6 +93,44 @@
static bool waitForFutures(std::string_view name,
Milliseconds timeout = std::chrono::seconds(10));
+ template <class T>
+ static T getProperty(const std::string& path,
+ const std::string& interfaceName,
+ const std::string& property)
+ {
+ auto propertyPromise = std::promise<T>();
+ auto propertyFuture = propertyPromise.get_future();
+ sdbusplus::asio::getProperty<T>(
+ *DbusEnvironment::getBus(), DbusEnvironment::serviceName(), path,
+ interfaceName, property,
+ [&propertyPromise](const boost::system::error_code& ec, T t) {
+ if (ec)
+ {
+ utils::setException(propertyPromise, "GetProperty failed");
+ return;
+ }
+ propertyPromise.set_value(t);
+ });
+ return DbusEnvironment::waitForFuture(std::move(propertyFuture));
+ }
+
+ template <class T>
+ static boost::system::error_code
+ setProperty(const std::string& path, const std::string& interfaceName,
+ const std::string& property, const T& newValue)
+ {
+ auto setPromise = std::promise<boost::system::error_code>();
+ auto future = setPromise.get_future();
+ sdbusplus::asio::setProperty(
+ *DbusEnvironment::getBus(), DbusEnvironment::serviceName(), path,
+ interfaceName, property, std::move(newValue),
+ [setPromise =
+ std::move(setPromise)](boost::system::error_code ec) mutable {
+ setPromise.set_value(ec);
+ });
+ return DbusEnvironment::waitForFuture(std::move(future));
+ }
+
private:
static std::future<bool> getFuture(std::string_view name);