Revert "created AddReportFutureVersion dbus method"
This reverts commit 753e4b3c843dd5d1068949c4106a6389f0e0ffbc.
Reason for revert: Breaks bmcweb, same approach is needed for changed properties
Change-Id: Id868159df916fcf0bdd7fc5062f8c51187fcc7e2
diff --git a/src/interfaces/metric.hpp b/src/interfaces/metric.hpp
index afca8a6..deb3ed6 100644
--- a/src/interfaces/metric.hpp
+++ b/src/interfaces/metric.hpp
@@ -1,7 +1,7 @@
#pragma once
+#include "interfaces/types.hpp"
#include "metric_value.hpp"
-#include "types/types.hpp"
#include <nlohmann/json.hpp>
diff --git a/src/interfaces/report_factory.hpp b/src/interfaces/report_factory.hpp
index ae07b84..237ae7b 100644
--- a/src/interfaces/report_factory.hpp
+++ b/src/interfaces/report_factory.hpp
@@ -3,7 +3,7 @@
#include "interfaces/json_storage.hpp"
#include "interfaces/report.hpp"
#include "interfaces/report_manager.hpp"
-#include "types/types.hpp"
+#include "interfaces/types.hpp"
#include <boost/asio/spawn.hpp>
diff --git a/src/interfaces/types.hpp b/src/interfaces/types.hpp
new file mode 100644
index 0000000..a5ed0db
--- /dev/null
+++ b/src/interfaces/types.hpp
@@ -0,0 +1,31 @@
+#pragma once
+
+#include "operation_type.hpp"
+#include "utils/labeled_tuple.hpp"
+#include "utils/tstring.hpp"
+
+#include <sdbusplus/message/types.hpp>
+
+#include <string>
+#include <tuple>
+#include <type_traits>
+#include <vector>
+
+using ReadingParameters =
+ std::vector<std::tuple<sdbusplus::message::object_path, std::string,
+ std::string, std::string>>;
+
+using LabeledSensorParameters =
+ utils::LabeledTuple<std::tuple<std::string, std::string>,
+ utils::tstring::Service, utils::tstring::Path>;
+
+using LabeledMetricParameters =
+ utils::LabeledTuple<std::tuple<LabeledSensorParameters, OperationType,
+ std::string, std::string>,
+ utils::tstring::SensorPath,
+ utils::tstring::OperationType, utils::tstring::Id,
+ utils::tstring::MetricMetadata>;
+
+using Readings = std::tuple<
+ uint64_t,
+ std::vector<std::tuple<std::string, std::string, double, uint64_t>>>;
diff --git a/src/metric.cpp b/src/metric.cpp
index c088e8a..2a73536 100644
--- a/src/metric.cpp
+++ b/src/metric.cpp
@@ -1,13 +1,13 @@
#include "metric.hpp"
-#include "types/types.hpp"
+#include "interfaces/types.hpp"
#include "utils/transform.hpp"
#include <algorithm>
Metric::Metric(std::shared_ptr<interfaces::Sensor> sensor,
OperationType operationType, std::string id,
- std::string metadata, CollectionTimeScope, CollectionDuration) :
+ std::string metadata) :
sensor(std::move(sensor)),
operationType(std::move(operationType)), reading{std::move(id),
std::move(metadata), 0.,
@@ -52,6 +52,5 @@
auto sensorPath =
LabeledSensorParameters(sensor->id().service, sensor->id().path);
return LabeledMetricParameters(std::move(sensorPath), operationType,
- reading.id, reading.metadata, timeScope,
- collectionDuration);
+ reading.id, reading.metadata);
}
diff --git a/src/metric.hpp b/src/metric.hpp
index 549603f..aab4d15 100644
--- a/src/metric.hpp
+++ b/src/metric.hpp
@@ -11,8 +11,7 @@
{
public:
Metric(std::shared_ptr<interfaces::Sensor> sensor,
- OperationType operationType, std::string id, std::string metadata,
- CollectionTimeScope, CollectionDuration);
+ OperationType operationType, std::string id, std::string metadata);
void initialize() override;
const MetricValue& getReading() const override;
@@ -26,6 +25,4 @@
std::shared_ptr<interfaces::Sensor> sensor;
OperationType operationType;
MetricValue reading;
- CollectionTimeScope timeScope;
- CollectionDuration collectionDuration;
};
diff --git a/src/types/operation_type.hpp b/src/operation_type.hpp
similarity index 100%
rename from src/types/operation_type.hpp
rename to src/operation_type.hpp
diff --git a/src/report.hpp b/src/report.hpp
index 6fe4e9e..97afe03 100644
--- a/src/report.hpp
+++ b/src/report.hpp
@@ -4,7 +4,7 @@
#include "interfaces/metric.hpp"
#include "interfaces/report.hpp"
#include "interfaces/report_manager.hpp"
-#include "types/types.hpp"
+#include "interfaces/types.hpp"
#include <boost/asio/io_context.hpp>
#include <boost/asio/steady_timer.hpp>
diff --git a/src/report_factory.cpp b/src/report_factory.cpp
index 0e598f3..9dfdbb0 100644
--- a/src/report_factory.cpp
+++ b/src/report_factory.cpp
@@ -43,8 +43,7 @@
-> std::shared_ptr<interfaces::Metric> {
return std::make_shared<Metric>(
getSensor(param.at_index<0>()), param.at_index<1>(),
- param.at_index<2>(), param.at_index<3>(), param.at_index<4>(),
- param.at_index<5>());
+ param.at_index<2>(), param.at_index<3>());
});
return std::make_unique<Report>(
@@ -70,8 +69,7 @@
auto tree = utils::getSubTreeSensors(yield, bus);
return utils::transform(metricParams, [&tree](const auto& item) {
- const auto& [sensorPath, operationType, id, metadata,
- collectionTimeScope, collectionDuration] = item;
+ const auto& [sensorPath, operationType, id, metadata] = item;
auto it = std::find_if(
tree.begin(), tree.end(),
@@ -82,10 +80,7 @@
const auto& [service, ifaces] = it->second.front();
return LabeledMetricParameters(
LabeledSensorParameters(service, sensorPath),
- utils::stringToOperationType(operationType), id, metadata,
- utils::stringToCollectionTimeScope(collectionTimeScope),
- CollectionDuration(
- std::chrono::milliseconds(collectionDuration)));
+ utils::stringToOperationType(operationType), id, metadata);
}
throw sdbusplus::exception::SdBusError(
diff --git a/src/report_manager.cpp b/src/report_manager.cpp
index 38b9f16..9ea6026 100644
--- a/src/report_manager.cpp
+++ b/src/report_manager.cpp
@@ -1,7 +1,7 @@
#include "report_manager.hpp"
+#include "interfaces/types.hpp"
#include "report.hpp"
-#include "types/types.hpp"
#include "utils/conversion.hpp"
#include "utils/transform.hpp"
@@ -11,19 +11,6 @@
#include <stdexcept>
#include <system_error>
-ReadingParameters
- convertToReadingParameters(ReadingParametersPastVersion params)
-{
- return utils::transform(params, [](const auto& param) {
- using namespace std::chrono_literals;
-
- return ReadingParameters::value_type(
- std::get<0>(param), std::get<1>(param), std::get<2>(param),
- std::get<3>(param), utils::enumToString(CollectionTimeScope::point),
- 0u);
- });
-}
-
ReportManager::ReportManager(
std::unique_ptr<interfaces::ReportFactory> reportFactoryIn,
std::unique_ptr<interfaces::JsonStorage> reportStorageIn,
@@ -51,25 +38,7 @@
const bool emitsReadingsUpdate,
const bool logToMetricReportsCollection,
const uint64_t interval,
- ReadingParametersPastVersion metricParams) {
- return addReport(yield, reportName, reportingType,
- emitsReadingsUpdate,
- logToMetricReportsCollection,
- std::chrono::milliseconds(interval),
- convertToReadingParameters(
- std::move(metricParams)))
- .getPath();
- });
-
- dbusIface.register_method(
- "AddReportFutureVersion",
- [this](boost::asio::yield_context& yield,
- const std::string& reportName,
- const std::string& reportingType,
- const bool emitsReadingsUpdate,
- const bool logToMetricReportsCollection,
- const uint64_t interval,
- ReadingParameters metricParams) {
+ ReadingParameters metricParams) {
return addReport(yield, reportName, reportingType,
emitsReadingsUpdate,
logToMetricReportsCollection,
@@ -175,8 +144,7 @@
sdbusplus::message::object_path(
param.at_index<0>().at_label<Path>()),
utils::enumToString(param.at_index<1>()), param.at_index<2>(),
- param.at_index<3>(), utils::enumToString(param.at_index<4>()),
- param.at_index<5>().t.count());
+ param.at_index<3>());
});
verifyAddReport(reportName, reportingType, interval, metricParams);
diff --git a/src/trigger.cpp b/src/trigger.cpp
index d6e51bc..471ad10 100644
--- a/src/trigger.cpp
+++ b/src/trigger.cpp
@@ -1,6 +1,6 @@
#include "trigger.hpp"
-#include "types/types.hpp"
+#include "interfaces/types.hpp"
Trigger::Trigger(
boost::asio::io_context& ioc,
diff --git a/src/types/collection_duration.hpp b/src/types/collection_duration.hpp
deleted file mode 100644
index dc70d4f..0000000
--- a/src/types/collection_duration.hpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-
-#include <boost/serialization/strong_typedef.hpp>
-#include <nlohmann/json.hpp>
-
-#include <chrono>
-
-BOOST_STRONG_TYPEDEF(std::chrono::milliseconds, CollectionDuration)
-
-inline void to_json(nlohmann::json& json, const CollectionDuration& value)
-{
- json = value.t.count();
-}
-
-inline void from_json(const nlohmann::json& json, CollectionDuration& value)
-{
- value = CollectionDuration(std::chrono::milliseconds(json.get<uint64_t>()));
-}
diff --git a/src/types/collection_time_scope.hpp b/src/types/collection_time_scope.hpp
deleted file mode 100644
index d2694d2..0000000
--- a/src/types/collection_time_scope.hpp
+++ /dev/null
@@ -1,46 +0,0 @@
-#pragma once
-
-#include "utils/conversion.hpp"
-
-#include <array>
-#include <cstdint>
-#include <string_view>
-#include <type_traits>
-
-enum class CollectionTimeScope : uint32_t
-{
- point,
- interval,
- startup
-};
-
-namespace utils
-{
-
-constexpr std::array<std::pair<std::string_view, CollectionTimeScope>, 3>
- convDataCollectionTimeScope = {
- {std::make_pair<std::string_view, CollectionTimeScope>(
- "Point", CollectionTimeScope::point),
- std::make_pair<std::string_view, CollectionTimeScope>(
- "Interval", CollectionTimeScope::interval),
- std::make_pair<std::string_view, CollectionTimeScope>(
- "StartupInterval", CollectionTimeScope::startup)}};
-
-inline CollectionTimeScope
- toCollectionTimeScope(std::underlying_type_t<CollectionTimeScope> value)
-{
- return toEnum<CollectionTimeScope, CollectionTimeScope::point,
- CollectionTimeScope::startup>(value);
-}
-
-inline CollectionTimeScope stringToCollectionTimeScope(const std::string& value)
-{
- return stringToEnum(convDataCollectionTimeScope, value);
-}
-
-inline std::string enumToString(CollectionTimeScope value)
-{
- return std::string(enumToString(convDataCollectionTimeScope, value));
-}
-
-} // namespace utils
\ No newline at end of file
diff --git a/src/types/types.hpp b/src/types/types.hpp
deleted file mode 100644
index 93f3b27..0000000
--- a/src/types/types.hpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#pragma once
-
-#include "types/collection_duration.hpp"
-#include "types/collection_time_scope.hpp"
-#include "types/operation_type.hpp"
-#include "utils/labeled_tuple.hpp"
-#include "utils/tstring.hpp"
-
-#include <sdbusplus/message/types.hpp>
-
-#include <chrono>
-#include <string>
-#include <tuple>
-#include <type_traits>
-#include <vector>
-
-using ReadingParametersPastVersion =
- std::vector<std::tuple<sdbusplus::message::object_path, std::string,
- std::string, std::string>>;
-
-using ReadingParameters =
- std::vector<std::tuple<sdbusplus::message::object_path, std::string,
- std::string, std::string, std::string, uint64_t>>;
-
-using LabeledSensorParameters =
- utils::LabeledTuple<std::tuple<std::string, std::string>,
- utils::tstring::Service, utils::tstring::Path>;
-
-using LabeledMetricParameters = utils::LabeledTuple<
- std::tuple<LabeledSensorParameters, OperationType, std::string, std::string,
- CollectionTimeScope, CollectionDuration>,
- utils::tstring::SensorPath, utils::tstring::OperationType,
- utils::tstring::Id, utils::tstring::MetricMetadata,
- utils::tstring::CollectionTimeScope, utils::tstring::CollectionDuration>;
-
-using Readings = std::tuple<
- uint64_t,
- std::vector<std::tuple<std::string, std::string, double, uint64_t>>>;
diff --git a/src/utils/labeled_tuple.hpp b/src/utils/labeled_tuple.hpp
index a224141..795f37f 100644
--- a/src/utils/labeled_tuple.hpp
+++ b/src/utils/labeled_tuple.hpp
@@ -170,15 +170,15 @@
};
template <class... Args, class... Labels>
-inline void to_json(nlohmann::json& json,
- const LabeledTuple<std::tuple<Args...>, Labels...>& tuple)
+void to_json(nlohmann::json& json,
+ const LabeledTuple<std::tuple<Args...>, Labels...>& tuple)
{
json = tuple.to_json();
}
template <class... Args, class... Labels>
-inline void from_json(const nlohmann::json& json,
- LabeledTuple<std::tuple<Args...>, Labels...>& tuple)
+void from_json(const nlohmann::json& json,
+ LabeledTuple<std::tuple<Args...>, Labels...>& tuple)
{
tuple.from_json(json);
}
diff --git a/src/utils/tstring.hpp b/src/utils/tstring.hpp
index 3e85ba5..a8d3e90 100644
--- a/src/utils/tstring.hpp
+++ b/src/utils/tstring.hpp
@@ -56,21 +56,5 @@
}
};
-struct CollectionTimeScope
-{
- static std::string str()
- {
- return "collectionTimeScope";
- }
-};
-
-struct CollectionDuration
-{
- static std::string str()
- {
- return "collectionDuration";
- }
-};
-
} // namespace tstring
} // namespace utils
diff --git a/tests/src/helpers/interfaces/labeled_reading_parameter_helpers.hpp b/tests/src/helpers/interfaces/labeled_reading_parameter_helpers.hpp
index d0b1fff..9a46d0c 100644
--- a/tests/src/helpers/interfaces/labeled_reading_parameter_helpers.hpp
+++ b/tests/src/helpers/interfaces/labeled_reading_parameter_helpers.hpp
@@ -1,7 +1,7 @@
#pragma once
#include "helpers/interfaces/labeled_sensor_parameter_helpers.hpp"
-#include "types/types.hpp"
+#include "interfaces/types.hpp"
#include <ostream>
diff --git a/tests/src/helpers/interfaces/labeled_sensor_parameter_helpers.hpp b/tests/src/helpers/interfaces/labeled_sensor_parameter_helpers.hpp
index 395f8d1..ef2eb6b 100644
--- a/tests/src/helpers/interfaces/labeled_sensor_parameter_helpers.hpp
+++ b/tests/src/helpers/interfaces/labeled_sensor_parameter_helpers.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include "types/types.hpp"
+#include "interfaces/types.hpp"
#include <ostream>
diff --git a/tests/src/params/report_params.hpp b/tests/src/params/report_params.hpp
index bf78add..25422bc 100644
--- a/tests/src/params/report_params.hpp
+++ b/tests/src/params/report_params.hpp
@@ -1,7 +1,7 @@
#pragma once
+#include "interfaces/types.hpp"
#include "report_manager.hpp"
-#include "types/types.hpp"
#include <chrono>
#include <string>
@@ -86,14 +86,10 @@
"/xyz/openbmc_project/sensors/power/p1")},
utils::enumToString(OperationType::single),
"MetricId1",
- "Metadata1",
- utils::enumToString(CollectionTimeScope::point),
- 0u},
+ "Metadata1"},
{{sdbusplus::message::object_path(
"/xyz/openbmc_project/sensors/power/p2")},
utils::enumToString(OperationType::single),
"MetricId2",
- "Metadata2",
- utils::enumToString(CollectionTimeScope::point),
- 0u}};
+ "Metadata2"}};
};
diff --git a/tests/src/test_metric.cpp b/tests/src/test_metric.cpp
index 786f025..e91750d 100644
--- a/tests/src/test_metric.cpp
+++ b/tests/src/test_metric.cpp
@@ -8,8 +8,6 @@
#include <gmock/gmock.h>
using namespace testing;
-using namespace std::chrono_literals;
-
namespace tstring = utils::tstring;
using Timestamp = uint64_t;
@@ -21,8 +19,7 @@
std::make_shared<NiceMock<SensorMock>>();
std::shared_ptr<Metric> sut = std::make_shared<Metric>(
- sensorMock, OperationType::avg, "id", "metadata",
- CollectionTimeScope::point, CollectionDuration(0ms));
+ sensorMock, OperationType::avg, "id", "metadata");
};
TEST_F(TestMetric, subscribesForSensorDuringInitialization)
diff --git a/tests/src/test_report.cpp b/tests/src/test_report.cpp
index ece4be8..80c0a9c 100644
--- a/tests/src/test_report.cpp
+++ b/tests/src/test_report.cpp
@@ -53,8 +53,7 @@
LabeledSensorParameters("service"s + id, "path"s + id);
auto metricParameters = LabeledMetricParameters(
std::move(sensorParameters), utils::toOperationType(i),
- "id"s + id, "metadata"s + id, CollectionTimeScope::point,
- CollectionDuration(0ms));
+ "id"s + id, "metadata"s + id);
ON_CALL(*metricMocks[i], dumpConfiguration())
.WillByDefault(Return(std::move(metricParameters)));
@@ -127,7 +126,7 @@
const T& newValue)
{
auto setPromise = std::promise<boost::system::error_code>();
- auto future = setPromise.get_future();
+ auto setFuture = setPromise.get_future();
sdbusplus::asio::setProperty(
*DbusEnvironment::getBus(), DbusEnvironment::serviceName(), path,
Report::reportIfaceName, property, std::move(newValue),
@@ -135,7 +134,7 @@
std::move(setPromise)](boost::system::error_code ec) mutable {
setPromise.set_value(ec);
});
- return DbusEnvironment::waitForFuture(std::move(future));
+ return DbusEnvironment::waitForFuture(std::move(setFuture));
}
boost::system::error_code deleteReport(const std::string& path)
@@ -263,32 +262,20 @@
"ReadingParameters",
nlohmann::json(
{{{tstring::SensorPath::str(),
- {{tstring::Service::str(), "service0"},
- {tstring::Path::str(), "path0"}}},
+ {{"service", "service0"}, {"path", "path0"}}},
{tstring::OperationType::str(), OperationType::single},
{tstring::Id::str(), "id0"},
- {tstring::MetricMetadata::str(), "metadata0"},
- {tstring::CollectionTimeScope::str(),
- CollectionTimeScope::point},
- {tstring::CollectionDuration::str(), 0}},
+ {tstring::MetricMetadata::str(), "metadata0"}},
{{tstring::SensorPath::str(),
- {{tstring::Service::str(), "service1"},
- {tstring::Path::str(), "path1"}}},
+ {{"service", "service1"}, {"path", "path1"}}},
{tstring::OperationType::str(), OperationType::max},
{tstring::Id::str(), "id1"},
- {tstring::MetricMetadata::str(), "metadata1"},
- {tstring::CollectionTimeScope::str(),
- CollectionTimeScope::point},
- {tstring::CollectionDuration::str(), 0}},
+ {tstring::MetricMetadata::str(), "metadata1"}},
{{tstring::SensorPath::str(),
- {{tstring::Service::str(), "service2"},
- {tstring::Path::str(), "path2"}}},
+ {{"service", "service2"}, {"path", "path2"}}},
{tstring::OperationType::str(), OperationType::min},
{tstring::Id::str(), "id2"},
- {tstring::MetricMetadata::str(), "metadata2"},
- {tstring::CollectionTimeScope::str(),
- CollectionTimeScope::point},
- {tstring::CollectionDuration::str(), 0}}}))));
+ {tstring::MetricMetadata::str(), "metadata2"}}}))));
TEST_P(TestReportStore, settingPersistencyToTrueStoresReport)
{
diff --git a/tests/src/test_report_manager.cpp b/tests/src/test_report_manager.cpp
index d9ea4af..519606f 100644
--- a/tests/src/test_report_manager.cpp
+++ b/tests/src/test_report_manager.cpp
@@ -57,7 +57,7 @@
addReportPromise.set_value({ec, path});
},
DbusEnvironment::serviceName(), ReportManager::reportManagerPath,
- ReportManager::reportManagerIfaceName, "AddReportFutureVersion",
+ ReportManager::reportManagerIfaceName, "AddReport",
params.reportName(), params.reportingType(),
params.emitReadingUpdate(), params.logToMetricReportCollection(),
static_cast<uint64_t>(params.interval().count()),
@@ -74,10 +74,10 @@
*DbusEnvironment::getBus(), DbusEnvironment::serviceName(),
ReportManager::reportManagerPath,
ReportManager::reportManagerIfaceName, property,
- [&propertyPromise](const boost::system::error_code& ec, T t) {
+ [&propertyPromise](boost::system::error_code ec, T t) {
if (ec)
{
- utils::setException(propertyPromise, "Get property failed");
+ utils::setException(propertyPromise, "GetProperty failed");
return;
}
propertyPromise.set_value(t);
@@ -274,9 +274,7 @@
"/xyz/openbmc_project/sensors/power/p1")},
utils::enumToString(operationType),
"MetricId1",
- "Metadata1",
- utils::enumToString(CollectionTimeScope::point),
- 0u}});
+ "Metadata1"}});
reportFactoryMock.expectMake(_, reportParams, Ref(*sut), Ref(storageMock))
.WillOnce(Return(ByMove(std::move(reportMockPtr))));
@@ -314,10 +312,7 @@
return LabeledMetricParameters(
LabeledSensorParameters("service", std::get<0>(item)),
utils::stringToOperationType(std::get<1>(item)),
- std::get<2>(item), std::get<3>(item),
- utils::stringToCollectionTimeScope(std::get<4>(item)),
- CollectionDuration(
- std::chrono::milliseconds(std::get<5>(item))));
+ std::get<2>(item), std::get<3>(item));
});
}