summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor')
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0001-Improve-initialization-of-I2C-sensors.patch24
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0002-Entity-manager-Add-support-to-update-assetTag.patch351
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager_%.bbappend6
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/dbus/phosphor-dbus-interfaces/0034-Fix-crash-issue-due-to-throw-undefined-error.patch38
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/dbus/phosphor-dbus-interfaces_%.bbappend3
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0005-Modified-firmware-activation-to-launch-fwupd.sh-thro.patch33
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/fru/default-fru.bb2
-rwxr-xr-xmeta-openbmc-mods/meta-common/recipes-phosphor/fru/default-fru/checkFru.sh56
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/fru/default-fru/decodeBoardID.sh6
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0001-Add-ConnectedVia-property-to-virtual-media-item-temp.patch25
-rwxr-xr-xmeta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0001-Firmware-update-configuration-changes.patch10
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0002-Change-InsertMedia-action-response-for-POST-in-proxy.patch30
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0003-Set-Inserted-redfish-property-for-not-inserted-resou.patch40
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0036-Fix-wrong-check-in-EventService-events.patch35
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0037-Add-state-sensor-messages-to-the-registry.patch98
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Redfish-TelemetryService-schema-implementation.patch717
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Add-POST-and-DELETE-in-MetricReportDefinitions.patch769
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Add-support-for-MetricDefinition-scheme.patch457
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Sync-Telmetry-service-with-EventService.patch159
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/README9
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend14
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-node-manager-proxy_git.bb2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/peci/peci-pcie_%.bbappend2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/pmci/libmctp-intel_git.bb2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/pmci/libpldm-intel_git.bb2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctp-emulator.bb2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctp-wrapper.bb2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctpd.bb2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctpwplus.bb2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/pmci/pldmd.bb2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/pmci/pmci-launcher.bb2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/sel-logger/phosphor-sel-logger_%.bbappend2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0002-Fix-PECI-client-creation-flow.patch24
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0003-Fix-missing-threshold-de-assert-event-when-threshold.patch139
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0004-Fan-Tach-Sensor-Threshold-Ignore-Zero.patch58
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0005-Fix-PECI-ioctl-number.patch29
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors_%.bbappend9
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/settings/settings_git.bb2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/special-mode-mgr/special-mode-mgr_git.bb2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/telemetry/telemetry_%.bbappend2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/users/phosphor-user-manager/0005-Added-suport-for-multiple-user-manager-services.patch447
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/users/phosphor-user-manager/0006-Use-groupmems-instead-of-getgrnam_r-due-to-overlay.patch18
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/users/phosphor-user-manager_%.bbappend2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/phosphor-watchdog_%.bbappend1
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/webui/webui-vue_%.bbappend2
45 files changed, 1727 insertions, 1912 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0001-Improve-initialization-of-I2C-sensors.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0001-Improve-initialization-of-I2C-sensors.patch
index c518d943f..fdd2ba6e3 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0001-Improve-initialization-of-I2C-sensors.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0001-Improve-initialization-of-I2C-sensors.patch
@@ -1,4 +1,4 @@
-From 2048226878a80fefcbcbe999fd826cc7c02ed9e4 Mon Sep 17 00:00:00 2001
+From 85e7b2d9ede4bb33e02f48ea1d4691d2154fc4a5 Mon Sep 17 00:00:00 2001
From: Johnathan Mantey <johnathanx.mantey@intel.com>
Date: Tue, 13 Oct 2020 15:00:51 -0700
Subject: [PATCH] Improve initialization of I2C sensors
@@ -32,15 +32,15 @@ missing after AC cycles.
Change-Id: I118df674162677d66e7d211b089430fce384086b
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
---
- include/devices.hpp | 153 +++++++++++++++++++----------------
+ include/devices.hpp | 165 ++++++++++++++++++++-----------------
src/Overlay.cpp | 192 ++++++++++++++++++++++++++++++++++----------
- 2 files changed, 233 insertions(+), 112 deletions(-)
+ 2 files changed, 239 insertions(+), 118 deletions(-)
diff --git a/include/devices.hpp b/include/devices.hpp
-index acbfb95..1f25864 100644
+index c375b1c..b7dc7d0 100644
--- a/include/devices.hpp
+++ b/include/devices.hpp
-@@ -31,99 +31,116 @@ struct CmpStr
+@@ -31,105 +31,122 @@ struct CmpStr
struct ExportTemplate
{
@@ -65,12 +65,18 @@ index acbfb95..1f25864 100644
- "/sys/bus/i2c/devices/i2c-$Bus/new_device")},
- {"24C64", ExportTemplate("24c64 $Address",
- "/sys/bus/i2c/devices/i2c-$Bus/new_device")},
+- {"ADM1266",
+- ExportTemplate("adm1266 $Address",
+- "/sys/bus/i2c/devices/i2c-$Bus/new_device")},
+ {{"24C02",
+ ExportTemplate("24c02 $Address", "/sys/bus/i2c/devices/i2c-$Bus",
+ "new_device", "delete_device", false)},
+ {"24C64",
+ ExportTemplate("24c64 $Address", "/sys/bus/i2c/devices/i2c-$Bus",
+ "new_device", "delete_device", false)},
++ {"ADM1266", ExportTemplate("adm1266 $Address",
++ "/sys/bus/i2c/devices/i2c-$Bus/new_device",
++ "new_device", "delete_device", false)},
{"ADM1272",
- ExportTemplate("adm1272 $Address",
- "/sys/bus/i2c/devices/i2c-$Bus/new_device")},
@@ -152,8 +158,14 @@ index acbfb95..1f25864 100644
{"MAX31730",
- ExportTemplate("max31730 $Address",
- "/sys/bus/i2c/devices/i2c-$Bus/new_device")},
+- {"MAX34440",
+- ExportTemplate("max34440 $Address",
+- "/sys/bus/i2c/devices/i2c-$Bus/new_device")},
+ ExportTemplate("max31730 $Address", "/sys/bus/i2c/devices/i2c-$Bus",
+ "new_device", "delete_device", true)},
++ {"MAX34440", ExportTemplate("max34440 $Address",
++ "/sys/bus/i2c/devices/i2c-$Bus/new_device",
++ "new_device", "delete_device", true)},
{"MAX34451",
- ExportTemplate("max34451 $Address",
- "/sys/bus/i2c/devices/i2c-$Bus/new_device")},
@@ -471,5 +483,5 @@ index cb6ed10..7a3089e 100644
linkMux(name, static_cast<size_t>(*bus), static_cast<size_t>(*address),
*channels);
--
-2.26.2
+2.17.1
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0002-Entity-manager-Add-support-to-update-assetTag.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0002-Entity-manager-Add-support-to-update-assetTag.patch
new file mode 100644
index 000000000..88e86f68c
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0002-Entity-manager-Add-support-to-update-assetTag.patch
@@ -0,0 +1,351 @@
+From 1e8b3e0fe4ce9aa87a35f6c3ba6e506873d5455c Mon Sep 17 00:00:00 2001
+From: mansijos <mansi.joshi@intel.com>
+Date: Fri, 12 Feb 2021 11:26:57 +0530
+Subject: [PATCH] Entity-manager: Add support to update assetTag
+
+Asset tag is an updateable property from User level interface like
+Redfish. User-level interface will update Asset tag in entity-manager,
+which will further update the needed FRU interface property exposed.
+
+Tested:
+Successfully updated in assetTag interface as well as in fru interface
+while using set-property and using redfish as well.
+The new value is preserved after BMC resets.
+
+Change-Id: Iab8b24344d1a27486ceafe21aa2b4496706a2944
+Signed-off-by: mansijos <mansi.joshi@intel.com>
+---
+ include/EntityManager.hpp | 15 ++--
+ src/EntityManager.cpp | 148 ++++++++++++++++++++++++++++++++------
+ 2 files changed, 135 insertions(+), 28 deletions(-)
+
+diff --git a/include/EntityManager.hpp b/include/EntityManager.hpp
+index 5867556..a4e9922 100644
+--- a/include/EntityManager.hpp
++++ b/include/EntityManager.hpp
+@@ -29,13 +29,16 @@
+ #include <list>
+ #include <string>
+
+-using DBusProbeObjectT = boost::container::flat_map<
+- std::string,
+- std::vector<boost::container::flat_map<std::string, BasicVariantType>>>;
+-
+ using FoundDeviceT =
+ std::vector<boost::container::flat_map<std::string, BasicVariantType>>;
+
++using FoundDeviceInfoT = std::vector<
++ std::tuple<boost::container::flat_map<std::string, BasicVariantType>,
++ std::string, std::string, std::string>>;
++
++using DBusProbeObjectT =
++ boost::container::flat_map<std::string, FoundDeviceInfoT>;
++
+ struct PerformScan : std::enable_shared_from_this<PerformScan>
+ {
+
+@@ -62,12 +65,12 @@ struct PerformProbe : std::enable_shared_from_this<PerformProbe>
+ {
+ PerformProbe(const std::vector<std::string>& probeCommand,
+ std::shared_ptr<PerformScan>& scanPtr,
+- std::function<void(FoundDeviceT&)>&& callback);
++ std::function<void(FoundDeviceInfoT&)>&& callback);
+ virtual ~PerformProbe();
+
+ std::vector<std::string> _probeCommand;
+ std::shared_ptr<PerformScan> scan;
+- std::function<void(FoundDeviceT&)> _callback;
++ std::function<void(FoundDeviceInfoT&)> _callback;
+ };
+
+ inline void logDeviceAdded(const nlohmann::json& record)
+diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
+index aa1df20..cd73675 100644
+--- a/src/EntityManager.cpp
++++ b/src/EntityManager.cpp
+@@ -47,9 +47,14 @@ constexpr const char* lastConfiguration = "/tmp/configuration/last.json";
+ constexpr const char* currentConfiguration = "/var/configuration/system.json";
+ constexpr const char* globalSchema = "global.json";
+ constexpr const int32_t MAX_MAPPER_DEPTH = 0;
++constexpr const char* foundObject = "FoundProbe";
+
+ constexpr const bool DEBUG = false;
+
++using foundProbeData = std::map<std::string, std::string>;
++static foundProbeData foundData;
++static std::map<std::string, foundProbeData> mapFoundData;
++
+ struct cmp_str
+ {
+ bool operator()(const char* a, const char* b) const
+@@ -169,7 +174,10 @@ void getInterfaces(
+ return;
+ }
+
+- scan->dbusProbeObjects[std::get<2>(call)].emplace_back(resp);
++ // Save the dbus info along with device info
++ scan->dbusProbeObjects[std::get<2>(call)].emplace_back(
++ std::make_tuple(resp, std::get<0>(call), std::get<1>(call),
++ std::get<2>(call)));
+ },
+ std::get<0>(call), std::get<1>(call), "org.freedesktop.DBus.Properties",
+ "GetAll", std::get<2>(call));
+@@ -274,11 +282,10 @@ void findDbusObjects(std::vector<std::shared_ptr<PerformProbe>>&& probeVector,
+ // probes dbus interface dictionary for a key with a value that matches a regex
+ bool probeDbus(const std::string& interface,
+ const std::map<std::string, nlohmann::json>& matches,
+- FoundDeviceT& devices, std::shared_ptr<PerformScan> scan,
++ FoundDeviceInfoT& devices, std::shared_ptr<PerformScan> scan,
+ bool& foundProbe)
+ {
+- std::vector<boost::container::flat_map<std::string, BasicVariantType>>&
+- dbusObject = scan->dbusProbeObjects[interface];
++ FoundDeviceInfoT& dbusObject = scan->dbusProbeObjects[interface];
+ if (dbusObject.empty())
+ {
+ foundProbe = false;
+@@ -287,8 +294,9 @@ bool probeDbus(const std::string& interface,
+ foundProbe = true;
+
+ bool foundMatch = false;
+- for (auto& device : dbusObject)
++ for (auto& deviceInfo : dbusObject)
+ {
++ auto& device = std::get<0>(deviceInfo);
+ bool deviceMatches = true;
+ for (auto& match : matches)
+ {
+@@ -305,7 +313,7 @@ bool probeDbus(const std::string& interface,
+ }
+ if (deviceMatches)
+ {
+- devices.emplace_back(device);
++ devices.emplace_back(deviceInfo);
+ foundMatch = true;
+ deviceMatches = false; // for next iteration
+ }
+@@ -315,11 +323,8 @@ bool probeDbus(const std::string& interface,
+
+ // default probe entry point, iterates a list looking for specific types to
+ // call specific probe functions
+-bool probe(
+- const std::vector<std::string>& probeCommand,
+- std::shared_ptr<PerformScan> scan,
+- std::vector<boost::container::flat_map<std::string, BasicVariantType>>&
+- foundDevs)
++bool probe(const std::vector<std::string>& probeCommand,
++ std::shared_ptr<PerformScan> scan, FoundDeviceInfoT& foundDevs)
+ {
+ const static std::regex command(R"(\((.*)\))");
+ std::smatch match;
+@@ -449,8 +454,9 @@ bool probe(
+ // probe passed, but empty device
+ if (ret && foundDevs.size() == 0)
+ {
+- foundDevs.emplace_back(
+- boost::container::flat_map<std::string, BasicVariantType>{});
++ foundDevs.emplace_back(std::make_tuple(
++ boost::container::flat_map<std::string, BasicVariantType>{},
++ std::string{}, std::string{}, std::string{}));
+ }
+ if (matchOne && ret)
+ {
+@@ -465,13 +471,13 @@ bool probe(
+
+ PerformProbe::PerformProbe(const std::vector<std::string>& probeCommand,
+ std::shared_ptr<PerformScan>& scanPtr,
+- std::function<void(FoundDeviceT&)>&& callback) :
++ std::function<void(FoundDeviceInfoT&)>&& callback) :
+ _probeCommand(probeCommand),
+ scan(scanPtr), _callback(std::move(callback))
+ {}
+ PerformProbe::~PerformProbe()
+ {
+- FoundDeviceT foundDevs;
++ FoundDeviceInfoT foundDevs;
+ if (probe(_probeCommand, scan, foundDevs))
+ {
+ _callback(foundDevs);
+@@ -556,6 +562,47 @@ void addArrayToDbus(const std::string& name, const nlohmann::json& array,
+ }
+ }
+
++template <typename PropertyType>
++bool persistAssetTag(const PropertyType& newVal,
++ const std::string& jsonPointerString)
++{
++ std::size_t found = jsonPointerString.find_last_of("/\\");
++ std::string jsonPointerPath = jsonPointerString.substr(0, found);
++
++ auto it = mapFoundData.find(jsonPointerPath);
++ if (it == mapFoundData.end())
++ {
++ std::cerr << "Error in finding jsonPointerPath in mapFoundData"
++ << "\n";
++ return false;
++ }
++
++ foundProbeData& tmpMap = it->second;
++ auto foundConn = tmpMap.find("foundConn");
++ auto foundPath = tmpMap.find("foundPath");
++ auto foundIntf = tmpMap.find("foundIntf");
++ if (foundConn == tmpMap.end() || foundPath == tmpMap.end() ||
++ foundIntf == tmpMap.end())
++ {
++ std::cerr << "No prob object data is avaliable in foundProbeData"
++ << "\n";
++ return false;
++ }
++
++ SYSTEM_BUS->async_method_call(
++ [](const boost::system::error_code& ec) {
++ if (ec)
++ {
++ std::cerr << "Error setting AssetTag in FRU interface " << ec
++ << "\n";
++ }
++ },
++ foundConn->second, foundPath->second, "org.freedesktop.DBus.Properties",
++ "Set", foundIntf->second, "PRODUCT_ASSET_TAG",
++ std::variant<PropertyType>(newVal));
++ return true;
++}
++
+ template <typename PropertyType>
+ void addProperty(const std::string& propertyName, const PropertyType& value,
+ sdbusplus::asio::dbus_interface* iface,
+@@ -568,11 +615,21 @@ void addProperty(const std::string& propertyName, const PropertyType& value,
+ iface->register_property(propertyName, value);
+ return;
+ }
++
+ iface->register_property(
+ propertyName, value,
+- [&systemConfiguration,
++ [propertyName, &systemConfiguration,
+ jsonPointerString{std::string(jsonPointerString)}](
+ const PropertyType& newVal, PropertyType& val) {
++ if (propertyName == "AssetTag")
++ {
++ if (!persistAssetTag(newVal, jsonPointerString))
++ {
++ std::cerr << "error setting AssetTag in FRU interface\n";
++ return -1;
++ }
++ }
++
+ val = newVal;
+ if (!setJsonFromPointer(jsonPointerString, val,
+ systemConfiguration))
+@@ -970,6 +1027,11 @@ void postToDbus(const nlohmann::json& newConfiguration,
+ populateInterfaceFromJson(systemConfiguration, jsonPointerPath,
+ boardIface, boardValues, objServer);
+ jsonPointerPath += "/";
++
++ std::string foundConn;
++ std::string foundPath;
++ std::string foundIntf;
++
+ // iterate through board properties
+ for (auto& boardField : boardValues.items())
+ {
+@@ -979,9 +1041,32 @@ void postToDbus(const nlohmann::json& newConfiguration,
+ createInterface(objServer, boardName, boardField.key(),
+ boardKeyOrig);
+
+- populateInterfaceFromJson(systemConfiguration,
+- jsonPointerPath + boardField.key(),
+- iface, boardField.value(), objServer);
++ if (boardField.key() == "FoundProbe")
++ {
++ foundConn = boardField.value()["Connection"];
++ foundPath = boardField.value()["Path"];
++ foundIntf = boardField.value()["Interface"];
++ }
++ if (boardField.key() ==
++ "xyz.openbmc_project.Inventory.Decorator.AssetTag")
++ {
++ foundData["foundConn"] = foundConn;
++ foundData["foundPath"] = foundPath;
++ foundData["foundIntf"] = foundIntf;
++ mapFoundData[jsonPointerPath + boardField.key()] =
++ foundData;
++
++ populateInterfaceFromJson(
++ systemConfiguration, jsonPointerPath + boardField.key(),
++ iface, boardField.value(), objServer,
++ sdbusplus::asio::PropertyPermission::readWrite);
++ }
++ else
++ {
++ populateInterfaceFromJson(
++ systemConfiguration, jsonPointerPath + boardField.key(),
++ iface, boardField.value(), objServer);
++ }
+ }
+ }
+
+@@ -1278,7 +1363,7 @@ void PerformScan::run()
+ auto thisRef = shared_from_this();
+ auto probePointer = std::make_shared<PerformProbe>(
+ probeCommand, thisRef,
+- [&, recordPtr, probeName](FoundDeviceT& foundDevices) {
++ [&, recordPtr, probeName](FoundDeviceInfoT& foundDevices) {
+ _passed = true;
+
+ std::set<nlohmann::json> usedNames;
+@@ -1294,7 +1379,8 @@ void PerformScan::run()
+ for (auto itr = foundDevices.begin();
+ itr != foundDevices.end();)
+ {
+- std::string recordName = getRecordName(*itr, probeName);
++ std::string recordName =
++ getRecordName(std::get<0>(*itr), probeName);
+
+ auto fromLastJson = lastJson.find(recordName);
+ if (fromLastJson != lastJson.end())
+@@ -1328,6 +1414,15 @@ void PerformScan::run()
+ continue;
+ }
+
++ nlohmann::json recordVal = *recordPtr;
++ // Save the dbus connection, path and interface info
++ // of the device
++ recordVal[foundObject]["Connection"] =
++ std::get<1>(*itr);
++ recordVal[foundObject]["Path"] = std::get<2>(*itr);
++ recordVal[foundObject]["Interface"] =
++ std::get<3>(*itr);
++
+ int index = std::stoi(
+ nameIt->get<std::string>().substr(indexIdx),
+ nullptr, 0);
+@@ -1349,8 +1444,9 @@ void PerformScan::run()
+
+ std::optional<std::string> replaceStr;
+
+- for (auto& foundDevice : foundDevices)
++ for (auto& foundDeviceInfo : foundDevices)
+ {
++ auto& foundDevice = std::get<0>(foundDeviceInfo);
+ nlohmann::json record = *recordPtr;
+ std::string recordName =
+ getRecordName(foundDevice, probeName);
+@@ -1382,6 +1478,14 @@ void PerformScan::run()
+ }
+ }
+
++ // Save the dbus connection, path and interface info
++ // of the device
++ record[foundObject]["Connection"] =
++ std::get<1>(foundDeviceInfo);
++ record[foundObject]["Path"] = std::get<2>(foundDeviceInfo);
++ record[foundObject]["Interface"] =
++ std::get<3>(foundDeviceInfo);
++
+ if (replaceStr)
+ {
+ std::cerr << "Duplicates found, replacing "
+--
+2.17.1
+
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager_%.bbappend
index 619c2f3d4..94bddf2be 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager_%.bbappend
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager_%.bbappend
@@ -1,8 +1,10 @@
# this is here just to bump faster than upstream
# SRC_URI = "git://github.com/openbmc/entity-manager.git"
-SRCREV = "2a9670820094a9a1847770597b713bf6fb3c08ba"
+SRCREV = "296667f0076888f3cdf898a3f2cdf66da260853e"
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
-SRC_URI += " file://0001-Improve-initialization-of-I2C-sensors.patch"
+SRC_URI += " file://0001-Improve-initialization-of-I2C-sensors.patch \
+ file://0002-Entity-manager-Add-support-to-update-assetTag.patch \
+ "
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/dbus/phosphor-dbus-interfaces/0034-Fix-crash-issue-due-to-throw-undefined-error.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/dbus/phosphor-dbus-interfaces/0034-Fix-crash-issue-due-to-throw-undefined-error.patch
deleted file mode 100644
index 98c3873dd..000000000
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/dbus/phosphor-dbus-interfaces/0034-Fix-crash-issue-due-to-throw-undefined-error.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From df0e7c1414b793a36e34a5875e4196a3a45704a5 Mon Sep 17 00:00:00 2001
-From: Kuiying Wang <kuiying.wang@intel.com>
-Date: Mon, 21 Dec 2020 23:09:33 +0800
-Subject: [PATCH] Fix crash issue due to throw undefined error
-
-Below 3 error is used by bios config manager daemon.
-xyz.openbmc_project.Common.Error.InvalidArgument
-xyz.openbmc_project.BIOSConfig.Common.Error.AttributeNotFound
-xyz.openbmc_project.BIOSConfig.Common.Error.AttributeReadOnl
-
-Tested:
-bios config manager daemon could throw these 3 error,
-but not crash any more.
-
-Signed-off-by: Kuiying Wang <kuiying.wang@intel.com>
----
- xyz/openbmc_project/BIOSConfig/Manager.interface.yaml | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/xyz/openbmc_project/BIOSConfig/Manager.interface.yaml b/xyz/openbmc_project/BIOSConfig/Manager.interface.yaml
-index 225ccaa..98daf3a 100644
---- a/xyz/openbmc_project/BIOSConfig/Manager.interface.yaml
-+++ b/xyz/openbmc_project/BIOSConfig/Manager.interface.yaml
-@@ -109,7 +109,10 @@ properties:
- ex- { {"QuietBoot",Type.Integer, 0x1},
- { "DdrFreqLimit",Type.String,"2933"}
- }
--
-+ errors:
-+ - xyz.openbmc_project.Common.Error.InvalidArgument
-+ - xyz.openbmc_project.BIOSConfig.Common.Error.AttributeNotFound
-+ - xyz.openbmc_project.BIOSConfig.Common.Error.AttributeReadOnly
-
- enumerations:
- - name: AttributeType
---
-2.17.1
-
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/dbus/phosphor-dbus-interfaces_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/dbus/phosphor-dbus-interfaces_%.bbappend
index f947b19c0..4cc641eec 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/dbus/phosphor-dbus-interfaces_%.bbappend
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/dbus/phosphor-dbus-interfaces_%.bbappend
@@ -1,7 +1,7 @@
# Keep this as a comment to enable the auto-bump script without
# stomping on SRC_URI from previous .bbappend files
#SRC_URI = "git://github.com/openbmc/phosphor-dbus-interfaces.git"
-SRCREV = "6be85da9193d5c529b49fbf9345507e0be2b9477"
+SRCREV = "d01d1f84191894ad605a9ba5b546280bcfc64f7d"
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
@@ -18,5 +18,4 @@ SRC_URI += "file://0007-ipmi-set-BIOS-id.patch \
file://0030-Add-PLDM-version-purpose-enumeration.patch \
file://0032-update-meson-build-for-MCTP-interfaces.patch \
file://0033-update-meson-build-for-PLDM-FWU-interfaces.patch \
- file://0034-Fix-crash-issue-due-to-throw-undefined-error.patch \
"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0005-Modified-firmware-activation-to-launch-fwupd.sh-thro.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0005-Modified-firmware-activation-to-launch-fwupd.sh-thro.patch
index 82ec8431d..cfaa077eb 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0005-Modified-firmware-activation-to-launch-fwupd.sh-thro.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0005-Modified-firmware-activation-to-launch-fwupd.sh-thro.patch
@@ -1,4 +1,4 @@
-From 05b893222a8586c51e6f66320067f13b2a89dd46 Mon Sep 17 00:00:00 2001
+From df1281792f6886b41c99919e8197c2c2d369d0ca Mon Sep 17 00:00:00 2001
From: Jennifer Lee <jennifer1.lee@intel.com>
Date: Mon, 10 Dec 2018 10:36:44 -0800
Subject: [PATCH] Modified firmware activation to launch fwupd.sh through
@@ -10,7 +10,6 @@ Subject: [PATCH] Modified firmware activation to launch fwupd.sh through
Signed-off-by: Jennifer Lee <jennifer1.lee@intel.com>
Signed-off-by: James Feist <james.feist@linux.intel.com>
-
---
activation.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++-
meson.build | 1 +
@@ -20,12 +19,12 @@ Signed-off-by: James Feist <james.feist@linux.intel.com>
5 files changed, 91 insertions(+), 9 deletions(-)
diff --git a/activation.cpp b/activation.cpp
-index c82e297..d690a39 100644
+index eb57587..901caf3 100644
--- a/activation.cpp
+++ b/activation.cpp
-@@ -88,7 +88,50 @@ auto Activation::activation(Activations value) -> Activations
-
- if (value == softwareServer::Activation::Activations::Activating)
+@@ -92,7 +92,50 @@ auto Activation::activation(Activations value) -> Activations
+ value ==
+ softwareServer::Activation::Activations::ActivatingAsStandbySpare)
{
+#ifdef FWUPD_SCRIPT
+ if (!activationProgress)
@@ -74,7 +73,7 @@ index c82e297..d690a39 100644
#ifdef HOST_BIOS_UPGRADE
auto purpose = parent.versions.find(versionId)->second->purpose();
if (purpose == VersionPurpose::Host)
-@@ -111,7 +154,6 @@ auto Activation::activation(Activations value) -> Activations
+@@ -115,7 +158,6 @@ auto Activation::activation(Activations value) -> Activations
return softwareServer::Activation::activation(value);
}
#endif
@@ -82,7 +81,7 @@ index c82e297..d690a39 100644
auto versionStr = parent.versions.find(versionId)->second->version();
if (!minimum_ship_level::verify(versionStr))
-@@ -175,6 +217,7 @@ auto Activation::activation(Activations value) -> Activations
+@@ -179,6 +221,7 @@ auto Activation::activation(Activations value) -> Activations
return softwareServer::Activation::activation(
softwareServer::Activation::Activations::Active);
#endif
@@ -91,24 +90,24 @@ index c82e297..d690a39 100644
else
{
diff --git a/meson.build b/meson.build
-index c74a927..0e5f963 100644
+index 0a7a6a6..5990168 100644
--- a/meson.build
+++ b/meson.build
-@@ -54,6 +54,7 @@ conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc'))
- # Configurable features
- conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled())
- conf.set('WANT_SIGNATURE_VERIFY', get_option('verify-signature').enabled())
+@@ -57,6 +57,7 @@ conf.set('WANT_SIGNATURE_VERIFY', \
+ get_option('verify-signature').enabled() or \
+ get_option('verify-full-signature').enabled())
+ conf.set('WANT_SIGNATURE_FULL_VERIFY', get_option('verify-full-signature').enabled())
+conf.set('FWUPD_SCRIPT', get_option('fwupd-script').enabled())
# Configurable variables
conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed'))
diff --git a/meson_options.txt b/meson_options.txt
-index d37e681..d86371b 100644
+index 355773c..f0c8730 100644
--- a/meson_options.txt
+++ b/meson_options.txt
-@@ -22,6 +22,9 @@ option('oe-sdk', type: 'feature', description: 'Enable OE SDK')
- option('verify-signature', type: 'feature',
- description: 'Enable image signature validation.')
+@@ -25,6 +25,9 @@ option('verify-signature', type: 'feature',
+ option('verify-full-signature', type: 'feature',
+ description: 'Enable image full signature validation.')
+option('fwupd-script', type: 'feature',
+ description: 'Enable fwupd script support.')
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/fru/default-fru.bb b/meta-openbmc-mods/meta-common/recipes-phosphor/fru/default-fru.bb
index 53cec437d..da8fc846e 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/fru/default-fru.bb
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/fru/default-fru.bb
@@ -8,6 +8,7 @@ SYSTEMD_SERVICE_${PN} = "SetBaseboardFru.service"
S = "${WORKDIR}"
SRC_URI = "file://checkFru.sh \
+ file://decodeBoardID.sh \
file://SetBaseboardFru.service \
file://mkfru.cpp \
file://CMakeLists.txt \
@@ -24,6 +25,7 @@ RDEPENDS_${PN} = "bash"
do_install_append() {
install -d ${D}${bindir}
install -m 0755 ${S}/checkFru.sh ${D}/${bindir}/checkFru.sh
+ install -m 0755 ${S}/decodeBoardID.sh ${D}/${bindir}/decodeBoardID.sh
install -d ${D}${base_libdir}/systemd/system
install -m 0644 ${S}/SetBaseboardFru.service ${D}${base_libdir}/systemd/system
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/fru/default-fru/checkFru.sh b/meta-openbmc-mods/meta-common/recipes-phosphor/fru/default-fru/checkFru.sh
index 9227beb20..18a6c7260 100755
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/fru/default-fru/checkFru.sh
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/fru/default-fru/checkFru.sh
@@ -5,10 +5,7 @@ FRUPATH="/etc/fru"
PRODIDPATH="/var/cache/private"
fruFile="$FRUPATH/baseboard.fru.bin"
prodIDFile="$PRODIDPATH/prodID"
-
-if [ -f $fruFile -a -f $prodIDFile ]; then
- exit 0
-fi
+source decodeBoardID.sh
read_id() {
local idx=0
@@ -23,48 +20,30 @@ read_id() {
echo $result
}
-BOARD_ID=$(read_id)
-if grep -q 'CPU part\s*: 0xb76' /proc/cpuinfo; then
- # AST2500
- case $BOARD_ID in
- 12) NAME="D50TNP1SB"
- PRODID="0x99";;
- 40) NAME="CooperCity"
- PRODID="0x9d";;
- 42) NAME="WilsonCity"
- PRODID="0x91";;
- 44) NAME="WilsonCityM"
- PRODID="0x91";;
- 45) NAME="WilsonCity"
- PRODID="0x91";;
- 60) NAME="M50CYP2SB2U"
- PRODID="0x98";;
- 62) NAME="WilsonPoint"
- PRODID="0x9a";;
- *) NAME="S2600WFT"
- PRODID="0x7b";;
- esac
-
-elif grep -q 'CPU part\s*: 0xc07' /proc/cpuinfo; then
- # AST2600
- case $BOARD_ID in
- 62) NAME="ArcherCity"
- PRODID="0x9c";;
- *) NAME="AST2600EVB"
- PRODID="0x00";;
- esac
-
+if [ -f $fruFile -a -f $prodIDFile ] &&
+ grep -q 'CPU part\s*: 0xc07' /proc/cpuinfo; then
+ exit 0
fi
-if [ -z "$NAME" ]; then
- NAME="Unknown"
-fi
+NAME="Unknown"
+PRODID="0x00"
+EEPROM_FRU=false
+
+BOARD_ID=$(read_id)
+decode_board_id
if [ ! -e $prodIDFile ]
then
echo $PRODID >$prodIDFile
fi
+if $EEPROM_FRU;
+then
+ # Remove baseboard filesystem FRU(if any), as this platform has EEPROM FRU.
+ rm -f $fruFile
+ exit 0
+fi
+
if [ ! -f $fruFile ]
then
cd /tmp
@@ -73,4 +52,3 @@ then
mv $NAME.fru.bin $fruFile
fi
-
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/fru/default-fru/decodeBoardID.sh b/meta-openbmc-mods/meta-common/recipes-phosphor/fru/default-fru/decodeBoardID.sh
new file mode 100644
index 000000000..80710ae26
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/fru/default-fru/decodeBoardID.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+# this script uses the BOARD_ID set from checkFru.sh and provides the NAME,
+# PRODID, and EEPROM_FRU values for this platform
+decode_board_id() {
+}
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0001-Add-ConnectedVia-property-to-virtual-media-item-temp.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0001-Add-ConnectedVia-property-to-virtual-media-item-temp.patch
new file mode 100644
index 000000000..ec6d70df1
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0001-Add-ConnectedVia-property-to-virtual-media-item-temp.patch
@@ -0,0 +1,25 @@
+From 4af788655c5b5a5fae4d85b365a70dc619810fe0 Mon Sep 17 00:00:00 2001
+From: Karol Wachowski <karol.wachowski@intel.com>
+Date: Thu, 11 Feb 2021 08:35:41 +0000
+Subject: [PATCH] Add ConnectedVia property to virtual media item template
+
+Tested: Verified that ConnectedVia property is returned and set to
+ "NotConnected" for disconnected media.
+
+Signed-off-by: Karol Wachowski <karol.wachowski@intel.com>
+---
+ redfish-core/lib/virtual_media.hpp | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
+index 188248a..80e7315 100644
+--- a/redfish-core/lib/virtual_media.hpp
++++ b/redfish-core/lib/virtual_media.hpp
+@@ -192,6 +192,7 @@ static nlohmann::json vmItemTemplate(const std::string& name,
+ item["@odata.id"] =
+ "/redfish/v1/Managers/" + name + "/VirtualMedia/" + resName;
+ item["@odata.type"] = "#VirtualMedia.v1_3_0.VirtualMedia";
++ item["ConnectedVia"] = "NotConnected";
+ item["Name"] = "Virtual Removable Media";
+ item["Id"] = resName;
+ item["WriteProtected"] = true;
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0001-Firmware-update-configuration-changes.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0001-Firmware-update-configuration-changes.patch
index a802095d5..193461baf 100755
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0001-Firmware-update-configuration-changes.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0001-Firmware-update-configuration-changes.patch
@@ -1,4 +1,4 @@
-From b831fbaf5c3ca346d2e701b021307ba219ca2ef8 Mon Sep 17 00:00:00 2001
+From 10cb7cb14974725a29b3ead4c543ca5e58234c07 Mon Sep 17 00:00:00 2001
From: Vikram Bodireddy <vikram.bodireddy@intel.com>
Date: Wed, 18 Nov 2020 17:14:41 +0530
Subject: [PATCH] Firmware update configuration changes
@@ -55,7 +55,7 @@ Signed-off-by: Helen Huang <he.huang@intel.com>
create mode 100644 static/redfish/v1/schema/OemUpdateService_v1.xml
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
-index 9e382ce..7dff5c9 100644
+index 6d44171..8eda265 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -32,6 +32,17 @@ static std::unique_ptr<sdbusplus::bus::match::match> fwUpdateErrorMatcher;
@@ -287,7 +287,7 @@ index 9e382ce..7dff5c9 100644
// Setup callback for when new software detected
// Give TFTP 10 minutes to complete
monitorForSoftwareAvailable(
- nullptr, req,
+ asyncResp, req,
"/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate",
- 600);
+ httpUriTargets, 600);
@@ -557,10 +557,10 @@ index 9e382ce..7dff5c9 100644
};
diff --git a/static/redfish/v1/$metadata/index.xml b/static/redfish/v1/$metadata/index.xml
-index e7f9d6d..bedc9e5 100644
+index 514f3dd..c068d4f 100644
--- a/static/redfish/v1/$metadata/index.xml
+++ b/static/redfish/v1/$metadata/index.xml
-@@ -2700,6 +2700,9 @@
+@@ -2142,6 +2142,9 @@
<edmx:Reference Uri="/redfish/v1/schema/OemManager_v1.xml">
<edmx:Include Namespace="OemManager"/>
</edmx:Reference>
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0002-Change-InsertMedia-action-response-for-POST-in-proxy.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0002-Change-InsertMedia-action-response-for-POST-in-proxy.patch
new file mode 100644
index 000000000..d04220b89
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0002-Change-InsertMedia-action-response-for-POST-in-proxy.patch
@@ -0,0 +1,30 @@
+From dcc94627aac5b8e4ad181c8548391c53d27b8896 Mon Sep 17 00:00:00 2001
+From: Karol Wachowski <karol.wachowski@intel.com>
+Date: Tue, 16 Feb 2021 06:47:11 +0000
+Subject: [PATCH] Change InsertMedia action response for POST in proxy mode
+
+Set boost::beast::http::status::method_not_allowed as a response
+for POST request to Virtual Media Insert Media action to keep
+consistency with other non existing requests.
+---
+ redfish-core/lib/virtual_media.hpp | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
+index 80e7315..76e8c4a 100644
+--- a/redfish-core/lib/virtual_media.hpp
++++ b/redfish-core/lib/virtual_media.hpp
+@@ -611,10 +611,9 @@ class VirtualMediaActionInsertMedia : public Node
+ // Not possible in proxy mode
+ BMCWEB_LOG_DEBUG << "InsertMedia not "
+ "allowed in proxy mode";
+- messages::resourceNotFound(
+- aResp->res, "VirtualMedia.InsertMedia",
+- resName);
+-
++ aResp->res.result(
++ boost::beast::http::status::
++ method_not_allowed);
+ return;
+ }
+
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0003-Set-Inserted-redfish-property-for-not-inserted-resou.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0003-Set-Inserted-redfish-property-for-not-inserted-resou.patch
new file mode 100644
index 000000000..eaba041d5
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0003-Set-Inserted-redfish-property-for-not-inserted-resou.patch
@@ -0,0 +1,40 @@
+From dab4adbf211b6867f86fcf6080b34a0e41f6f4a1 Mon Sep 17 00:00:00 2001
+From: Karol Wachowski <karol.wachowski@intel.com>
+Date: Tue, 23 Feb 2021 15:53:16 +0000
+Subject: [PATCH] Set Inserted redfish property for not inserted resources
+
+Tested: Verified that Inserted property is returned and set to
+ "false" for not inserted media.
+Signed-off-by: Karol Wachowski <karol.wachowski@intel.com>
+---
+ redfish-core/lib/virtual_media.hpp | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
+index 188248a..f477f63 100644
+--- a/redfish-core/lib/virtual_media.hpp
++++ b/redfish-core/lib/virtual_media.hpp
+@@ -95,6 +95,7 @@ static void vmParseInterfaceObject(const DbusInterfaceType& interface,
+ BMCWEB_LOG_DEBUG << "Value Active not found";
+ return;
+ }
++ aResp->res.jsonValue["Inserted"] = *activeValue;
+
+ const std::string* endpointIdValue =
+ std::get_if<std::string>(&endpointIdProperty->second);
+@@ -106,7 +107,6 @@ static void vmParseInterfaceObject(const DbusInterfaceType& interface,
+ aResp->res.jsonValue["Oem"]["OpenBMC"]["WebSocketEndpoint"] =
+ *endpointIdValue;
+ aResp->res.jsonValue["TransferProtocolType"] = "OEM";
+- aResp->res.jsonValue["Inserted"] = *activeValue;
+ if (*activeValue == true)
+ {
+ aResp->res.jsonValue["ConnectedVia"] = "Applet";
+@@ -137,7 +137,6 @@ static void vmParseInterfaceObject(const DbusInterfaceType& interface,
+ }
+
+ aResp->res.jsonValue["Image"] = *imageUrlValue;
+- aResp->res.jsonValue["Inserted"] = *activeValue;
+ aResp->res.jsonValue["TransferProtocolType"] =
+ getTransferProtocolTypeFromUri(*imageUrlValue);
+
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0036-Fix-wrong-check-in-EventService-events.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0036-Fix-wrong-check-in-EventService-events.patch
deleted file mode 100644
index 115a48112..000000000
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0036-Fix-wrong-check-in-EventService-events.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 6a9f85f9050e2c0f38148e295d7e25f56d05c6de Mon Sep 17 00:00:00 2001
-From: AppaRao Puli <apparao.puli@linux.intel.com>
-Date: Mon, 1 Feb 2021 23:45:53 +0000
-Subject: [PATCH] Fix wrong check in EventService events
-
-Sending async event logs to event listener is
-broken due to commit 23a21a1cbed23ace4174664950e595df961e9e69.
-Correct the check to make EventService back to functional
-state.
-
-Tested:
- - Redfish event logs are properly sent to subscribers.
-
-Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
-Change-Id: If232846a2b0ac694205731a801e55dc4bd5e928a
----
- redfish-core/include/event_service_manager.hpp | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
-index 54dafb4..3db9f0c 100644
---- a/redfish-core/include/event_service_manager.hpp
-+++ b/redfish-core/include/event_service_manager.hpp
-@@ -1208,7 +1208,7 @@ class EventServiceManager
-
- static void watchRedfishEventLogFile()
- {
-- if (inotifyConn)
-+ if (!inotifyConn)
- {
- return;
- }
---
-2.17.1
-
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0037-Add-state-sensor-messages-to-the-registry.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0037-Add-state-sensor-messages-to-the-registry.patch
new file mode 100644
index 000000000..b171a8b2c
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0037-Add-state-sensor-messages-to-the-registry.patch
@@ -0,0 +1,98 @@
+From df571ddf0596f73c0318da3a90b9813e6df19dd9 Mon Sep 17 00:00:00 2001
+From: "Arun P. Mohanan" <arun.p.m@linux.intel.com>
+Date: Wed, 27 Jan 2021 18:22:58 +0530
+Subject: [PATCH] Add state sensor messages to the registry
+
+Add messages to registry to indicate state sensor state change.
+
+Tested:
+Build and redfish validator passes.
+Logged these events and confirmed that they appear as expected on
+Redfish.
+GET: https://<BMC IP>/redfish/v1/Systems/system/LogServices/EventLog/Entries/1612528180
+{
+ "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1612528180",
+ "@odata.type": "#LogEntry.v1_4_0.LogEntry",
+ "Created": "2021-02-05T12:29:40+00:00",
+ "EntryType": "Event",
+ "Id": "1612528180",
+ "Message": "Operational Fault Status of Card_health_1 state sensor changed from Error to Normal.",
+ "MessageArgs": [
+ "Operational Fault Status",
+ "Card_health_1",
+ "Error",
+ "Normal"
+ ],
+ "MessageId": "OpenBMC.0.1.StateSensorNormal",
+ "Name": "System Event Log Entry",
+ "Severity": "OK"
+}
+
+Signed-off-by: Arun P. Mohanan <arun.p.m@linux.intel.com>
+---
+ .../registries/openbmc_message_registry.hpp | 36 +++++++++++++++++--
+ 1 file changed, 34 insertions(+), 2 deletions(-)
+
+diff --git a/redfish-core/include/registries/openbmc_message_registry.hpp b/redfish-core/include/registries/openbmc_message_registry.hpp
+index 5eb9380..dbea97c 100644
+--- a/redfish-core/include/registries/openbmc_message_registry.hpp
++++ b/redfish-core/include/registries/openbmc_message_registry.hpp
+@@ -29,7 +29,7 @@ const Header header = {
+ "0.1.0",
+ "OpenBMC",
+ };
+-constexpr std::array<MessageEntry, 187> registry = {
++constexpr std::array<MessageEntry, 190> registry = {
+ MessageEntry{
+ "ADDDCCorrectable",
+ {
+@@ -2318,6 +2318,39 @@ constexpr std::array<MessageEntry, 187> registry = {
+ {},
+ "None.",
+ }},
++ MessageEntry{
++ "StateSensorNormal",
++ {
++ "Indicates that a state sensor has changed state to normal.",
++ "%1 of %2 state sensor changed from %3 to %4.",
++ "OK",
++ "OK",
++ 4,
++ {"string", "string", "string", "string"},
++ "None.",
++ }},
++ MessageEntry{
++ "StateSensorWarning",
++ {
++ "Indicates that a state sensor has changed state to warning.",
++ "%1 of %2 state sensor changed from %3 to %4.",
++ "Warning",
++ "Warning",
++ 4,
++ {"string", "string", "string", "string"},
++ "Check sensor subsystem for errors.",
++ }},
++ MessageEntry{
++ "StateSensorCritical",
++ {
++ "Indicates that a state sensor has changed state to critical.",
++ "%1 of %2 state sensor changed from %3 to %4.",
++ "Critical",
++ "Critical",
++ 4,
++ {"string", "string", "string", "string"},
++ "Check sensor subsystem for errors.",
++ }},
+ MessageEntry{"SystemInterfaceDisabledProvisioned",
+ {
+ "Indicates that the system interface is in the disabled "
+@@ -2410,6 +2443,5 @@ constexpr std::array<MessageEntry, 187> registry = {
+ {"string"},
+ "None.",
+ }},
+-
+ };
+ } // namespace redfish::message_registries::openbmc
+--
+2.17.1
+
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Redfish-TelemetryService-schema-implementation.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Redfish-TelemetryService-schema-implementation.patch
deleted file mode 100644
index 208831338..000000000
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Redfish-TelemetryService-schema-implementation.patch
+++ /dev/null
@@ -1,717 +0,0 @@
-From d50e4ce193703c008d3293acd03e1c0542c0c215 Mon Sep 17 00:00:00 2001
-From: "Wludzik, Jozef" <jozef.wludzik@intel.com>
-Date: Mon, 27 Apr 2020 17:24:15 +0200
-Subject: [PATCH] Redfish TelemetryService schema implementation
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Added TelemetryService, MetricReports, MetricReportCollection,
-MetricReportDefinition and MetricReportDefinitionCollection schemas
-with GET method support. Added TelemetryService URI to root service.
-Implemented communication with backend - Telemetry.
-Added schemes attributes that are supported by Telemetry service
-design. User is able to fetch basic information about reports if
-Telemetry service is present in OpenBMC.
-Added util function that converts decimal value into duration format
-that is described by ISO 8601 and Redfish specification.
-
-Tested:
- - Succesfully passed RedfishServiceValidator.py
- - Verified DBus method calls to Telemetry service
- - Verified all possible pages that are displayed to user when:
- - Reports are fully defined in Telemetry
- - Reports are partially available in Telemetry
- - Telemetry is disabled
- - Verified time_utils::toDurationString() output
-
-Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
-Signed-off-by: Adrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com>
-Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
-Change-Id: Ie6b0b49f4ef5eeaef07d1209b6c349270c04d570
----
- redfish-core/include/redfish.hpp | 10 +
- .../include/utils/telemetry_utils.hpp | 71 +++++++
- redfish-core/include/utils/time_utils.hpp | 78 ++++++++
- redfish-core/lib/metric_report.hpp | 162 +++++++++++++++
- redfish-core/lib/metric_report_definition.hpp | 186 ++++++++++++++++++
- redfish-core/lib/service_root.hpp | 2 +
- redfish-core/lib/telemetry_service.hpp | 93 +++++++++
- 7 files changed, 602 insertions(+)
- create mode 100644 redfish-core/include/utils/telemetry_utils.hpp
- create mode 100644 redfish-core/include/utils/time_utils.hpp
- create mode 100644 redfish-core/lib/metric_report.hpp
- create mode 100644 redfish-core/lib/metric_report_definition.hpp
- create mode 100644 redfish-core/lib/telemetry_service.hpp
-
-diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp
-index dabf78e..b366e24 100644
---- a/redfish-core/include/redfish.hpp
-+++ b/redfish-core/include/redfish.hpp
-@@ -25,6 +25,8 @@
- #include "../lib/managers.hpp"
- #include "../lib/memory.hpp"
- #include "../lib/message_registries.hpp"
-+#include "../lib/metric_report.hpp"
-+#include "../lib/metric_report_definition.hpp"
- #include "../lib/network_protocol.hpp"
- #include "../lib/pcie.hpp"
- #include "../lib/power.hpp"
-@@ -36,6 +38,7 @@
- #include "../lib/storage.hpp"
- #include "../lib/systems.hpp"
- #include "../lib/task.hpp"
-+#include "../lib/telemetry_service.hpp"
- #include "../lib/thermal.hpp"
- #include "../lib/update_service.hpp"
- #ifdef BMCWEB_ENABLE_VM_NBDPROXY
-@@ -212,6 +215,13 @@ class RedfishService
- nodes.emplace_back(std::make_unique<HypervisorInterface>(app));
- nodes.emplace_back(std::make_unique<HypervisorSystem>(app));
-
-+ nodes.emplace_back(std::make_unique<TelemetryService>(app));
-+ nodes.emplace_back(
-+ std::make_unique<MetricReportDefinitionCollection>(app));
-+ nodes.emplace_back(std::make_unique<MetricReportDefinition>(app));
-+ nodes.emplace_back(std::make_unique<MetricReportCollection>(app));
-+ nodes.emplace_back(std::make_unique<MetricReport>(app));
-+
- for (const auto& node : nodes)
- {
- node->initPrivileges();
-diff --git a/redfish-core/include/utils/telemetry_utils.hpp b/redfish-core/include/utils/telemetry_utils.hpp
-new file mode 100644
-index 0000000..8caee2d
---- /dev/null
-+++ b/redfish-core/include/utils/telemetry_utils.hpp
-@@ -0,0 +1,71 @@
-+#pragma once
-+
-+namespace redfish
-+{
-+
-+namespace telemetry
-+{
-+
-+constexpr const char* service = "xyz.openbmc_project.Telemetry";
-+constexpr const char* reportInterface = "xyz.openbmc_project.Telemetry.Report";
-+constexpr const char* metricReportDefinitionUri =
-+ "/redfish/v1/TelemetryService/MetricReportDefinitions/";
-+constexpr const char* metricReportUri =
-+ "/redfish/v1/TelemetryService/MetricReports/";
-+
-+inline void getReportCollection(const std::shared_ptr<AsyncResp>& asyncResp,
-+ const std::string& uri)
-+{
-+ const std::array<const char*, 1> interfaces = {reportInterface};
-+
-+ crow::connections::systemBus->async_method_call(
-+ [asyncResp, uri](const boost::system::error_code ec,
-+ const std::vector<std::string>& reportPaths) {
-+ if (ec)
-+ {
-+ asyncResp->res.jsonValue["Members"] = nlohmann::json::array();
-+ asyncResp->res.jsonValue["Members@odata.count"] = 0;
-+ return;
-+ }
-+
-+ nlohmann::json& members = asyncResp->res.jsonValue["Members"];
-+ members = nlohmann::json::array();
-+
-+ for (const std::string& path : reportPaths)
-+ {
-+ std::size_t pos = path.rfind('/');
-+ if (pos == std::string::npos)
-+ {
-+ BMCWEB_LOG_ERROR << "Failed to find '/' in " << path;
-+ messages::internalError(asyncResp->res);
-+ return;
-+ }
-+ if (path.size() <= (pos + 1))
-+ {
-+ BMCWEB_LOG_ERROR << "Failed to parse path " << path;
-+ messages::internalError(asyncResp->res);
-+ return;
-+ }
-+
-+ members.push_back({{"@odata.id", uri + path.substr(pos + 1)}});
-+ }
-+
-+ asyncResp->res.jsonValue["Members@odata.count"] = members.size();
-+ },
-+ "xyz.openbmc_project.ObjectMapper",
-+ "/xyz/openbmc_project/object_mapper",
-+ "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
-+ "/xyz/openbmc_project/Telemetry/Reports/TelemetryService", 1,
-+ interfaces);
-+}
-+
-+inline std::string getDbusReportPath(const std::string& id)
-+{
-+ std::string path =
-+ "/xyz/openbmc_project/Telemetry/Reports/TelemetryService/" + id;
-+ dbus::utility::escapePathForDbus(path);
-+ return path;
-+}
-+
-+} // namespace telemetry
-+} // namespace redfish
-diff --git a/redfish-core/include/utils/time_utils.hpp b/redfish-core/include/utils/time_utils.hpp
-new file mode 100644
-index 0000000..dd4ea75
---- /dev/null
-+++ b/redfish-core/include/utils/time_utils.hpp
-@@ -0,0 +1,78 @@
-+#pragma once
-+
-+#include <chrono>
-+#include <string>
-+
-+namespace redfish
-+{
-+
-+namespace time_utils
-+{
-+
-+namespace details
-+{
-+
-+inline void leftZeroPadding(std::string& str, const std::size_t padding)
-+{
-+ if (str.size() < padding)
-+ {
-+ str.insert(0, padding - str.size(), '0');
-+ }
-+}
-+} // namespace details
-+
-+/**
-+ * @brief Convert time value into duration format that is based on ISO 8601.
-+ * Example output: "P12DT1M5.5S"
-+ * Ref: Redfish Specification, Section 9.4.4. Duration values
-+ */
-+std::string toDurationString(std::chrono::milliseconds ms)
-+{
-+ if (ms < std::chrono::milliseconds::zero())
-+ {
-+ return "";
-+ }
-+
-+ std::string fmt;
-+ fmt.reserve(sizeof("PxxxxxxxxxxxxDTxxHxxMxx.xxxxxxS"));
-+
-+ using Days = std::chrono::duration<long, std::ratio<24 * 60 * 60>>;
-+ Days days = std::chrono::floor<Days>(ms);
-+ ms -= days;
-+
-+ std::chrono::hours hours = std::chrono::floor<std::chrono::hours>(ms);
-+ ms -= hours;
-+
-+ std::chrono::minutes minutes = std::chrono::floor<std::chrono::minutes>(ms);
-+ ms -= minutes;
-+
-+ std::chrono::seconds seconds = std::chrono::floor<std::chrono::seconds>(ms);
-+ ms -= seconds;
-+
-+ fmt = "P";
-+ if (days.count() > 0)
-+ {
-+ fmt += std::to_string(days.count()) + "D";
-+ }
-+ fmt += "T";
-+ if (hours.count() > 0)
-+ {
-+ fmt += std::to_string(hours.count()) + "H";
-+ }
-+ if (minutes.count() > 0)
-+ {
-+ fmt += std::to_string(minutes.count()) + "M";
-+ }
-+ if (seconds.count() != 0 || ms.count() != 0)
-+ {
-+ fmt += std::to_string(seconds.count()) + ".";
-+ std::string msStr = std::to_string(ms.count());
-+ details::leftZeroPadding(msStr, 3);
-+ fmt += msStr + "S";
-+ }
-+
-+ return fmt;
-+}
-+
-+} // namespace time_utils
-+} // namespace redfish
-diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp
-new file mode 100644
-index 0000000..050304c
---- /dev/null
-+++ b/redfish-core/lib/metric_report.hpp
-@@ -0,0 +1,162 @@
-+#pragma once
-+
-+#include "node.hpp"
-+#include "utils/telemetry_utils.hpp"
-+
-+namespace redfish
-+{
-+
-+class MetricReportCollection : public Node
-+{
-+ public:
-+ MetricReportCollection(App& app) :
-+ Node(app, "/redfish/v1/TelemetryService/MetricReports/")
-+ {
-+ 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&,
-+ const std::vector<std::string>&) override
-+ {
-+ res.jsonValue["@odata.type"] =
-+ "#MetricReportCollection.MetricReportCollection";
-+ res.jsonValue["@odata.id"] =
-+ "/redfish/v1/TelemetryService/MetricReports";
-+ res.jsonValue["Name"] = "Metric Report Collection";
-+
-+ auto asyncResp = std::make_shared<AsyncResp>(res);
-+ telemetry::getReportCollection(asyncResp, telemetry::metricReportUri);
-+ }
-+};
-+
-+class MetricReport : public Node
-+{
-+ public:
-+ MetricReport(App& app) :
-+ Node(app, "/redfish/v1/TelemetryService/MetricReports/<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&,
-+ const std::vector<std::string>& params) override
-+ {
-+ auto asyncResp = std::make_shared<AsyncResp>(res);
-+
-+ if (params.size() != 1)
-+ {
-+ messages::internalError(asyncResp->res);
-+ return;
-+ }
-+
-+ const std::string& id = params[0];
-+ const std::string reportPath = telemetry::getDbusReportPath(id);
-+
-+ crow::connections::systemBus->async_method_call(
-+ [asyncResp, id, reportPath](const boost::system::error_code& ec) {
-+ if (ec.value() == EBADR)
-+ {
-+ messages::resourceNotFound(asyncResp->res, schemaType, id);
-+ return;
-+ }
-+ if (ec)
-+ {
-+ BMCWEB_LOG_ERROR << "respHandler DBus error " << ec;
-+ messages::internalError(asyncResp->res);
-+ return;
-+ }
-+
-+ crow::connections::systemBus->async_method_call(
-+ [asyncResp,
-+ id](const boost::system::error_code ec,
-+ const std::variant<TimestampReadings>& ret) {
-+ if (ec)
-+ {
-+ BMCWEB_LOG_ERROR << "respHandler DBus error " << ec;
-+ messages::internalError(asyncResp->res);
-+ return;
-+ }
-+
-+ fillReport(asyncResp, id, ret);
-+ },
-+ telemetry::service, reportPath,
-+ "org.freedesktop.DBus.Properties", "Get",
-+ telemetry::reportInterface, "Readings");
-+ },
-+ telemetry::service, reportPath, telemetry::reportInterface,
-+ "Update");
-+ }
-+
-+ using Readings =
-+ std::vector<std::tuple<std::string, std::string, double, uint64_t>>;
-+ using TimestampReadings = std::tuple<uint64_t, Readings>;
-+
-+ static nlohmann::json toMetricValues(const Readings& readings)
-+ {
-+ nlohmann::json metricValues = nlohmann::json::array_t();
-+
-+ for (auto& [id, metadata, sensorValue, timestamp] : readings)
-+ {
-+ nlohmann::json metadataJson = nlohmann::json::parse(metadata);
-+ metricValues.push_back({
-+ {"MetricId", id},
-+ {"MetricDefinition", metadataJson.contains("MetricDefinition")
-+ ? metadataJson["MetricDefinition"]
-+ : nlohmann::json()},
-+ {"MetricProperty", metadataJson.contains("MetricProperty")
-+ ? metadataJson["MetricProperty"]
-+ : nlohmann::json()},
-+ {"MetricValue", std::to_string(sensorValue)},
-+ {"Timestamp",
-+ crow::utility::getDateTime(static_cast<time_t>(timestamp))},
-+ });
-+ }
-+
-+ return metricValues;
-+ }
-+
-+ static void fillReport(const std::shared_ptr<AsyncResp>& asyncResp,
-+ const std::string& id,
-+ const std::variant<TimestampReadings>& var)
-+ {
-+ asyncResp->res.jsonValue["@odata.type"] = schemaType;
-+ asyncResp->res.jsonValue["@odata.id"] = telemetry::metricReportUri + id;
-+ asyncResp->res.jsonValue["Id"] = id;
-+ asyncResp->res.jsonValue["Name"] = id;
-+ asyncResp->res.jsonValue["MetricReportDefinition"]["@odata.id"] =
-+ telemetry::metricReportDefinitionUri + id;
-+
-+ const TimestampReadings* timestampReadings =
-+ std::get_if<TimestampReadings>(&var);
-+ if (!timestampReadings)
-+ {
-+ BMCWEB_LOG_ERROR << "Property type mismatch or property is missing";
-+ messages::internalError(asyncResp->res);
-+ return;
-+ }
-+
-+ const auto& [timestamp, readings] = *timestampReadings;
-+ asyncResp->res.jsonValue["Timestamp"] =
-+ crow::utility::getDateTime(static_cast<time_t>(timestamp));
-+ asyncResp->res.jsonValue["MetricValues"] = toMetricValues(readings);
-+ }
-+
-+ static constexpr const char* schemaType =
-+ "#MetricReport.v1_3_0.MetricReport";
-+};
-+} // namespace redfish
-diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp
-new file mode 100644
-index 0000000..48c56e6
---- /dev/null
-+++ b/redfish-core/lib/metric_report_definition.hpp
-@@ -0,0 +1,186 @@
-+#pragma once
-+
-+#include "node.hpp"
-+#include "utils/telemetry_utils.hpp"
-+#include "utils/time_utils.hpp"
-+
-+#include <tuple>
-+#include <variant>
-+
-+namespace redfish
-+{
-+
-+class MetricReportDefinitionCollection : public Node
-+{
-+ public:
-+ MetricReportDefinitionCollection(App& app) :
-+ Node(app, "/redfish/v1/TelemetryService/MetricReportDefinitions/")
-+ {
-+ 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&,
-+ const std::vector<std::string>&) override
-+ {
-+ res.jsonValue["@odata.type"] = "#MetricReportDefinitionCollection."
-+ "MetricReportDefinitionCollection";
-+ res.jsonValue["@odata.id"] =
-+ "/redfish/v1/TelemetryService/MetricReportDefinitions";
-+ res.jsonValue["Name"] = "Metric Definition Collection";
-+
-+ auto asyncResp = std::make_shared<AsyncResp>(res);
-+ telemetry::getReportCollection(asyncResp,
-+ telemetry::metricReportDefinitionUri);
-+ }
-+};
-+
-+class MetricReportDefinition : public Node
-+{
-+ public:
-+ MetricReportDefinition(App& app) :
-+ Node(app, "/redfish/v1/TelemetryService/MetricReportDefinitions/<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&,
-+ const std::vector<std::string>& params) override
-+ {
-+ auto asyncResp = std::make_shared<AsyncResp>(res);
-+
-+ if (params.size() != 1)
-+ {
-+ messages::internalError(asyncResp->res);
-+ return;
-+ }
-+
-+ const std::string& id = params[0];
-+ crow::connections::systemBus->async_method_call(
-+ [asyncResp,
-+ id](const boost::system::error_code ec,
-+ const std::vector<std::pair<
-+ std::string, std::variant<bool, ReadingParameters,
-+ std::string, uint64_t>>>& ret) {
-+ if (ec.value() == EBADR)
-+ {
-+ messages::resourceNotFound(asyncResp->res, schemaType, id);
-+ return;
-+ }
-+ if (ec)
-+ {
-+ BMCWEB_LOG_ERROR << "respHandler DBus error " << ec;
-+ messages::internalError(asyncResp->res);
-+ return;
-+ }
-+
-+ fillReportDefinition(asyncResp, id, ret);
-+ },
-+ telemetry::service, telemetry::getDbusReportPath(id),
-+ "org.freedesktop.DBus.Properties", "GetAll",
-+ telemetry::reportInterface);
-+ }
-+
-+ using ReadingParameters =
-+ std::vector<std::tuple<std::vector<sdbusplus::message::object_path>,
-+ std::string, std::string, std::string>>;
-+
-+ static void fillReportDefinition(
-+ const std::shared_ptr<AsyncResp>& asyncResp, const std::string& id,
-+ const std::vector<
-+ std::pair<std::string, std::variant<bool, ReadingParameters,
-+ std::string, uint64_t>>>& ret)
-+ {
-+ asyncResp->res.jsonValue["@odata.type"] = schemaType;
-+ asyncResp->res.jsonValue["@odata.id"] =
-+ telemetry::metricReportDefinitionUri + id;
-+ asyncResp->res.jsonValue["Id"] = id;
-+ asyncResp->res.jsonValue["Name"] = id;
-+ asyncResp->res.jsonValue["MetricReport"]["@odata.id"] =
-+ telemetry::metricReportUri + id;
-+ asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
-+ asyncResp->res.jsonValue["ReportUpdates"] = "Overwrite";
-+
-+ const bool* emitsReadingsUpdate = nullptr;
-+ const bool* logToMetricReportsCollection = nullptr;
-+ const ReadingParameters* readingParams = nullptr;
-+ const std::string* reportingType = nullptr;
-+ const uint64_t* interval = nullptr;
-+ for (const auto& [key, var] : ret)
-+ {
-+ if (key == "EmitsReadingsUpdate")
-+ {
-+ emitsReadingsUpdate = std::get_if<bool>(&var);
-+ }
-+ else if (key == "LogToMetricReportsCollection")
-+ {
-+ logToMetricReportsCollection = std::get_if<bool>(&var);
-+ }
-+ else if (key == "ReadingParameters")
-+ {
-+ readingParams = std::get_if<ReadingParameters>(&var);
-+ }
-+ else if (key == "ReportingType")
-+ {
-+ reportingType = std::get_if<std::string>(&var);
-+ }
-+ else if (key == "Interval")
-+ {
-+ interval = std::get_if<uint64_t>(&var);
-+ }
-+ }
-+ if (!emitsReadingsUpdate || !logToMetricReportsCollection ||
-+ !readingParams || !reportingType || !interval)
-+ {
-+ BMCWEB_LOG_ERROR << "Property type mismatch or property is missing";
-+ messages::internalError(asyncResp->res);
-+ return;
-+ }
-+
-+ std::vector<std::string> redfishReportActions;
-+ redfishReportActions.reserve(2);
-+ if (*emitsReadingsUpdate)
-+ {
-+ redfishReportActions.emplace_back("RedfishEvent");
-+ }
-+ if (*logToMetricReportsCollection)
-+ {
-+ redfishReportActions.emplace_back("LogToMetricReportsCollection");
-+ }
-+
-+ nlohmann::json metrics = nlohmann::json::array();
-+ for (auto& [sensorPaths, operationType, id, metadata] : *readingParams)
-+ {
-+ nlohmann::json metadataJson = nlohmann::json::parse(metadata);
-+ metrics.push_back({
-+ {"MetricId", id},
-+ {"MetricProperties", metadataJson.contains("MetricProperties")
-+ ? metadataJson["MetricProperties"]
-+ : nlohmann::json()},
-+ });
-+ }
-+ asyncResp->res.jsonValue["Metrics"] = metrics;
-+ asyncResp->res.jsonValue["MetricReportDefinitionType"] = *reportingType;
-+ asyncResp->res.jsonValue["ReportActions"] = redfishReportActions;
-+ asyncResp->res.jsonValue["Schedule"]["RecurrenceInterval"] =
-+ time_utils::toDurationString(std::chrono::milliseconds(*interval));
-+ }
-+
-+ static constexpr const char* schemaType =
-+ "#MetricReportDefinition.v1_3_0.MetricReportDefinition";
-+};
-+} // namespace redfish
-diff --git a/redfish-core/lib/service_root.hpp b/redfish-core/lib/service_root.hpp
-index 629280c..3df5ec5 100644
---- a/redfish-core/lib/service_root.hpp
-+++ b/redfish-core/lib/service_root.hpp
-@@ -68,6 +68,8 @@ class ServiceRoot : public Node
- res.jsonValue["Tasks"] = {{"@odata.id", "/redfish/v1/TaskService"}};
- res.jsonValue["EventService"] = {
- {"@odata.id", "/redfish/v1/EventService"}};
-+ res.jsonValue["TelemetryService"] = {
-+ {"@odata.id", "/redfish/v1/TelemetryService"}};
- res.end();
- }
-
-diff --git a/redfish-core/lib/telemetry_service.hpp b/redfish-core/lib/telemetry_service.hpp
-new file mode 100644
-index 0000000..a6acc34
---- /dev/null
-+++ b/redfish-core/lib/telemetry_service.hpp
-@@ -0,0 +1,93 @@
-+#pragma once
-+
-+#include "node.hpp"
-+#include "utils/telemetry_utils.hpp"
-+
-+#include <variant>
-+
-+namespace redfish
-+{
-+
-+class TelemetryService : public Node
-+{
-+ public:
-+ TelemetryService(App& app) : Node(app, "/redfish/v1/TelemetryService/")
-+ {
-+ 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&,
-+ const std::vector<std::string>&) override
-+ {
-+ res.jsonValue["@odata.type"] =
-+ "#TelemetryService.v1_2_1.TelemetryService";
-+ res.jsonValue["@odata.id"] = "/redfish/v1/TelemetryService";
-+ res.jsonValue["Id"] = "TelemetryService";
-+ res.jsonValue["Name"] = "Telemetry Service";
-+
-+ res.jsonValue["LogService"]["@odata.id"] =
-+ "/redfish/v1/Managers/bmc/LogServices/Journal";
-+ res.jsonValue["MetricReportDefinitions"]["@odata.id"] =
-+ "/redfish/v1/TelemetryService/MetricReportDefinitions";
-+ res.jsonValue["MetricReports"]["@odata.id"] =
-+ "/redfish/v1/TelemetryService/MetricReports";
-+
-+ auto asyncResp = std::make_shared<AsyncResp>(res);
-+ crow::connections::systemBus->async_method_call(
-+ [asyncResp](
-+ const boost::system::error_code ec,
-+ const std::vector<std::pair<
-+ std::string, std::variant<uint32_t, uint64_t>>>& ret) {
-+ if (ec == boost::system::errc::host_unreachable)
-+ {
-+ asyncResp->res.jsonValue["Status"]["State"] = "Absent";
-+ return;
-+ }
-+ if (ec)
-+ {
-+ BMCWEB_LOG_ERROR << "respHandler DBus error " << ec;
-+ messages::internalError(asyncResp->res);
-+ return;
-+ }
-+
-+ asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
-+
-+ const size_t* maxReports = nullptr;
-+ const uint64_t* minInterval = nullptr;
-+ for (const auto& [key, var] : ret)
-+ {
-+ if (key == "MaxReports")
-+ {
-+ maxReports = std::get_if<size_t>(&var);
-+ }
-+ else if (key == "MinInterval")
-+ {
-+ minInterval = std::get_if<uint64_t>(&var);
-+ }
-+ }
-+ if (!maxReports || !minInterval)
-+ {
-+ BMCWEB_LOG_ERROR
-+ << "Property type mismatch or property is missing";
-+ messages::internalError(asyncResp->res);
-+ return;
-+ }
-+
-+ asyncResp->res.jsonValue["MaxReports"] = *maxReports;
-+ asyncResp->res.jsonValue["MinCollectionInterval"] =
-+ time_utils::toDurationString(std::chrono::milliseconds(
-+ static_cast<time_t>(*minInterval)));
-+ },
-+ telemetry::service, "/xyz/openbmc_project/Telemetry/Reports",
-+ "org.freedesktop.DBus.Properties", "GetAll",
-+ "xyz.openbmc_project.Telemetry.ReportManager");
-+ }
-+};
-+} // namespace redfish
---
-2.17.1
-
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Add-POST-and-DELETE-in-MetricReportDefinitions.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Add-POST-and-DELETE-in-MetricReportDefinitions.patch
index f40058ad8..fd7e8a445 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Add-POST-and-DELETE-in-MetricReportDefinitions.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Add-POST-and-DELETE-in-MetricReportDefinitions.patch
@@ -1,7 +1,7 @@
-From 433358330c7f7d2fba99f6e488d67b314224317f Mon Sep 17 00:00:00 2001
+From bc1635622e122f307fb3b8eb9bbd66ea576a8f0c Mon Sep 17 00:00:00 2001
From: "Wludzik, Jozef" <jozef.wludzik@intel.com>
Date: Mon, 18 May 2020 11:56:57 +0200
-Subject: [PATCH] Add POST and DELETE in MetricReportDefinitions
+Subject: [PATCH 2/4] Add POST and DELETE in MetricReportDefinitions
Added POST action in MetricReportDefinitions node to allow user
to add new MetricReportDefinition. Using minimal set of
@@ -12,64 +12,62 @@ Added DELETE request in MetricReportDefinitions node to allow user
to remove report from Telemetry.
Added conversion from string that represents duration format into
its numeric equivalent.
+Added unit tests for conversion from and to Duration format.
Tested:
- - Succesfully passed RedfishServiceValidator.py
- - Validated good cases with different parameters for POST action
- - Validated bad cases with different parameters for POST action
- - Verified time_utils::fromDurationString()
+ - Tested using witherspoon image on QEMU
+ - Verified POST action in different cases:
+ - all parameters are provided, new report is added to collection
+ - some parameters are missing or invalid, user gets response with
+ description of the issue
- Verified that reports are removed on DELETE request
+ - Verified that on invalid DELETE request user receives response
+ with error
+ - Verified time_utils::fromDurationString()
+ - Succesfully passed RedfishServiceValidator.py
Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Change-Id: I2fed96848594451e22fde686f8c066d7770cc65a
---
- .../include/utils/telemetry_utils.hpp | 5 +-
- redfish-core/include/utils/time_utils.hpp | 145 ++++++-
- redfish-core/lib/metric_report_definition.hpp | 382 +++++++++++++++++-
- 3 files changed, 516 insertions(+), 16 deletions(-)
+ meson.build | 1 +
+ redfish-core/include/utils/time_utils.hpp | 138 ++++++++++-
+ redfish-core/lib/metric_report_definition.hpp | 328 ++++++++++++++++++++++++++
+ redfish-core/ut/time_utils_test.cpp | 63 +++++
+ 4 files changed, 528 insertions(+), 2 deletions(-)
+ create mode 100644 redfish-core/ut/time_utils_test.cpp
-diff --git a/redfish-core/include/utils/telemetry_utils.hpp b/redfish-core/include/utils/telemetry_utils.hpp
-index 8caee2d..acb739d 100644
---- a/redfish-core/include/utils/telemetry_utils.hpp
-+++ b/redfish-core/include/utils/telemetry_utils.hpp
-@@ -12,6 +12,8 @@ constexpr const char* metricReportDefinitionUri =
- "/redfish/v1/TelemetryService/MetricReportDefinitions/";
- constexpr const char* metricReportUri =
- "/redfish/v1/TelemetryService/MetricReports/";
-+constexpr const char* reportDir =
-+ "/xyz/openbmc_project/Telemetry/Reports/TelemetryService/";
+diff --git a/meson.build b/meson.build
+index 7a16e91..3d65b01 100644
+--- a/meson.build
++++ b/meson.build
+@@ -330,6 +330,7 @@ srcfiles_bmcweb = ['src/webserver_main.cpp','redfish-core/src/error_messages.cpp
+ srcfiles_unittest = ['include/ut/dbus_utility_test.cpp',
+ 'redfish-core/ut/privileges_test.cpp',
+ 'redfish-core/ut/lock_test.cpp',
++ 'redfish-core/ut/time_utils_test.cpp',
+ 'http/ut/utility_test.cpp']
- inline void getReportCollection(const std::shared_ptr<AsyncResp>& asyncResp,
- const std::string& uri)
-@@ -61,8 +63,7 @@ inline void getReportCollection(const std::shared_ptr<AsyncResp>& asyncResp,
-
- inline std::string getDbusReportPath(const std::string& id)
- {
-- std::string path =
-- "/xyz/openbmc_project/Telemetry/Reports/TelemetryService/" + id;
-+ std::string path = reportDir + id;
- dbus::utility::escapePathForDbus(path);
- return path;
- }
+ # Gather the Configuration data
diff --git a/redfish-core/include/utils/time_utils.hpp b/redfish-core/include/utils/time_utils.hpp
-index dd4ea75..d8985ab 100644
+index dd4ea75..e94801b 100644
--- a/redfish-core/include/utils/time_utils.hpp
+++ b/redfish-core/include/utils/time_utils.hpp
-@@ -1,7 +1,12 @@
+@@ -1,7 +1,13 @@
#pragma once
+#include "logging.hpp"
+
+#include <charconv>
#include <chrono>
++#include <cmath>
+#include <optional>
#include <string>
+#include <system_error>
namespace redfish
{
-@@ -12,6 +17,8 @@ namespace time_utils
+@@ -12,6 +18,8 @@ namespace time_utils
namespace details
{
@@ -78,32 +76,12 @@ index dd4ea75..d8985ab 100644
inline void leftZeroPadding(std::string& str, const std::size_t padding)
{
if (str.size() < padding)
-@@ -19,8 +26,143 @@ inline void leftZeroPadding(std::string& str, const std::size_t padding)
+@@ -19,8 +27,135 @@ inline void leftZeroPadding(std::string& str, const std::size_t padding)
str.insert(0, padding - str.size(), '0');
}
}
+
-+inline bool fromChars(const char* start, const char* end,
-+ std::chrono::milliseconds::rep& val)
-+{
-+ auto [ptr, ec] = std::from_chars(start, end, val);
-+ if (ptr != end)
-+ {
-+ BMCWEB_LOG_ERROR
-+ << "Failed to convert string to decimal because of unexpected sign";
-+ return false;
-+ }
-+ if (ec != std::errc())
-+ {
-+ BMCWEB_LOG_ERROR << "Failed to convert string to decimal with err: "
-+ << static_cast<int>(ec) << "("
-+ << std::make_error_code(ec).message() << ")";
-+ return false;
-+ }
-+ return true;
-+}
-+
-+template <typename T>
++template <typename FromTime>
+bool fromDurationItem(std::string_view& fmt, const char postfix,
+ std::chrono::milliseconds& out)
+{
@@ -117,31 +95,43 @@ index dd4ea75..d8985ab 100644
+ return false;
+ }
+
-+ std::chrono::milliseconds::rep v = 0;
-+ if constexpr (std::is_same_v<T, std::chrono::milliseconds>)
++ const char* end;
++ std::chrono::milliseconds::rep ticks = 0;
++ if constexpr (std::is_same_v<FromTime, std::chrono::milliseconds>)
+ {
-+ std::string str(fmt.data(), std::min<size_t>(pos, 3U));
-+ while (str.size() < 3U)
-+ {
-+ str += '0';
-+ }
-+ if (!fromChars(str.data(), str.data() + str.size(), v))
-+ {
-+ return false;
-+ }
++ end = fmt.data() + std::min<size_t>(pos, 3U);
+ }
+ else
+ {
-+ if (!fromChars(fmt.data(), fmt.data() + pos, v))
-+ {
-+ return false;
-+ }
++ end = fmt.data() + pos;
+ }
+
-+ out += T(v);
-+ if (out < T(v) ||
-+ std::chrono::duration_cast<T>(std::chrono::milliseconds::max())
-+ .count() < v)
++ auto [ptr, ec] = std::from_chars(fmt.data(), end, ticks);
++ if (ptr != end || ec != std::errc())
++ {
++ BMCWEB_LOG_ERROR << "Failed to convert string to decimal with err: "
++ << static_cast<int>(ec) << "("
++ << std::make_error_code(ec).message() << "), ptr{"
++ << static_cast<const void*>(ptr) << "} != end{"
++ << static_cast<const void*>(end) << "})";
++ return false;
++ }
++
++ if constexpr (std::is_same_v<FromTime, std::chrono::milliseconds>)
++ {
++ ticks *= static_cast<std::chrono::milliseconds::rep>(
++ std::pow(10, 3 - std::min<size_t>(pos, 3U)));
++ }
++ if (ticks < 0)
++ {
++ return false;
++ }
++
++ out += FromTime(ticks);
++ const auto maxConversionRange =
++ std::chrono::duration_cast<FromTime>(std::chrono::milliseconds::max())
++ .count();
++ if (out < FromTime(ticks) || maxConversionRange < ticks)
+ {
+ return false;
+ }
@@ -222,7 +212,7 @@ index dd4ea75..d8985ab 100644
/**
* @brief Convert time value into duration format that is based on ISO 8601.
* Example output: "P12DT1M5.5S"
-@@ -36,8 +178,7 @@ std::string toDurationString(std::chrono::milliseconds ms)
+@@ -36,8 +171,7 @@ std::string toDurationString(std::chrono::milliseconds ms)
std::string fmt;
fmt.reserve(sizeof("PxxxxxxxxxxxxDTxxHxxMxx.xxxxxxS"));
@@ -233,10 +223,10 @@ index dd4ea75..d8985ab 100644
std::chrono::hours hours = std::chrono::floor<std::chrono::hours>(ms);
diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp
-index 48c56e6..d5a540d 100644
+index 59025d9..fcbc99c 100644
--- a/redfish-core/lib/metric_report_definition.hpp
+++ b/redfish-core/lib/metric_report_definition.hpp
-@@ -1,15 +1,26 @@
+@@ -1,9 +1,12 @@
#pragma once
#include "node.hpp"
@@ -249,394 +239,311 @@ index 48c56e6..d5a540d 100644
#include <tuple>
#include <variant>
- namespace redfish
- {
-
-+namespace telemetry
-+{
-+
-+using ReadingParameters =
-+ std::vector<std::tuple<std::vector<sdbusplus::message::object_path>,
-+ std::string, std::string, std::string>>;
-+} // namespace telemetry
-+
- class MetricReportDefinitionCollection : public Node
- {
- public:
-@@ -39,6 +50,318 @@ class MetricReportDefinitionCollection : public Node
- telemetry::getReportCollection(asyncResp,
- telemetry::metricReportDefinitionUri);
- }
-+
-+ struct AddReportArgs
-+ {
-+ std::string name;
-+ std::string reportingType;
-+ bool emitsReadingsUpdate = false;
-+ bool logToMetricReportsCollection = false;
-+ uint64_t interval = 0;
-+ std::vector<std::pair<std::string, std::vector<std::string>>> metrics;
-+ };
+@@ -95,6 +98,252 @@ inline void fillReportDefinition(
+ asyncResp->res.jsonValue["Schedule"]["RecurrenceInterval"] =
+ time_utils::toDurationString(std::chrono::milliseconds(*interval));
+ }
+
-+ void doPost(crow::Response& res, const crow::Request& req,
-+ const std::vector<std::string>&) override
++struct AddReportArgs
++{
++ std::string name;
++ std::string reportingType;
++ bool emitsReadingsUpdate = false;
++ bool logToMetricReportsCollection = false;
++ uint64_t interval = 0;
++ std::vector<std::pair<std::string, std::vector<std::string>>> metrics;
++};
++
++inline bool toDbusReportActions(crow::Response& res,
++ std::vector<std::string>& actions,
++ AddReportArgs& args)
++{
++ size_t index = 0;
++ for (auto& action : actions)
+ {
-+ auto asyncResp = std::make_shared<AsyncResp>(res);
-+ AddReportArgs args;
-+ if (!getUserParameters(res, req, args))
++ if (action == "RedfishEvent")
+ {
-+ return;
++ args.emitsReadingsUpdate = true;
+ }
-+
-+ boost::container::flat_set<std::pair<std::string, std::string>>
-+ chassisSensors;
-+ if (!getChassisSensorNode(asyncResp, args.metrics, chassisSensors))
++ else if (action == "LogToMetricReportsCollection")
+ {
-+ return;
++ args.logToMetricReportsCollection = true;
+ }
-+
-+ auto addReportReq =
-+ std::make_shared<AddReport>(std::move(args), asyncResp);
-+ for (const auto& [chassis, sensorType] : chassisSensors)
++ else
+ {
-+ retrieveUriToDbusMap(
-+ chassis, sensorType,
-+ [asyncResp, addReportReq](
-+ const boost::beast::http::status status,
-+ const boost::container::flat_map<std::string, std::string>&
-+ uriToDbus) {
-+ if (status != boost::beast::http::status::ok)
-+ {
-+ BMCWEB_LOG_ERROR << "Failed to retrieve URI to dbus "
-+ "sensors map with err "
-+ << static_cast<unsigned>(status);
-+ messages::internalError(asyncResp->res);
-+ return;
-+ }
-+ addReportReq->insert(uriToDbus);
-+ });
++ messages::propertyValueNotInList(
++ res, action, "ReportActions/" + std::to_string(index));
++ return false;
+ }
++ index++;
+ }
++ return true;
++}
+
-+ static bool toDbusReportActions(crow::Response& res,
-+ std::vector<std::string>& actions,
-+ AddReportArgs& args)
++inline bool getUserParameters(crow::Response& res, const crow::Request& req,
++ AddReportArgs& args)
++{
++ std::vector<nlohmann::json> metrics;
++ std::vector<std::string> reportActions;
++ std::optional<nlohmann::json> schedule;
++ if (!json_util::readJson(req, res, "Id", args.name, "Metrics", metrics,
++ "MetricReportDefinitionType", args.reportingType,
++ "ReportActions", reportActions, "Schedule",
++ schedule))
+ {
-+ size_t index = 0;
-+ for (auto& action : actions)
-+ {
-+ if (action == "RedfishEvent")
-+ {
-+ args.emitsReadingsUpdate = true;
-+ }
-+ else if (action == "LogToMetricReportsCollection")
-+ {
-+ args.logToMetricReportsCollection = true;
-+ }
-+ else
-+ {
-+ messages::propertyValueNotInList(
-+ res, action, "ReportActions/" + std::to_string(index));
-+ return false;
-+ }
-+ index++;
-+ }
-+ return true;
++ return false;
++ }
++
++ constexpr const char* allowedCharactersInName =
++ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
++ if (args.name.empty() || args.name.find_first_not_of(
++ allowedCharactersInName) != std::string::npos)
++ {
++ BMCWEB_LOG_ERROR << "Failed to match " << args.name
++ << " with allowed character "
++ << allowedCharactersInName;
++ messages::propertyValueIncorrect(res, "Id", args.name);
++ return false;
++ }
++
++ if (args.reportingType != "Periodic" && args.reportingType != "OnRequest")
++ {
++ messages::propertyValueNotInList(res, args.reportingType,
++ "MetricReportDefinitionType");
++ return false;
+ }
+
-+ static bool getUserParameters(crow::Response& res, const crow::Request& req,
-+ AddReportArgs& args)
++ if (!toDbusReportActions(res, reportActions, args))
+ {
-+ std::vector<nlohmann::json> metrics;
-+ std::vector<std::string> reportActions;
-+ std::optional<nlohmann::json> schedule;
-+ if (!json_util::readJson(req, res, "Id", args.name, "Metrics", metrics,
-+ "MetricReportDefinitionType",
-+ args.reportingType, "ReportActions",
-+ reportActions, "Schedule", schedule))
++ return false;
++ }
++
++ if (args.reportingType == "Periodic")
++ {
++ if (!schedule)
+ {
++ messages::createFailedMissingReqProperties(res, "Schedule");
+ return false;
+ }
+
-+ constexpr const char* allowedCharactersInName =
-+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
-+ if (args.name.empty() ||
-+ args.name.find_first_not_of(allowedCharactersInName) !=
-+ std::string::npos)
++ std::string durationStr;
++ if (!json_util::readJson(*schedule, res, "RecurrenceInterval",
++ durationStr))
+ {
-+ BMCWEB_LOG_ERROR << "Failed to match " << args.name
-+ << " with allowed character "
-+ << allowedCharactersInName;
-+ messages::propertyValueIncorrect(res, "Id", args.name);
+ return false;
+ }
+
-+ if (args.reportingType != "Periodic" &&
-+ args.reportingType != "OnRequest")
++ std::optional<std::chrono::milliseconds> durationNum =
++ time_utils::fromDurationString(durationStr);
++ if (!durationNum)
+ {
-+ messages::propertyValueNotInList(res, args.reportingType,
-+ "MetricReportDefinitionType");
++ messages::propertyValueIncorrect(res, "RecurrenceInterval",
++ durationStr);
+ return false;
+ }
++ args.interval = static_cast<uint64_t>(durationNum->count());
++ }
+
-+ if (!toDbusReportActions(res, reportActions, args))
++ args.metrics.reserve(metrics.size());
++ for (auto& m : metrics)
++ {
++ std::string id;
++ std::vector<std::string> uris;
++ if (!json_util::readJson(m, res, "MetricId", id, "MetricProperties",
++ uris))
+ {
+ return false;
+ }
+
-+ if (args.reportingType == "Periodic")
++ args.metrics.emplace_back(std::move(id), std::move(uris));
++ }
++
++ return true;
++}
++
++inline bool getChassisSensorNode(
++ const std::shared_ptr<AsyncResp>& asyncResp,
++ const std::vector<std::pair<std::string, std::vector<std::string>>>&
++ metrics,
++ boost::container::flat_set<std::pair<std::string, std::string>>& matched)
++{
++ for (const auto& [id, uris] : metrics)
++ {
++ for (size_t i = 0; i < uris.size(); i++)
+ {
-+ if (!schedule)
-+ {
-+ messages::createFailedMissingReqProperties(res, "Schedule");
-+ return false;
-+ }
++ const std::string& uri = uris[i];
++ std::string chassis;
++ std::string node;
+
-+ std::string durationStr;
-+ if (!json_util::readJson(*schedule, res, "RecurrenceInterval",
-+ durationStr))
++ if (!boost::starts_with(uri, "/redfish/v1/Chassis/") ||
++ !dbus::utility::getNthStringFromPath(uri, 3, chassis) ||
++ !dbus::utility::getNthStringFromPath(uri, 4, node))
+ {
++ BMCWEB_LOG_ERROR << "Failed to get chassis and sensor Node "
++ "from "
++ << uri;
++ messages::propertyValueIncorrect(asyncResp->res, uri,
++ "MetricProperties/" +
++ std::to_string(i));
+ return false;
+ }
+
-+ std::optional<std::chrono::milliseconds> durationNum =
-+ time_utils::fromDurationString(durationStr);
-+ if (!durationNum)
++ if (boost::ends_with(node, "#"))
+ {
-+ messages::propertyValueIncorrect(res, "RecurrenceInterval",
-+ durationStr);
-+ return false;
++ node.pop_back();
+ }
-+ args.interval = static_cast<uint64_t>(durationNum->count());
++
++ matched.emplace(std::move(chassis), std::move(node));
+ }
++ }
++ return true;
++}
+
-+ args.metrics.reserve(metrics.size());
-+ for (auto& m : metrics)
++class AddReport
++{
++ public:
++ AddReport(AddReportArgs argsIn, std::shared_ptr<AsyncResp> asyncResp) :
++ asyncResp{std::move(asyncResp)}, args{std::move(argsIn)}
++ {}
++ ~AddReport()
++ {
++ if (asyncResp->res.result() != boost::beast::http::status::ok)
+ {
-+ std::string id;
-+ std::vector<std::string> uris;
-+ if (!json_util::readJson(m, res, "MetricId", id, "MetricProperties",
-+ uris))
-+ {
-+ return false;
-+ }
-+
-+ args.metrics.emplace_back(std::move(id), std::move(uris));
++ return;
+ }
+
-+ return true;
-+ }
++ telemetry::ReadingParameters readingParams;
++ readingParams.reserve(args.metrics.size());
+
-+ static bool getChassisSensorNode(
-+ const std::shared_ptr<AsyncResp>& asyncResp,
-+ const std::vector<std::pair<std::string, std::vector<std::string>>>&
-+ metrics,
-+ boost::container::flat_set<std::pair<std::string, std::string>>&
-+ matched)
-+ {
-+ for (const auto& [id, uris] : metrics)
++ for (const auto& [id, uris] : args.metrics)
+ {
+ for (size_t i = 0; i < uris.size(); i++)
+ {
+ const std::string& uri = uris[i];
-+ std::string chassis;
-+ std::string node;
-+
-+ if (!boost::starts_with(uri, "/redfish/v1/Chassis/") ||
-+ !dbus::utility::getNthStringFromPath(uri, 3, chassis) ||
-+ !dbus::utility::getNthStringFromPath(uri, 4, node))
++ auto el = uriToDbus.find(uri);
++ if (el == uriToDbus.end())
+ {
-+ BMCWEB_LOG_ERROR << "Failed to get chassis and sensor Node "
-+ "from "
++ BMCWEB_LOG_ERROR << "Failed to find DBus sensor "
++ "corresponding to URI "
+ << uri;
-+ messages::propertyValueIncorrect(asyncResp->res, uri,
++ messages::propertyValueNotInList(asyncResp->res, uri,
+ "MetricProperties/" +
+ std::to_string(i));
-+ return false;
-+ }
-+
-+ if (boost::ends_with(node, "#"))
-+ {
-+ node.pop_back();
++ return;
+ }
+
-+ matched.emplace(std::move(chassis), std::move(node));
++ const std::string& dbusPath = el->second;
++ readingParams.emplace_back(dbusPath, "SINGLE", id, uri);
+ }
+ }
-+ return true;
-+ }
-+
-+ class AddReport
-+ {
-+ public:
-+ AddReport(AddReportArgs argsIn, std::shared_ptr<AsyncResp> asyncResp) :
-+ asyncResp{std::move(asyncResp)}, args{std::move(argsIn)}
-+ {}
-+ ~AddReport()
-+ {
-+ if (asyncResp->res.result() != boost::beast::http::status::ok)
-+ {
-+ return;
-+ }
-+
-+ telemetry::ReadingParameters readingParams;
-+ readingParams.reserve(args.metrics.size());
+
-+ for (const auto& [id, uris] : args.metrics)
-+ {
-+ std::vector<sdbusplus::message::object_path> dbusPaths;
-+ dbusPaths.reserve(uris.size());
-+
-+ for (size_t i = 0; i < uris.size(); i++)
++ crow::connections::systemBus->async_method_call(
++ [asyncResp = std::move(asyncResp), name = args.name,
++ uriToDbus = std::move(uriToDbus)](
++ const boost::system::error_code ec, const std::string&) {
++ if (ec == boost::system::errc::file_exists)
++ {
++ messages::resourceAlreadyExists(
++ asyncResp->res, "MetricReportDefinition", "Id", name);
++ return;
++ }
++ if (ec == boost::system::errc::too_many_files_open)
+ {
-+ const std::string& uri = uris[i];
-+ auto el = uriToDbus.find(uri);
-+ if (el == uriToDbus.end())
++ messages::createLimitReachedForResource(asyncResp->res);
++ return;
++ }
++ if (ec == boost::system::errc::argument_list_too_long)
++ {
++ nlohmann::json metricProperties = nlohmann::json::array();
++ for (const auto& [uri, _] : uriToDbus)
+ {
-+ BMCWEB_LOG_ERROR << "Failed to find DBus sensor "
-+ "corresponding to URI "
-+ << uri;
-+ messages::propertyValueNotInList(asyncResp->res, uri,
-+ "MetricProperties/" +
-+ std::to_string(i));
-+ return;
++ metricProperties.emplace_back(uri);
+ }
-+
-+ dbusPaths.emplace_back(el->second);
++ messages::propertyValueIncorrect(
++ asyncResp->res, metricProperties, "MetricProperties");
++ return;
+ }
-+
-+ nlohmann::json metadata;
-+ metadata["MetricProperties"] = uris;
-+ if (uris.size() == 1)
++ if (ec)
+ {
-+ metadata["MetricProperty"] = uris[0];
++ messages::internalError(asyncResp->res);
++ BMCWEB_LOG_ERROR << "respHandler DBus error " << ec;
++ return;
+ }
-+ readingParams.emplace_back(std::move(dbusPaths), "SINGLE", id,
-+ metadata.dump());
-+ }
+
-+ crow::connections::systemBus->async_method_call(
-+ [asyncResp = asyncResp, name = args.name](
-+ const boost::system::error_code ec, const std::string&) {
-+ if (ec == boost::system::errc::file_exists)
-+ {
-+ messages::resourceAlreadyExists(
-+ asyncResp->res, "MetricReportDefinition", "Id",
-+ name);
-+ return;
-+ }
-+ if (ec == boost::system::errc::too_many_files_open)
-+ {
-+ messages::createLimitReachedForResource(asyncResp->res);
-+ return;
-+ }
-+ if (ec == boost::system::errc::argument_list_too_long)
-+ {
-+ messages::propertyValueNotInList(
-+ asyncResp->res, "/Exceeds supported size/",
-+ "Metrics");
-+ return;
-+ }
-+ if (ec == boost::system::errc::not_supported)
-+ {
-+ messages::propertyValueNotInList(
-+ asyncResp->res,
-+ "/Only single property per metric is supported/",
-+ "MetricProperties");
-+ return;
-+ }
-+ if (ec == boost::system::errc::invalid_argument)
-+ {
-+ messages::propertyValueNotInList(
-+ asyncResp->res, "/Less then MinInterval/",
-+ "RecurrenceInterval");
-+ return;
-+ }
-+ if (ec)
-+ {
-+ messages::internalError(asyncResp->res);
-+ BMCWEB_LOG_ERROR << "respHandler DBus error " << ec;
-+ return;
-+ }
++ messages::created(asyncResp->res);
++ },
++ telemetry::service, "/xyz/openbmc_project/Telemetry/Reports",
++ "xyz.openbmc_project.Telemetry.ReportManager", "AddReport",
++ "TelemetryService/" + args.name, args.reportingType,
++ args.emitsReadingsUpdate, args.logToMetricReportsCollection,
++ args.interval, readingParams);
++ }
++
++ void insert(const boost::container::flat_map<std::string, std::string>& el)
++ {
++ uriToDbus.insert(el.begin(), el.end());
++ }
+
-+ messages::created(asyncResp->res);
-+ },
-+ telemetry::service, "/xyz/openbmc_project/Telemetry/Reports",
-+ "xyz.openbmc_project.Telemetry.ReportManager", "AddReport",
-+ "TelemetryService/" + args.name, args.reportingType,
-+ args.emitsReadingsUpdate, args.logToMetricReportsCollection,
-+ args.interval, readingParams);
++ private:
++ std::shared_ptr<AsyncResp> asyncResp;
++ AddReportArgs args;
++ boost::container::flat_map<std::string, std::string> uriToDbus{};
++};
+ } // namespace telemetry
+
+ class MetricReportDefinitionCollection : public Node
+@@ -126,6 +375,46 @@ class MetricReportDefinitionCollection : public Node
+ telemetry::getReportCollection(asyncResp,
+ telemetry::metricReportDefinitionUri);
+ }
++
++ void doPost(crow::Response& res, const crow::Request& req,
++ const std::vector<std::string>&) override
++ {
++ auto asyncResp = std::make_shared<AsyncResp>(res);
++ telemetry::AddReportArgs args;
++ if (!telemetry::getUserParameters(res, req, args))
++ {
++ return;
+ }
+
-+ void insert(
-+ const boost::container::flat_map<std::string, std::string>& el)
++ boost::container::flat_set<std::pair<std::string, std::string>>
++ chassisSensors;
++ if (!telemetry::getChassisSensorNode(asyncResp, args.metrics,
++ chassisSensors))
+ {
-+ uriToDbus.insert(el.begin(), el.end());
++ return;
+ }
+
-+ private:
-+ std::shared_ptr<AsyncResp> asyncResp;
-+ AddReportArgs args;
-+ boost::container::flat_map<std::string, std::string> uriToDbus{};
-+ };
++ auto addReportReq =
++ std::make_shared<telemetry::AddReport>(std::move(args), asyncResp);
++ for (const auto& [chassis, sensorType] : chassisSensors)
++ {
++ retrieveUriToDbusMap(
++ chassis, sensorType,
++ [asyncResp, addReportReq](
++ const boost::beast::http::status status,
++ const boost::container::flat_map<std::string, std::string>&
++ uriToDbus) {
++ if (status != boost::beast::http::status::ok)
++ {
++ BMCWEB_LOG_ERROR << "Failed to retrieve URI to dbus "
++ "sensors map with err "
++ << static_cast<unsigned>(status);
++ return;
++ }
++ addReportReq->insert(uriToDbus);
++ });
++ }
++ }
};
class MetricReportDefinition : public Node
-@@ -73,9 +396,10 @@ class MetricReportDefinition : public Node
- crow::connections::systemBus->async_method_call(
- [asyncResp,
- id](const boost::system::error_code ec,
-- const std::vector<std::pair<
-- std::string, std::variant<bool, ReadingParameters,
-- std::string, uint64_t>>>& ret) {
-+ const std::vector<
-+ std::pair<std::string,
-+ std::variant<bool, telemetry::ReadingParameters,
-+ std::string, uint64_t>>>& ret) {
- if (ec.value() == EBADR)
- {
- messages::resourceNotFound(asyncResp->res, schemaType, id);
-@@ -95,15 +419,11 @@ class MetricReportDefinition : public Node
+@@ -184,5 +473,44 @@ class MetricReportDefinition : public Node
+ "org.freedesktop.DBus.Properties", "GetAll",
telemetry::reportInterface);
}
-
-- using ReadingParameters =
-- std::vector<std::tuple<std::vector<sdbusplus::message::object_path>,
-- std::string, std::string, std::string>>;
--
- static void fillReportDefinition(
- const std::shared_ptr<AsyncResp>& asyncResp, const std::string& id,
-- const std::vector<
-- std::pair<std::string, std::variant<bool, ReadingParameters,
-- std::string, uint64_t>>>& ret)
-+ const std::vector<std::pair<
-+ std::string, std::variant<bool, telemetry::ReadingParameters,
-+ std::string, uint64_t>>>& ret)
- {
- asyncResp->res.jsonValue["@odata.type"] = schemaType;
- asyncResp->res.jsonValue["@odata.id"] =
-@@ -117,7 +437,7 @@ class MetricReportDefinition : public Node
-
- const bool* emitsReadingsUpdate = nullptr;
- const bool* logToMetricReportsCollection = nullptr;
-- const ReadingParameters* readingParams = nullptr;
-+ const telemetry::ReadingParameters* readingParams = nullptr;
- const std::string* reportingType = nullptr;
- const uint64_t* interval = nullptr;
- for (const auto& [key, var] : ret)
-@@ -132,7 +452,7 @@ class MetricReportDefinition : public Node
- }
- else if (key == "ReadingParameters")
- {
-- readingParams = std::get_if<ReadingParameters>(&var);
-+ readingParams = std::get_if<telemetry::ReadingParameters>(&var);
- }
- else if (key == "ReportingType")
- {
-@@ -180,6 +500,44 @@ class MetricReportDefinition : public Node
- time_utils::toDurationString(std::chrono::milliseconds(*interval));
- }
-
++
+ void doDelete(crow::Response& res, const crow::Request&,
+ const std::vector<std::string>& params) override
+ {
@@ -658,7 +565,8 @@ index 48c56e6..d5a540d 100644
+ */
+ if (ec.value() == EBADR)
+ {
-+ messages::resourceNotFound(asyncResp->res, schemaType, id);
++ messages::resourceNotFound(asyncResp->res,
++ "MetricReportDefinition", id);
+ return;
+ }
+
@@ -674,10 +582,77 @@ index 48c56e6..d5a540d 100644
+ telemetry::service, reportPath, "xyz.openbmc_project.Object.Delete",
+ "Delete");
+ }
-+
- static constexpr const char* schemaType =
- "#MetricReportDefinition.v1_3_0.MetricReportDefinition";
};
+ } // namespace redfish
+diff --git a/redfish-core/ut/time_utils_test.cpp b/redfish-core/ut/time_utils_test.cpp
+new file mode 100644
+index 0000000..70999ce
+--- /dev/null
++++ b/redfish-core/ut/time_utils_test.cpp
+@@ -0,0 +1,63 @@
++#include "utils/time_utils.hpp"
++
++#include <gmock/gmock.h>
++
++using namespace testing;
++
++class FromDurationTest :
++ public Test,
++ public WithParamInterface<
++ std::pair<std::string, std::optional<std::chrono::milliseconds>>>
++{};
++
++INSTANTIATE_TEST_SUITE_P(
++ _, FromDurationTest,
++ Values(std::make_pair("PT12S", std::chrono::milliseconds(12000)),
++ std::make_pair("PT0.204S", std::chrono::milliseconds(204)),
++ std::make_pair("PT0.2S", std::chrono::milliseconds(200)),
++ std::make_pair("PT50M", std::chrono::milliseconds(3000000)),
++ std::make_pair("PT23H", std::chrono::milliseconds(82800000)),
++ std::make_pair("P51D", std::chrono::milliseconds(4406400000)),
++ std::make_pair("PT2H40M10.1S", std::chrono::milliseconds(9610100)),
++ std::make_pair("P20DT2H40M10.1S",
++ std::chrono::milliseconds(1737610100)),
++ std::make_pair("", std::chrono::milliseconds(0)),
++ std::make_pair("PTS", std::nullopt),
++ std::make_pair("P1T", std::nullopt),
++ std::make_pair("PT100M1000S100", std::nullopt),
++ std::make_pair("PDTHMS", std::nullopt),
++ std::make_pair("P99999999999999999DT", std::nullopt),
++ std::make_pair("PD222T222H222M222.222S", std::nullopt),
++ std::make_pair("PT99999H9999999999999999999999M99999999999S",
++ std::nullopt),
++ std::make_pair("PT-9H", std::nullopt)));
++
++TEST_P(FromDurationTest, convertToMilliseconds)
++{
++ const auto& [str, expected] = GetParam();
++ EXPECT_THAT(redfish::time_utils::fromDurationString(str), Eq(expected));
++}
++
++class ToDurationTest :
++ public Test,
++ public WithParamInterface<std::pair<std::chrono::milliseconds, std::string>>
++{};
++
++INSTANTIATE_TEST_SUITE_P(
++ _, ToDurationTest,
++ Values(std::make_pair(std::chrono::milliseconds(12000), "PT12.000S"),
++ std::make_pair(std::chrono::milliseconds(204), "PT0.204S"),
++ std::make_pair(std::chrono::milliseconds(200), "PT0.200S"),
++ std::make_pair(std::chrono::milliseconds(3000000), "PT50M"),
++ std::make_pair(std::chrono::milliseconds(82800000), "PT23H"),
++ std::make_pair(std::chrono::milliseconds(4406400000), "P51DT"),
++ std::make_pair(std::chrono::milliseconds(9610100), "PT2H40M10.100S"),
++ std::make_pair(std::chrono::milliseconds(1737610100),
++ "P20DT2H40M10.100S"),
++ std::make_pair(std::chrono::milliseconds(-250), "")));
++
++TEST_P(ToDurationTest, convertToDuration)
++{
++ const auto& [ms, expected] = GetParam();
++ EXPECT_THAT(redfish::time_utils::toDurationString(ms), Eq(expected));
++}
--
-2.17.1
+2.16.6
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Add-support-for-MetricDefinition-scheme.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Add-support-for-MetricDefinition-scheme.patch
index 7c3e4c804..99af0ab86 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Add-support-for-MetricDefinition-scheme.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Add-support-for-MetricDefinition-scheme.patch
@@ -1,35 +1,41 @@
-From d9016c8064f5732fb6d24d07a990ddfa294a8a9d Mon Sep 17 00:00:00 2001
+From 462b2e814698e12a18b4956eb3c6421c34a3a4ba Mon Sep 17 00:00:00 2001
From: "Wludzik, Jozef" <jozef.wludzik@intel.com>
-Date: Mon, 8 Jun 2020 17:15:54 +0200
-Subject: [PATCH] Add support for MetricDefinition scheme
+Date: Tue, 15 Dec 2020 12:28:17 +0100
+Subject: [PATCH 3/4] Add support for MetricDefinition scheme
+
+Added MetricDefinition node to Redfish code. Now user is able
+to list all available metrics in OpenBMC that are supported
+by Telemetry service. Metrics are grouped by following
+categories: temperature, power, voltage, current, fan_tach,
+fan_pwm, utilization.
-Added MetricDefinition node to redfish core. Now user is able to
-get all possible metrics that are present in system and are
-supported by TelemetryService.
Added generic function to fill ReadingUnits and ReadingType
-in Sensor scheme.
+in Sensor node.
Tested:
- - Succesfully passed RedfishServiceValidator.py
- - Validated a presence of MetricDefinition members
+ - MetricDefinitions response is filled with existing sensors,
+ it works with and without Telemetry service
+ - Validated a presence of MetricDefinition members and it
+ attributes
+ - Succesfully passed RedfishServiceValidator.py using
+ witherspoon image on QEMU
Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Change-Id: I3086e1302e1ba2e5442d1367939fd5507a0cbc00
---
- redfish-core/include/redfish.hpp | 3 +
- .../include/utils/telemetry_utils.hpp | 56 ++--
- redfish-core/lib/metric_definition.hpp | 269 ++++++++++++++++++
- redfish-core/lib/metric_report_definition.hpp | 22 ++
- redfish-core/lib/power.hpp | 4 +-
- redfish-core/lib/sensors.hpp | 96 +++++--
- redfish-core/lib/telemetry_service.hpp | 2 +
- redfish-core/lib/thermal.hpp | 4 +-
- 8 files changed, 406 insertions(+), 50 deletions(-)
+ redfish-core/include/redfish.hpp | 3 +
+ redfish-core/include/utils/telemetry_utils.hpp | 2 +
+ redfish-core/lib/metric_definition.hpp | 283 +++++++++++++++++++++++++
+ redfish-core/lib/power.hpp | 4 +-
+ redfish-core/lib/sensors.hpp | 85 ++++++--
+ redfish-core/lib/telemetry_service.hpp | 2 +
+ redfish-core/lib/thermal.hpp | 4 +-
+ 7 files changed, 361 insertions(+), 22 deletions(-)
create mode 100644 redfish-core/lib/metric_definition.hpp
diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp
-index b366e24..a938d43 100644
+index e94c0f3..83f2300 100644
--- a/redfish-core/include/redfish.hpp
+++ b/redfish-core/include/redfish.hpp
@@ -25,6 +25,7 @@
@@ -40,7 +46,7 @@ index b366e24..a938d43 100644
#include "../lib/metric_report.hpp"
#include "../lib/metric_report_definition.hpp"
#include "../lib/network_protocol.hpp"
-@@ -216,6 +217,8 @@ class RedfishService
+@@ -213,6 +214,8 @@ class RedfishService
nodes.emplace_back(std::make_unique<HypervisorSystem>(app));
nodes.emplace_back(std::make_unique<TelemetryService>(app));
@@ -50,7 +56,7 @@ index b366e24..a938d43 100644
std::make_unique<MetricReportDefinitionCollection>(app));
nodes.emplace_back(std::make_unique<MetricReportDefinition>(app));
diff --git a/redfish-core/include/utils/telemetry_utils.hpp b/redfish-core/include/utils/telemetry_utils.hpp
-index acb739d..c13a79b 100644
+index a3a8156..c1b7639 100644
--- a/redfish-core/include/utils/telemetry_utils.hpp
+++ b/redfish-core/include/utils/telemetry_utils.hpp
@@ -8,6 +8,8 @@ namespace telemetry
@@ -62,80 +68,12 @@ index acb739d..c13a79b 100644
constexpr const char* metricReportDefinitionUri =
"/redfish/v1/TelemetryService/MetricReportDefinitions/";
constexpr const char* metricReportUri =
-@@ -15,6 +17,36 @@ constexpr const char* metricReportUri =
- constexpr const char* reportDir =
- "/xyz/openbmc_project/Telemetry/Reports/TelemetryService/";
-
-+inline void dbusPathsToMembers(const std::shared_ptr<AsyncResp>& asyncResp,
-+ const std::vector<std::string>& paths,
-+ const std::string& uri)
-+{
-+ nlohmann::json& members = asyncResp->res.jsonValue["Members"];
-+ members = nlohmann::json::array();
-+
-+ for (const std::string& path : paths)
-+ {
-+ std::size_t pos = path.rfind('/');
-+ if (pos == std::string::npos)
-+ {
-+ BMCWEB_LOG_ERROR << "Failed to find '/' in " << path;
-+ messages::internalError(asyncResp->res);
-+ return;
-+ }
-+
-+ if (path.size() <= (pos + 1))
-+ {
-+ BMCWEB_LOG_ERROR << "Failed to parse path " << path;
-+ messages::internalError(asyncResp->res);
-+ return;
-+ }
-+
-+ members.push_back({{"@odata.id", uri + path.substr(pos + 1)}});
-+ }
-+
-+ asyncResp->res.jsonValue["Members@odata.count"] = members.size();
-+}
-+
- inline void getReportCollection(const std::shared_ptr<AsyncResp>& asyncResp,
- const std::string& uri)
- {
-@@ -30,29 +62,7 @@ inline void getReportCollection(const std::shared_ptr<AsyncResp>& asyncResp,
- return;
- }
-
-- nlohmann::json& members = asyncResp->res.jsonValue["Members"];
-- members = nlohmann::json::array();
--
-- for (const std::string& path : reportPaths)
-- {
-- std::size_t pos = path.rfind('/');
-- if (pos == std::string::npos)
-- {
-- BMCWEB_LOG_ERROR << "Failed to find '/' in " << path;
-- messages::internalError(asyncResp->res);
-- return;
-- }
-- if (path.size() <= (pos + 1))
-- {
-- BMCWEB_LOG_ERROR << "Failed to parse path " << path;
-- messages::internalError(asyncResp->res);
-- return;
-- }
--
-- members.push_back({{"@odata.id", uri + path.substr(pos + 1)}});
-- }
--
-- asyncResp->res.jsonValue["Members@odata.count"] = members.size();
-+ dbusPathsToMembers(asyncResp, reportPaths, uri);
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
diff --git a/redfish-core/lib/metric_definition.hpp b/redfish-core/lib/metric_definition.hpp
new file mode 100644
-index 0000000..f037ed2
+index 0000000..4a40af5
--- /dev/null
+++ b/redfish-core/lib/metric_definition.hpp
-@@ -0,0 +1,269 @@
+@@ -0,0 +1,283 @@
+#pragma once
+
+#include "node.hpp"
@@ -149,31 +87,36 @@ index 0000000..f037ed2
+{
+
+template <typename F>
-+inline void getChassisNames(F&& cb)
++inline void getChassisNames(F&& cb, const std::shared_ptr<AsyncResp>& asyncResp)
+{
+ const std::array<const char*, 2> interfaces = {
+ "xyz.openbmc_project.Inventory.Item.Board",
+ "xyz.openbmc_project.Inventory.Item.Chassis"};
+
+ crow::connections::systemBus->async_method_call(
-+ [callback = std::move(cb)](const boost::system::error_code ec,
-+ std::vector<std::string>& chassisList) {
++ [asyncResp,
++ callback = std::move(cb)](const boost::system::error_code ec,
++ std::vector<std::string>& chassises) {
+ if (ec)
+ {
++ messages::internalError(asyncResp->res);
+ BMCWEB_LOG_DEBUG << "DBus call error: " << ec.value();
+ return;
+ }
+
+ std::vector<std::string> chassisNames;
-+ chassisNames.reserve(chassisList.size());
-+ for (const std::string& chassisPath : chassisList)
++ chassisNames.reserve(chassises.size());
++ for (const std::string& chassis : chassises)
+ {
-+ size_t pos = chassisPath.rfind('/');
-+ if (pos == std::string::npos)
++ sdbusplus::message::object_path path(chassis);
++ std::string name = path.filename();
++ if (name.empty())
+ {
-+ continue;
++ messages::internalError(asyncResp->res);
++ BMCWEB_LOG_ERROR << "Invalid chassis: " << chassis;
++ return;
+ }
-+ chassisNames.push_back(chassisPath.substr(pos + 1));
++ chassisNames.push_back(name);
+ }
+
+ callback(chassisNames);
@@ -185,6 +128,109 @@ index 0000000..f037ed2
+}
+} // namespace utils
+
++namespace telemetry
++{
++
++class DefinitionCollectionReduce
++{
++ public:
++ DefinitionCollectionReduce(const std::shared_ptr<AsyncResp>& asyncResp) :
++ asyncResp{asyncResp}
++ {}
++
++ ~DefinitionCollectionReduce()
++ {
++ if (asyncResp->res.result() != boost::beast::http::status::ok)
++ {
++ return;
++ }
++
++ nlohmann::json& members = asyncResp->res.jsonValue["Members"];
++ members = nlohmann::json::array();
++
++ for (const std::string& type : dbusTypes)
++ {
++ members.push_back(
++ {{"@odata.id", telemetry::metricDefinitionUri + type}});
++ }
++ asyncResp->res.jsonValue["Members@odata.count"] = members.size();
++ }
++
++ void insert(const boost::container::flat_map<std::string, std::string>& el)
++ {
++ for (const auto& [_, dbusSensor] : el)
++ {
++ sdbusplus::message::object_path path(dbusSensor);
++ sdbusplus::message::object_path parentPath = path.parent_path();
++ std::string type = parentPath.filename();
++ if (type.empty())
++ {
++ BMCWEB_LOG_ERROR << "Received invalid DBus Sensor Path = "
++ << dbusSensor;
++ continue;
++ }
++
++ dbusTypes.insert(std::move(type));
++ }
++ }
++
++ private:
++ const std::shared_ptr<AsyncResp> asyncResp;
++ boost::container::flat_set<std::string> dbusTypes;
++};
++
++class DefinitionReduce
++{
++ public:
++ DefinitionReduce(const std::shared_ptr<AsyncResp>& asyncResp,
++ const std::string& id) :
++ id(id),
++ pattern{'/' + id + '/'}, asyncResp{asyncResp}
++ {}
++ ~DefinitionReduce()
++ {
++ if (asyncResp->res.result() != boost::beast::http::status::ok)
++ {
++ return;
++ }
++ if (redfishSensors.empty())
++ {
++ messages::resourceNotFound(asyncResp->res, "MetricDefinition", id);
++ return;
++ }
++
++ asyncResp->res.jsonValue["MetricProperties"] = redfishSensors;
++ asyncResp->res.jsonValue["Id"] = id;
++ asyncResp->res.jsonValue["Name"] = id;
++ asyncResp->res.jsonValue["@odata.id"] =
++ telemetry::metricDefinitionUri + id;
++ asyncResp->res.jsonValue["@odata.type"] =
++ "#MetricDefinition.v1_0_3.MetricDefinition";
++ asyncResp->res.jsonValue["MetricDataType"] = "Decimal";
++ asyncResp->res.jsonValue["MetricType"] = "Numeric";
++ asyncResp->res.jsonValue["IsLinear"] = true;
++ asyncResp->res.jsonValue["Units"] = sensors::toReadingUnits(id);
++ }
++
++ void insert(const boost::container::flat_map<std::string, std::string>& el)
++ {
++ for (const auto& [redfishSensor, dbusSensor] : el)
++ {
++ if (dbusSensor.find(pattern) != std::string::npos)
++ {
++ redfishSensors.push_back(redfishSensor);
++ }
++ }
++ }
++
++ private:
++ const std::string id;
++ const std::string pattern;
++ const std::shared_ptr<AsyncResp> asyncResp;
++ std::vector<std::string> redfishSensors;
++};
++} // namespace telemetry
++
+class MetricDefinitionCollection : public Node
+{
+ public:
@@ -213,7 +259,8 @@ index 0000000..f037ed2
+ res.jsonValue["Members@odata.count"] = 0;
+
+ auto asyncResp = std::make_shared<AsyncResp>(res);
-+ auto collectionReduce = std::make_shared<CollectionGather>(asyncResp);
++ auto collectionReduce =
++ std::make_shared<telemetry::DefinitionCollectionReduce>(asyncResp);
+ utils::getChassisNames(
+ [asyncResp,
+ collectionReduce](const std::vector<std::string>& chassisNames) {
@@ -242,50 +289,9 @@ index 0000000..f037ed2
+ });
+ }
+ }
-+ });
++ },
++ asyncResp);
+ }
-+
-+ class CollectionGather
-+ {
-+ public:
-+ CollectionGather(const std::shared_ptr<AsyncResp>& asyncResp) :
-+ asyncResp{asyncResp}
-+ {}
-+
-+ ~CollectionGather()
-+ {
-+ if (asyncResp->res.result() != boost::beast::http::status::ok)
-+ {
-+ return;
-+ }
-+
-+ telemetry::dbusPathsToMembers(
-+ asyncResp,
-+ std::vector<std::string>(dbusTypes.begin(), dbusTypes.end()),
-+ telemetry::metricDefinitionUri);
-+ }
-+
-+ void insert(
-+ const boost::container::flat_map<std::string, std::string>& el)
-+ {
-+ for (const auto& [_, dbusSensor] : el)
-+ {
-+ size_t pos = dbusSensor.rfind('/');
-+ if (pos == std::string::npos)
-+ {
-+ BMCWEB_LOG_ERROR << "Received invalid DBus Sensor Path = "
-+ << dbusSensor;
-+ continue;
-+ }
-+
-+ dbusTypes.insert(dbusSensor.substr(0, pos));
-+ }
-+ }
-+
-+ private:
-+ const std::shared_ptr<AsyncResp> asyncResp;
-+ boost::container::flat_set<std::string> dbusTypes;
-+ };
+};
+
+class MetricDefinition : public Node
@@ -317,7 +323,7 @@ index 0000000..f037ed2
+
+ const std::string& id = params[0];
+ auto definitionGather =
-+ std::make_shared<DefinitionGather>(asyncResp, id);
++ std::make_shared<telemetry::DefinitionReduce>(asyncResp, id);
+ utils::getChassisNames(
+ [asyncResp,
+ definitionGather](const std::vector<std::string>& chassisNames) {
@@ -345,113 +351,12 @@ index 0000000..f037ed2
+ });
+ }
+ }
-+ });
++ },
++ asyncResp);
+ }
-+
-+ class DefinitionGather
-+ {
-+ public:
-+ DefinitionGather(const std::shared_ptr<AsyncResp>& asyncResp,
-+ const std::string& id) :
-+ id(id),
-+ pattern{'/' + id + '/'}, asyncResp{asyncResp}
-+ {}
-+ ~DefinitionGather()
-+ {
-+ if (asyncResp->res.result() != boost::beast::http::status::ok)
-+ {
-+ return;
-+ }
-+ if (redfishSensors.empty())
-+ {
-+ messages::resourceNotFound(asyncResp->res, schemaType, id);
-+ return;
-+ }
-+
-+ asyncResp->res.jsonValue["MetricProperties"] = redfishSensors;
-+ asyncResp->res.jsonValue["Id"] = id;
-+ asyncResp->res.jsonValue["Name"] = id;
-+ asyncResp->res.jsonValue["@odata.id"] =
-+ telemetry::metricDefinitionUri + id;
-+ asyncResp->res.jsonValue["@odata.type"] = schemaType;
-+ asyncResp->res.jsonValue["MetricDataType"] = "Decimal";
-+ asyncResp->res.jsonValue["MetricType"] = "Numeric";
-+ asyncResp->res.jsonValue["IsLinear"] = true;
-+ asyncResp->res.jsonValue["Units"] = sensors::toReadingUnits(id);
-+ }
-+
-+ void insert(
-+ const boost::container::flat_map<std::string, std::string>& el)
-+ {
-+ for (const auto& [redfishSensor, dbusSensor] : el)
-+ {
-+ if (dbusSensor.find(pattern) != std::string::npos)
-+ {
-+ redfishSensors.push_back(redfishSensor);
-+ }
-+ }
-+ }
-+
-+ const std::string id;
-+ const std::string pattern;
-+
-+ private:
-+ const std::shared_ptr<AsyncResp> asyncResp;
-+ std::vector<std::string> redfishSensors;
-+ };
-+
-+ static constexpr const char* schemaType =
-+ "#MetricDefinition.v1_0_3.MetricDefinition";
+};
+
+} // namespace redfish
-diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp
-index d5a540d..03f0b82 100644
---- a/redfish-core/lib/metric_report_definition.hpp
-+++ b/redfish-core/lib/metric_report_definition.hpp
-@@ -269,6 +269,8 @@ class MetricReportDefinitionCollection : public Node
- {
- std::vector<sdbusplus::message::object_path> dbusPaths;
- dbusPaths.reserve(uris.size());
-+ std::string sensorType;
-+ bool invalidType = false;
-
- for (size_t i = 0; i < uris.size(); i++)
- {
-@@ -286,6 +288,21 @@ class MetricReportDefinitionCollection : public Node
- }
-
- dbusPaths.emplace_back(el->second);
-+
-+ if (invalidType)
-+ {
-+ continue;
-+ }
-+ std::string tmp;
-+ dbus::utility::getNthStringFromPath(el->second, 3, tmp);
-+ if (sensorType.empty())
-+ {
-+ sensorType = std::move(tmp);
-+ }
-+ else if (sensorType != tmp)
-+ {
-+ invalidType = true;
-+ }
- }
-
- nlohmann::json metadata;
-@@ -294,6 +311,11 @@ class MetricReportDefinitionCollection : public Node
- {
- metadata["MetricProperty"] = uris[0];
- }
-+ if (!sensorType.empty() && !invalidType)
-+ {
-+ metadata["MetricDefinition"]["@odata.id"] =
-+ telemetry::metricDefinitionUri + sensorType;
-+ }
- readingParams.emplace_back(std::move(dbusPaths), "SINGLE", id,
- metadata.dump());
- }
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index 1c7a009..99c45ef 100644
--- a/redfish-core/lib/power.hpp
@@ -475,7 +380,7 @@ index 1c7a009..99c45ef 100644
std::optional<std::vector<nlohmann::json>> voltageCollections;
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
-index 14c9593..bf97540 100644
+index 14c9593..5080f77 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -54,9 +54,10 @@ static constexpr std::string_view thermal = "Thermal";
@@ -555,46 +460,12 @@ index 14c9593..bf97540 100644
}
} // namespace sensors
-@@ -90,19 +149,20 @@ class SensorsAsyncResp
- };
-
- SensorsAsyncResp(crow::Response& response, const std::string& chassisIdIn,
-- const std::vector<const char*>& typesIn,
-+ const std::vector<const char*>& matchPathsIn,
- const std::string_view& subNode) :
- res(response),
-- chassisId(chassisIdIn), types(typesIn), chassisSubNode(subNode)
-+ chassisId(chassisIdIn), matchPaths(matchPathsIn),
-+ chassisSubNode(subNode)
- {}
-
- // Store extra data about sensor mapping and return it in callback
- SensorsAsyncResp(crow::Response& response, const std::string& chassisIdIn,
-- const std::vector<const char*>& typesIn,
-+ const std::vector<const char*>& matchPathsIn,
- const std::string_view& subNode,
- DataCompleteCb&& creationComplete) :
- res(response),
-- chassisId(chassisIdIn), types(typesIn),
-+ chassisId(chassisIdIn), matchPaths(matchPathsIn),
- chassisSubNode(subNode), metadata{std::vector<SensorData>()},
- dataComplete{std::move(creationComplete)}
- {}
-@@ -161,7 +221,7 @@ class SensorsAsyncResp
-
- crow::Response& res;
- const std::string chassisId;
-- const std::vector<const char*> types;
-+ const std::vector<const char*> matchPaths;
- const std::string chassisSubNode;
-
- private:
-@@ -345,11 +405,11 @@ inline void reduceSensorList(
+@@ -345,11 +404,11 @@ inline void reduceSensorList(
return;
}
- for (const char* type : sensorsAsyncResp->types)
-+ for (const char* path : sensorsAsyncResp->matchPaths)
++ for (const char* path : sensorsAsyncResp->types)
{
for (const std::string& sensor : *allSensors)
{
@@ -603,7 +474,7 @@ index 14c9593..bf97540 100644
{
activeSensors->emplace(sensor);
}
-@@ -853,18 +913,8 @@ inline void objectInterfacesToJson(
+@@ -853,18 +912,8 @@ inline void objectInterfacesToJson(
if (sensorsAsyncResp->chassisSubNode == sensors::node::sensors)
{
sensorJson["@odata.type"] = "#Sensor.v1_0_0.Sensor";
@@ -624,7 +495,7 @@ index 14c9593..bf97540 100644
}
else if (sensorType == "temperature")
{
-@@ -2976,8 +3026,8 @@ inline void retrieveUriToDbusMap(const std::string& chassis,
+@@ -2976,8 +3025,8 @@ inline void retrieveUriToDbusMap(const std::string& chassis,
const std::string& node,
SensorsAsyncResp::DataCompleteCb&& mapComplete)
{
@@ -635,7 +506,7 @@ index 14c9593..bf97540 100644
{
BMCWEB_LOG_ERROR << "Wrong node provided : " << node;
mapComplete(boost::beast::http::status::bad_request, {});
-@@ -3027,7 +3077,7 @@ class SensorCollection : public Node
+@@ -3027,7 +3076,7 @@ class SensorCollection : public Node
const std::string& chassisId = params[0];
std::shared_ptr<SensorsAsyncResp> asyncResp =
std::make_shared<SensorsAsyncResp>(
@@ -645,13 +516,13 @@ index 14c9593..bf97540 100644
auto getChassisCb =
diff --git a/redfish-core/lib/telemetry_service.hpp b/redfish-core/lib/telemetry_service.hpp
-index a6acc34..8105d86 100644
+index 61ca891..a8c8b03 100644
--- a/redfish-core/lib/telemetry_service.hpp
+++ b/redfish-core/lib/telemetry_service.hpp
-@@ -34,6 +34,8 @@ class TelemetryService : public Node
+@@ -32,6 +32,8 @@ class TelemetryService : public Node
+ res.jsonValue["Id"] = "TelemetryService";
+ res.jsonValue["Name"] = "Telemetry Service";
- res.jsonValue["LogService"]["@odata.id"] =
- "/redfish/v1/Managers/bmc/LogServices/Journal";
+ res.jsonValue["MetricDefinitions"]["@odata.id"] =
+ "/redfish/v1/TelemetryService/MetricDefinitions";
res.jsonValue["MetricReportDefinitions"]["@odata.id"] =
@@ -680,5 +551,5 @@ index 8e01bee..00acdf9 100644
if (!json_util::readJson(req, asyncResp->res, "Temperatures",
--
-2.17.1
+2.16.6
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Sync-Telmetry-service-with-EventService.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Sync-Telmetry-service-with-EventService.patch
index 06c50b31f..3df9fe5ae 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Sync-Telmetry-service-with-EventService.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Sync-Telmetry-service-with-EventService.patch
@@ -1,27 +1,28 @@
-From b6286fe6800ca402b013e57429025fd9e4d65cab Mon Sep 17 00:00:00 2001
+From 14a429586fd8ccb82c72611fe3310860db2e643b Mon Sep 17 00:00:00 2001
From: "Wludzik, Jozef" <jozef.wludzik@intel.com>
-Date: Fri, 4 Dec 2020 14:48:41 +0100
-Subject: [PATCH] Sync Telmetry service with EventService
+Date: Tue, 15 Dec 2020 12:30:31 +0100
+Subject: [PATCH 4/4] Sync Telmetry service with EventService
-Now assembling MetricReport is done properly and is
-covered in one place - MetricReport node.
-Updated method of fetching Readings from Telemetry by
-EventService. Using ReportUpdate signal is no longer
-supported.
+Synced the latest changes in Telemetry service with Event Service
+code. Now assembling MetricReport is covered in single place in
+code. Updated method of fetching Readings from Telemetry by
+Event Service. Using ReportUpdate signal is no longer
+supported. Now Event Service monitors for PropertiesChanged signal
+from /xyz/openbmc_project/Telemetry/Reports path.
Tested:
- - Received MetricReport in EventListener server after
- adding subscription to EventService.
+ - Verified that EventListener received MetricReport response from
+ Event Service in insecure http push style eventing mode
Change-Id: I2fc1841a6c9259a8bff30b34bddc0d4aabd41912
Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
---
- .../include/event_service_manager.hpp | 156 ++++++------------
- redfish-core/lib/metric_report.hpp | 35 ++--
- 2 files changed, 74 insertions(+), 117 deletions(-)
+ redfish-core/include/event_service_manager.hpp | 157 +++++++++----------------
+ redfish-core/lib/metric_report.hpp | 28 +++--
+ 2 files changed, 71 insertions(+), 114 deletions(-)
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
-index f68ae1d..893a813 100644
+index 3db9f0c..5c5a6c1 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -14,6 +14,7 @@
@@ -41,7 +42,7 @@ index f68ae1d..893a813 100644
- const ReadingsObjType& readings)
+ void filterAndSendReports(
+ const std::string& id,
-+ const std::variant<MetricReport::TimestampReadings>& var)
++ const std::variant<telemetry::TimestampReadings>& var)
{
- std::string metricReportDef =
- "/redfish/v1/TelemetryService/MetricReportDefinitions/" + id2;
@@ -62,7 +63,7 @@ index f68ae1d..893a813 100644
- nlohmann::json metricValuesArray = nlohmann::json::array();
- for (const auto& it : readings)
+ nlohmann::json json;
-+ if (!MetricReport::fillReport(json, id, var))
++ if (!telemetry::fillReport(json, id, var))
{
- metricValuesArray.push_back({});
- nlohmann::json& entry = metricValuesArray.back();
@@ -90,7 +91,7 @@ index f68ae1d..893a813 100644
}
void updateRetryConfig(const uint32_t retryAttempts,
-@@ -1342,56 +1324,71 @@ class EventServiceManager
+@@ -1342,56 +1324,72 @@ class EventServiceManager
}
#endif
@@ -152,7 +153,7 @@ index f68ae1d..893a813 100644
- if (!timestampPtr)
+ std::string intf;
+ std::vector<std::pair<
-+ std::string, std::variant<MetricReport::TimestampReadings>>>
++ std::string, std::variant<telemetry::TimestampReadings>>>
+ props;
+ std::vector<std::string> invalidProp;
+
@@ -166,7 +167,7 @@ index f68ae1d..893a813 100644
- ReadingsObjType* readingsPtr =
- std::get_if<ReadingsObjType>(&resp["Readings"]);
- if (!readingsPtr)
-+ const std::variant<MetricReport::TimestampReadings>* varPtr =
++ const std::variant<telemetry::TimestampReadings>* varPtr =
+ nullptr;
+ for (const auto& [key, var] : props)
+ {
@@ -183,15 +184,16 @@ index f68ae1d..893a813 100644
}
- if (!readingsPtr->size())
-+ std::string id;
-+ if (!dbus::utility::getNthStringFromPath(msg.get_path(), 5, id))
++ sdbusplus::message::object_path path(msg.get_path());
++ std::string id = path.filename();
++ if (id.empty())
{
- BMCWEB_LOG_DEBUG << "No metrics report to be transferred";
+ BMCWEB_LOG_ERROR << "Failed to get Id from path";
return;
}
-@@ -1401,52 +1398,9 @@ class EventServiceManager
+@@ -1401,52 +1399,9 @@ class EventServiceManager
std::shared_ptr<Subscription> entry = it.second;
if (entry->eventFormatType == metricReportFormatType)
{
@@ -246,85 +248,64 @@ index f68ae1d..893a813 100644
}
diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp
-index 050304c..c2013cc 100644
+index 9caf4a3..e79a41c 100644
--- a/redfish-core/lib/metric_report.hpp
+++ b/redfish-core/lib/metric_report.hpp
-@@ -52,6 +52,10 @@ class MetricReport : public Node
- {boost::beast::http::verb::post, {{"ConfigureManager"}}}};
+@@ -31,16 +31,14 @@ inline nlohmann::json toMetricValues(const Readings& readings)
+ return metricValues;
+ }
+
+-inline void fillReport(const std::shared_ptr<AsyncResp>& asyncResp,
+- const std::string& id,
++inline bool fillReport(nlohmann::json& json, const std::string& id,
+ const std::variant<TimestampReadings>& var)
+ {
+- asyncResp->res.jsonValue["@odata.type"] =
+- "#MetricReport.v1_3_0.MetricReport";
+- asyncResp->res.jsonValue["@odata.id"] = telemetry::metricReportUri + id;
+- asyncResp->res.jsonValue["Id"] = id;
+- asyncResp->res.jsonValue["Name"] = id;
+- asyncResp->res.jsonValue["MetricReportDefinition"]["@odata.id"] =
++ json["@odata.type"] = "#MetricReport.v1_3_0.MetricReport";
++ json["@odata.id"] = telemetry::metricReportUri + id;
++ json["Id"] = id;
++ json["Name"] = id;
++ json["MetricReportDefinition"]["@odata.id"] =
+ telemetry::metricReportDefinitionUri + id;
+
+ const TimestampReadings* timestampReadings =
+@@ -48,14 +46,14 @@ inline void fillReport(const std::shared_ptr<AsyncResp>& asyncResp,
+ if (!timestampReadings)
+ {
+ BMCWEB_LOG_ERROR << "Property type mismatch or property is missing";
+- messages::internalError(asyncResp->res);
+- return;
++ return false;
}
-+ using Readings =
-+ std::vector<std::tuple<std::string, std::string, double, uint64_t>>;
-+ using TimestampReadings = std::tuple<uint64_t, Readings>;
-+
- private:
- void doGet(crow::Response& res, const crow::Request&,
- const std::vector<std::string>& params) override
-@@ -92,7 +96,10 @@ class MetricReport : public Node
+ const auto& [timestamp, readings] = *timestampReadings;
+- asyncResp->res.jsonValue["Timestamp"] =
++ json["Timestamp"] =
+ crow::utility::getDateTime(static_cast<time_t>(timestamp));
+- asyncResp->res.jsonValue["MetricValues"] = toMetricValues(readings);
++ json["MetricValues"] = toMetricValues(readings);
++ return true;
+ }
+ } // namespace telemetry
+
+@@ -146,7 +144,11 @@ class MetricReport : public Node
return;
}
-- fillReport(asyncResp, id, ret);
-+ if (!fillReport(asyncResp->res.jsonValue, id, ret))
+- telemetry::fillReport(asyncResp, id, ret);
++ if (!telemetry::fillReport(asyncResp->res.jsonValue, id,
++ ret))
+ {
+ messages::internalError(asyncResp->res);
+ }
},
telemetry::service, reportPath,
"org.freedesktop.DBus.Properties", "Get",
-@@ -102,10 +109,6 @@ class MetricReport : public Node
- "Update");
- }
-
-- using Readings =
-- std::vector<std::tuple<std::string, std::string, double, uint64_t>>;
-- using TimestampReadings = std::tuple<uint64_t, Readings>;
--
- static nlohmann::json toMetricValues(const Readings& readings)
- {
- nlohmann::json metricValues = nlohmann::json::array_t();
-@@ -130,15 +133,15 @@ class MetricReport : public Node
- return metricValues;
- }
-
-- static void fillReport(const std::shared_ptr<AsyncResp>& asyncResp,
-- const std::string& id,
-+ public:
-+ static bool fillReport(nlohmann::json& json, const std::string& id,
- const std::variant<TimestampReadings>& var)
- {
-- asyncResp->res.jsonValue["@odata.type"] = schemaType;
-- asyncResp->res.jsonValue["@odata.id"] = telemetry::metricReportUri + id;
-- asyncResp->res.jsonValue["Id"] = id;
-- asyncResp->res.jsonValue["Name"] = id;
-- asyncResp->res.jsonValue["MetricReportDefinition"]["@odata.id"] =
-+ json["@odata.type"] = schemaType;
-+ json["@odata.id"] = telemetry::metricReportUri + id;
-+ json["Id"] = id;
-+ json["Name"] = id;
-+ json["MetricReportDefinition"]["@odata.id"] =
- telemetry::metricReportDefinitionUri + id;
-
- const TimestampReadings* timestampReadings =
-@@ -146,14 +149,14 @@ class MetricReport : public Node
- if (!timestampReadings)
- {
- BMCWEB_LOG_ERROR << "Property type mismatch or property is missing";
-- messages::internalError(asyncResp->res);
-- return;
-+ return false;
- }
-
- const auto& [timestamp, readings] = *timestampReadings;
-- asyncResp->res.jsonValue["Timestamp"] =
-+ json["Timestamp"] =
- crow::utility::getDateTime(static_cast<time_t>(timestamp));
-- asyncResp->res.jsonValue["MetricValues"] = toMetricValues(readings);
-+ json["MetricValues"] = toMetricValues(readings);
-+ return true;
- }
-
- static constexpr const char* schemaType =
--
-2.17.1
+2.16.6
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/README b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/README
index 833fabfec..35c6e90bc 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/README
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/README
@@ -2,15 +2,12 @@ These patches are mirror of upstream TelemetryService implementation.
Until change is integrated they will be manually merged here to enable feature in Intel builds.
Current revisions:
-- Redfish TelemetryService schema implementation
- https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/31692/54
-
- Add POST and DELETE in MetricReportDefinitions
- https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/32536/46
+ https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/32536/58
- Add support for MetricDefinition scheme
- https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/33363/42
+ https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/33363/54
- Sync Telmetry service with EventService
- https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/38798/9
+ https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/38798/21
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend
index e5037593f..db8a7a90f 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend
@@ -1,5 +1,5 @@
SRC_URI = "git://github.com/openbmc/bmcweb.git"
-SRCREV = "a90daf182891521fcc7c3e99ba266e6a55d4b4dd"
+SRCREV = "2b3da45876aac57a36d3093379a992d699e7e396"
DEPENDS += "boost-url"
RDEPENDS_${PN} += "phosphor-nslcd-authority-cert-config"
@@ -22,17 +22,23 @@ SRC_URI += "file://0001-Firmware-update-configuration-changes.patch \
file://0009-Add-support-to-ChangePassword-action.patch \
file://0010-managers-add-attributes-for-Manager.CommandShell.patch \
file://0034-recommended-fixes-by-crypto-review-team.patch \
- file://0036-Fix-wrong-check-in-EventService-events.patch \
"
+# Temporary downstream mirror of upstream patch to enable feature in Intel builds.
+SRC_URI += "file://0037-Add-state-sensor-messages-to-the-registry.patch \
+"
# Temporary downstream mirror of upstream patches, see telemetry\README for details
-SRC_URI += "file://telemetry/0001-Redfish-TelemetryService-schema-implementation.patch \
- file://telemetry/0002-Add-POST-and-DELETE-in-MetricReportDefinitions.patch \
+SRC_URI += "file://telemetry/0002-Add-POST-and-DELETE-in-MetricReportDefinitions.patch \
file://telemetry/0003-Add-support-for-MetricDefinition-scheme.patch \
file://telemetry/0004-Sync-Telmetry-service-with-EventService.patch \
"
+SRC_URI += "file://0001-Add-ConnectedVia-property-to-virtual-media-item-temp.patch \
+ file://0002-Change-InsertMedia-action-response-for-POST-in-proxy.patch \
+ file://0003-Set-Inserted-redfish-property-for-not-inserted-resou.patch \
+"
+
# Temporary fix: Move it to service file
do_install_append() {
install -d ${D}/var/lib/bmcweb
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-node-manager-proxy_git.bb b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-node-manager-proxy_git.bb
index 30a229022..8a6911345 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-node-manager-proxy_git.bb
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-node-manager-proxy_git.bb
@@ -3,7 +3,7 @@ DESCRIPTION = "The Node Manager Proxy provides a simple interface for communicat
with Management Engine via IPMB"
SRC_URI = "git://github.com/Intel-BMC/node-manager;protocol=ssh"
-SRCREV = "403434f80e6a6c476516848dde2512b37f7ec5d8"
+SRCREV = "1b243b3bfa5a3523a6ca9805626c8cf045146697"
PV = "0.1+git${SRCPV}"
LICENSE = "Apache-2.0"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/peci/peci-pcie_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/peci/peci-pcie_%.bbappend
index 71a6d58da..6744b172c 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/peci/peci-pcie_%.bbappend
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/peci/peci-pcie_%.bbappend
@@ -1,3 +1,3 @@
SRC_URI = "git://github.com/openbmc/peci-pcie"
-SRCREV = "9fa54b52f83c00fd713085e6849d3f261672d008"
+SRCREV = "0b79f3e485554957a4b24d5f0cefc5bc577ad301"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/libmctp-intel_git.bb b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/libmctp-intel_git.bb
index 099de5a47..61d008c46 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/libmctp-intel_git.bb
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/libmctp-intel_git.bb
@@ -2,7 +2,7 @@ SUMMARY = "libmctp_intel"
DESCRIPTION = "Implementation of MCTP(DMTF DSP0236)"
SRC_URI = "git://github.com/Intel-BMC/libmctp.git;protocol=ssh"
-SRCREV = "14bf0b99083dda55b959273d63210407740c8217"
+SRCREV = "f5246c429d728ee1b6558692b72ef1960db68a7c"
S = "${WORKDIR}/git"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/libpldm-intel_git.bb b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/libpldm-intel_git.bb
index d885bf227..d72093b8b 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/libpldm-intel_git.bb
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/libpldm-intel_git.bb
@@ -2,7 +2,7 @@ SUMMARY = "libpldm_intel"
DESCRIPTION = "Provides encode/decode APIs for PLDM specifications"
SRC_URI = "git://github.com/Intel-BMC/pmci.git;protocol=ssh"
-SRCREV = "7ec1523f3a982678fec20b0ccc94436f3d467126"
+SRCREV = "85f6b517b0c519b88b7533f042159e9a30fd3048"
S = "${WORKDIR}/git/libpldm_intel"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctp-emulator.bb b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctp-emulator.bb
index 083394a24..291a18375 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctp-emulator.bb
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctp-emulator.bb
@@ -5,7 +5,7 @@ LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=bcd9ada3a943f58551867d72893cc9ab"
SRC_URI = "git://github.com/Intel-BMC/pmci.git;protocol=ssh"
-SRCREV = "7ec1523f3a982678fec20b0ccc94436f3d467126"
+SRCREV = "85f6b517b0c519b88b7533f042159e9a30fd3048"
S = "${WORKDIR}/git/mctp_emulator"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctp-wrapper.bb b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctp-wrapper.bb
index 88939348f..a56db5829 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctp-wrapper.bb
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctp-wrapper.bb
@@ -5,7 +5,7 @@ LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=bcd9ada3a943f58551867d72893cc9ab"
SRC_URI = "git://github.com/Intel-BMC/pmci.git;protocol=ssh"
-SRCREV = "7ec1523f3a982678fec20b0ccc94436f3d467126"
+SRCREV = "85f6b517b0c519b88b7533f042159e9a30fd3048"
S = "${WORKDIR}/git/mctp_wrapper"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctpd.bb b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctpd.bb
index 8612fc78d..226a3a44f 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctpd.bb
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctpd.bb
@@ -5,7 +5,7 @@ LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${PN}/LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
SRC_URI = "git://github.com/Intel-BMC/pmci.git;protocol=ssh"
-SRCREV = "7ec1523f3a982678fec20b0ccc94436f3d467126"
+SRCREV = "85f6b517b0c519b88b7533f042159e9a30fd3048"
S = "${WORKDIR}/git"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctpwplus.bb b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctpwplus.bb
index a0c4ac42a..c9a44d1ad 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctpwplus.bb
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/mctpwplus.bb
@@ -5,7 +5,7 @@ LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=615045c30a05cde5c0e924854d43c327"
SRC_URI = "git://github.com/Intel-BMC/pmci.git;protocol=ssh"
-SRCREV = "7ec1523f3a982678fec20b0ccc94436f3d467126"
+SRCREV = "85f6b517b0c519b88b7533f042159e9a30fd3048"
S = "${WORKDIR}/git/mctpwplus"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/pldmd.bb b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/pldmd.bb
index 3c443aa02..0167014b7 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/pldmd.bb
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/pldmd.bb
@@ -5,7 +5,7 @@ LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=86d3f3a95c324c9479bd8986968f4327"
SRC_URI += "git://github.com/Intel-BMC/pmci.git;protocol=ssh"
-SRCREV = "7ec1523f3a982678fec20b0ccc94436f3d467126"
+SRCREV = "85f6b517b0c519b88b7533f042159e9a30fd3048"
S = "${WORKDIR}/git/pldmd"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/pmci-launcher.bb b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/pmci-launcher.bb
index 0997869d5..09a3f9284 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/pmci-launcher.bb
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/pmci/pmci-launcher.bb
@@ -5,7 +5,7 @@ LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
SRC_URI = "git://github.com/Intel-BMC/pmci.git;protocol=ssh"
-SRCREV = "7ec1523f3a982678fec20b0ccc94436f3d467126"
+SRCREV = "85f6b517b0c519b88b7533f042159e9a30fd3048"
S = "${WORKDIR}/git/pmci_launcher"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/sel-logger/phosphor-sel-logger_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/sel-logger/phosphor-sel-logger_%.bbappend
index 33a19a902..cb4a74a0b 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/sel-logger/phosphor-sel-logger_%.bbappend
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/sel-logger/phosphor-sel-logger_%.bbappend
@@ -1,4 +1,4 @@
# Enable downstream autobump
SRC_URI = "git://github.com/openbmc/phosphor-sel-logger.git"
-SRCREV = "7d8a3003fb8038291f5e678cbfd74344ec6e62d2"
+SRCREV = "aaffc124b6f49d9bc267e65565bdd5d4c1db1aaf"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0002-Fix-PECI-client-creation-flow.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0002-Fix-PECI-client-creation-flow.patch
index 0b2c19d32..cfdc99d66 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0002-Fix-PECI-client-creation-flow.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0002-Fix-PECI-client-creation-flow.patch
@@ -1,4 +1,4 @@
-From 6d553f9fb6829d7dbbe2f625a09f476b0ef91ca0 Mon Sep 17 00:00:00 2001
+From 0a1b2a13f6dbc64b5851ac2b1ca99d57afa78d60 Mon Sep 17 00:00:00 2001
From: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
Date: Wed, 27 Jan 2021 15:52:16 -0800
Subject: [PATCH] Fix PECI client creation flow
@@ -12,10 +12,10 @@ Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
1 file changed, 54 insertions(+), 12 deletions(-)
diff --git a/src/CPUSensorMain.cpp b/src/CPUSensorMain.cpp
-index dfc942fcf7f3..67be7447e74e 100644
+index f304e3f..92c1716 100644
--- a/src/CPUSensorMain.cpp
+++ b/src/CPUSensorMain.cpp
-@@ -84,6 +84,7 @@ struct CPUConfig
+@@ -82,6 +82,7 @@ struct CPUConfig
};
static constexpr const char* peciDev = "/dev/peci-";
@@ -23,16 +23,16 @@ index dfc942fcf7f3..67be7447e74e 100644
static constexpr const unsigned int rankNumMax = 8;
namespace fs = std::filesystem;
-@@ -169,7 +170,7 @@ bool createSensors(boost::asio::io_service& io,
+@@ -167,7 +168,7 @@ bool createSensors(boost::asio::io_service& io,
}
std::vector<fs::path> hwmonNamePaths;
- if (!findFiles(fs::path(R"(/sys/bus/peci/devices)"),
+ if (!findFiles(fs::path(peciDevPath),
R"(peci-\d+/\d+-.+/peci-.+/hwmon/hwmon\d+/name$)",
- hwmonNamePaths, 1))
+ hwmonNamePaths, 6))
{
-@@ -405,7 +406,7 @@ bool createSensors(boost::asio::io_service& io,
+@@ -403,7 +404,7 @@ bool createSensors(boost::asio::io_service& io,
return true;
}
@@ -41,7 +41,7 @@ index dfc942fcf7f3..67be7447e74e 100644
{
std::ostringstream hex;
hex << std::hex << config.addr;
-@@ -413,9 +414,12 @@ void exportDevice(const CPUConfig& config)
+@@ -411,9 +412,12 @@ void exportDevice(const CPUConfig& config)
std::string busStr = std::to_string(config.bus);
std::string parameters = "peci-client 0x" + addrHexStr;
@@ -56,7 +56,7 @@ index dfc942fcf7f3..67be7447e74e 100644
const std::string& dir = devicePath.parent_path().string();
for (const auto& path : std::filesystem::directory_iterator(dir))
{
-@@ -433,20 +437,38 @@ void exportDevice(const CPUConfig& config)
+@@ -431,20 +435,38 @@ void exportDevice(const CPUConfig& config)
std::cout << parameters << " on bus " << busStr
<< " is already exported\n";
}
@@ -99,7 +99,7 @@ index dfc942fcf7f3..67be7447e74e 100644
}
void detectCpu(boost::asio::deadline_timer& pingTimer,
-@@ -462,6 +484,11 @@ void detectCpu(boost::asio::deadline_timer& pingTimer,
+@@ -460,6 +482,11 @@ void detectCpu(boost::asio::deadline_timer& pingTimer,
for (CPUConfig& config : cpuConfigs)
{
@@ -111,7 +111,7 @@ index dfc942fcf7f3..67be7447e74e 100644
std::string peciDevPath = peciDev + std::to_string(config.bus);
auto file = open(peciDevPath.c_str(), O_RDWR | O_CLOEXEC);
if (file < 0)
-@@ -512,16 +539,29 @@ void detectCpu(boost::asio::deadline_timer& pingTimer,
+@@ -510,16 +537,29 @@ void detectCpu(boost::asio::deadline_timer& pingTimer,
newState = State::OFF;
}
@@ -145,13 +145,13 @@ index dfc942fcf7f3..67be7447e74e 100644
}
if (newState == State::ON)
-@@ -544,6 +584,8 @@ void detectCpu(boost::asio::deadline_timer& pingTimer,
+@@ -542,6 +582,8 @@ void detectCpu(boost::asio::deadline_timer& pingTimer,
keepPinging = true;
}
+ close(file);
+
- if (DEBUG)
+ if (debug)
{
std::cout << config.name << ", state: " << config.state << "\n";
--
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0003-Fix-missing-threshold-de-assert-event-when-threshold.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0003-Fix-missing-threshold-de-assert-event-when-threshold.patch
new file mode 100644
index 000000000..c9175fd64
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0003-Fix-missing-threshold-de-assert-event-when-threshold.patch
@@ -0,0 +1,139 @@
+From 17e3ed85f2ff919ff52b4a3fe7a1eb0026f28898 Mon Sep 17 00:00:00 2001
+From: Zhikui Ren <zhikui.ren@intel.com>
+Date: Thu, 24 Sep 2020 14:27:32 -0700
+Subject: [PATCH] Fix missing threshold de-assert event when threshold changes.
+
+Sensor can be re-constructed when sensor configuration changes
+like a new threshold value. Threshold deassert can be missed
+if the new threshold value fixes the alarm because the
+default state for new threshold interface is de-asserted.
+Send threshold de-assert message after interfaces are initialized to
+ensure de-assert event is logged if there is an active assert
+event.
+
+Tested:
+step1:
+busctl set-property xyz.openbmc_project.ADCSensor /xyz/openbmc_project/sensors/voltage/P3VBAT xyz.openbmc_project.Sensor.Threshold.Warning WarningLow d 2.457
+ipmitool sel list
+SEL has no entries
+step2:
+busctl set-property xyz.openbmc_project.ADCSensor /xyz/openbmc_project/sensors/voltage/P3VBAT xyz.openbmc_project.Sensor.Threshold.Warning WarningLow d 3.1
+ipmitool sel list
+ 1 | 09/24/20 | 21:30:15 UTC | Voltage #0x2d | Lower Non-critical going low | Asserted
+step3:
+busctl set-property xyz.openbmc_project.ADCSensor /xyz/openbmc_project/sensors/voltage/P3VBAT xyz.openbmc_project.Sensor.Threshold.Warning WarningLow d 2.457
+ipmitool sel list
+ 1 | 09/24/20 | 21:30:15 UTC | Voltage #0x2d | Lower Non-critical going low | Asserted
+ 2 | 09/24/20 | 21:30:33 UTC | Voltage #0x2d | Lower Non-critical going low | Deasserted
+
+Signed-off-by: Zhikui Ren <zhikui.ren@intel.com>
+Change-Id: If28870ac1e0d09be4a631a3145408ec70390dfc5
+---
+ include/Thresholds.hpp | 5 ++++-
+ include/sensor.hpp | 13 +++++++++++++
+ src/ADCSensor.cpp | 1 +
+ src/Thresholds.cpp | 15 +++++++++++++--
+ 4 files changed, 31 insertions(+), 3 deletions(-)
+
+diff --git a/include/Thresholds.hpp b/include/Thresholds.hpp
+index ca2b0a0..c1d0baf 100644
+--- a/include/Thresholds.hpp
++++ b/include/Thresholds.hpp
+@@ -45,7 +45,10 @@ struct Threshold
+
+ void assertThresholds(Sensor* sensor, double assertValue,
+ thresholds::Level level, thresholds::Direction direction,
+- bool assert);
++ bool assert, bool force = false);
++
++void forceDeassertThresholds(Sensor* sensor, thresholds::Level level,
++ thresholds::Direction direction);
+
+ struct TimerUsed
+ {
+diff --git a/include/sensor.hpp b/include/sensor.hpp
+index 0ef87d5..d50b2ff 100644
+--- a/include/sensor.hpp
++++ b/include/sensor.hpp
+@@ -312,6 +312,19 @@ struct Sensor
+ operationalInterface->register_property("Functional", true);
+ operationalInterface->initialize();
+ }
++
++ // Sensor can be reconstructed when sensor configuration changes
++ // like a new threshold value. Threshold deassert can be missed
++ // if the new threshold value fixes the alarm because
++ // default state for new threshold interface is de-asserted.
++ // Send threshold de-assert message during initialization to
++ // ensure de-assert events are logged if there is an active assert
++ // event.
++ for (auto& threshold : thresholds)
++ {
++ thresholds::forceDeassertThresholds(this, threshold.level,
++ threshold.direction);
++ }
+ }
+
+ bool readingStateGood()
+diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp
+index fe600d7..632fc8c 100644
+--- a/src/ADCSensor.cpp
++++ b/src/ADCSensor.cpp
+@@ -88,6 +88,7 @@ ADCSensor::~ADCSensor()
+ // close the input dev to cancel async operations
+ inputDev.close();
+ waitTimer.cancel();
++
+ objServer.remove_interface(thresholdInterfaceWarning);
+ objServer.remove_interface(thresholdInterfaceCritical);
+ objServer.remove_interface(sensorInterface);
+diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp
+index f4d4ed0..3c791c9 100644
+--- a/src/Thresholds.cpp
++++ b/src/Thresholds.cpp
+@@ -344,6 +344,7 @@ bool checkThresholds(Sensor* sensor)
+ {
+ bool status = true;
+ std::vector<ChangeParam> changes = checkThresholds(sensor, sensor->value);
++
+ for (const auto& change : changes)
+ {
+ assertThresholds(sensor, change.assertValue, change.threshold.level,
+@@ -392,7 +393,7 @@ void checkThresholdsPowerDelay(Sensor* sensor, ThresholdTimer& thresholdTimer)
+
+ void assertThresholds(Sensor* sensor, double assertValue,
+ thresholds::Level level, thresholds::Direction direction,
+- bool assert)
++ bool assert, bool force)
+ {
+ std::string property;
+ std::shared_ptr<sdbusplus::asio::dbus_interface> interface;
+@@ -432,7 +433,9 @@ void assertThresholds(Sensor* sensor, double assertValue,
+ return;
+ }
+
+- if (interface->set_property<bool, true>(property, assert))
++ bool propertyChanged =
++ interface->set_property<bool, true>(property, assert);
++ if (force || propertyChanged)
+ {
+ try
+ {
+@@ -452,6 +455,14 @@ void assertThresholds(Sensor* sensor, double assertValue,
+ }
+ }
+
++// Explicitely de-assert a threshold with existing sensor value
++// Should only be called on sensor desctruction
++void forceDeassertThresholds(Sensor* sensor, thresholds::Level level,
++ thresholds::Direction direction)
++{
++ assertThresholds(sensor, sensor->value, level, direction, false, true);
++}
++
+ bool parseThresholdsFromAttr(
+ std::vector<thresholds::Threshold>& thresholdVector,
+ const std::string& inputPath, const double& scaleFactor,
+--
+2.17.1
+
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0004-Fan-Tach-Sensor-Threshold-Ignore-Zero.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0004-Fan-Tach-Sensor-Threshold-Ignore-Zero.patch
new file mode 100644
index 000000000..65558aba5
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0004-Fan-Tach-Sensor-Threshold-Ignore-Zero.patch
@@ -0,0 +1,58 @@
+From 8f850ea8745aa7aafcb504aa50686ba00fdfcfee Mon Sep 17 00:00:00 2001
+From: Zhikui Ren <zhikui.ren@intel.com>
+Date: Fri, 19 Feb 2021 12:14:05 -0800
+Subject: [PATCH] Fan Tach Sensor Threshold Ignore Zero
+
+Currently there are systems that have system fans plugged
+into different fan connectors. Fan present detection is
+not supported in most of these systems. Critical low
+threshold is asserted for the non-utilized fans
+resulting in FSC boost all fans.
+
+Skip threshold checking for fan tach reading less or equal
+to zero. This is a temporary WA until a more robust solution
+is available.
+
+Note: with this workaround a completely non-working fan
+will not be detected. FSC will still boost fans due to other
+constraints if the system can't be cooled with the working fans.
+
+Tested:
+No cr event for the missing fans.
+
+Signed-off-by: Zhikui Ren <zhikui.ren@intel.com>
+---
+ src/TachSensor.cpp | 16 +++++++++++-----
+ 1 file changed, 11 insertions(+), 5 deletions(-)
+
+diff --git a/src/TachSensor.cpp b/src/TachSensor.cpp
+index 1ec979f..b17be98 100644
+--- a/src/TachSensor.cpp
++++ b/src/TachSensor.cpp
+@@ -185,12 +185,18 @@ void TachSensor::handleResponse(const boost::system::error_code& err)
+
+ void TachSensor::checkThresholds(void)
+ {
+- bool status = thresholds::checkThresholds(this);
+-
+- if (redundancy && *redundancy)
++ // WA - treat value <= 0 as not present
++ bool status = false;
++ if (value > 0)
+ {
+- (*redundancy)
+- ->update("/xyz/openbmc_project/sensors/fan_tach/" + name, !status);
++ status = thresholds::checkThresholds(this);
++
++ if (redundancy && *redundancy)
++ {
++ (*redundancy)
++ ->update("/xyz/openbmc_project/sensors/fan_tach/" + name,
++ !status);
++ }
+ }
+
+ bool curLed = !status;
+--
+2.17.1
+
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0005-Fix-PECI-ioctl-number.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0005-Fix-PECI-ioctl-number.patch
new file mode 100644
index 000000000..8119f7542
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0005-Fix-PECI-ioctl-number.patch
@@ -0,0 +1,29 @@
+From f85dd776301371892ff5197c1995bf2224dd87ab Mon Sep 17 00:00:00 2001
+From: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
+Date: Mon, 22 Feb 2021 15:57:20 -0800
+Subject: [PATCH] Fix PECI ioctl number
+
+This commit fixes PECI ioctl number to 0xb8 to avoid conflicts in
+kernel v5.10.
+
+Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
+---
+ include/linux/peci-ioctl.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/linux/peci-ioctl.h b/include/linux/peci-ioctl.h
+index e5b4b8bd3275..1f44edf4fc04 100644
+--- a/include/linux/peci-ioctl.h
++++ b/include/linux/peci-ioctl.h
+@@ -601,7 +601,7 @@ struct peci_crashdump_get_frame_msg {
+ __u8 data[16];
+ } __attribute__((__packed__));
+
+-#define PECI_IOC_BASE 0xb7
++#define PECI_IOC_BASE 0xb8
+
+ #define PECI_IOC_XFER \
+ _IOWR(PECI_IOC_BASE, PECI_CMD_XFER, struct peci_xfer_msg)
+--
+2.17.1
+
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors_%.bbappend
index 39a6f1581..bb1268e0a 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors_%.bbappend
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors_%.bbappend
@@ -1,13 +1,16 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
PROJECT_SRC_DIR := "${THISDIR}/${PN}"
-SRCREV = "a3e8f2a391f389ffb2c379ca0c181e67de43824e"
+SRCREV = "d05867c0d32065d36b13bd452f7aff9dcb20ac2f"
#SRC_URI = "git://github.com/openbmc/dbus-sensors.git"
SRC_URI += "\
file://intrusionsensor-depend-on-networkd.conf \
file://0001-Add-check-for-min-max-received-from-hwmon-files.patch \
file://0002-Fix-PECI-client-creation-flow.patch \
+ file://0003-Fix-missing-threshold-de-assert-event-when-threshold.patch \
+ file://0004-Fan-Tach-Sensor-Threshold-Ignore-Zero.patch \
+ file://0005-Fix-PECI-ioctl-number.patch \
"
DEPENDS_append = " libgpiod libmctp"
@@ -24,14 +27,12 @@ PACKAGECONFIG += " \
psusensor \
"
-PACKAGECONFIG[nvmesensor] = "-DDISABLE_NVME=OFF, -DDISABLE_NVME=ON"
+PACKAGECONFIG[nvmesensor] = "-Dnvme=enabled, -Dnvme=disabled"
SYSTEMD_SERVICE_${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'nvmesensor', \
'xyz.openbmc_project.nvmesensor.service', \
'', d)}"
-PACKAGECONFIG_remove = "nvmesensor"
-
do_install_append() {
svc="xyz.openbmc_project.intrusionsensor.service"
srcf="${WORKDIR}/intrusionsensor-depend-on-networkd.conf"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/settings/settings_git.bb b/meta-openbmc-mods/meta-common/recipes-phosphor/settings/settings_git.bb
index 986d50f2d..6acbfff37 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/settings/settings_git.bb
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/settings/settings_git.bb
@@ -1,7 +1,7 @@
SUMMARY = "Settings"
SRC_URI = "git://github.com/Intel-BMC/settings.git;protocol=ssh"
-SRCREV = "946ac7669602d5660310e8609f500dadf16bb16d"
+SRCREV = "1bdbb05873b5790bd56b683ce8ddf1a02a6795e7"
PV = "0.1+git${SRCPV}"
LICENSE = "Apache-2.0"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/special-mode-mgr/special-mode-mgr_git.bb b/meta-openbmc-mods/meta-common/recipes-phosphor/special-mode-mgr/special-mode-mgr_git.bb
index 85e3d6e8b..c77e5ace6 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/special-mode-mgr/special-mode-mgr_git.bb
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/special-mode-mgr/special-mode-mgr_git.bb
@@ -9,7 +9,7 @@ LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
SRC_URI = "git://github.com/Intel-BMC/special-mode-manager.git;protocol=ssh"
-SRCREV = "024531a11dbe2bd13f2f6e59bdb41a22fce8b431"
+SRCREV = "32ea1e19df9e5179054d87617468664367dfab80"
EXTRA_OECMAKE += "${@bb.utils.contains('EXTRA_IMAGE_FEATURES', 'validation-unsecure', '-DBMC_VALIDATION_UNSECURE_FEATURE=ON', '', d)}"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/telemetry/telemetry_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/telemetry/telemetry_%.bbappend
index 1468afe49..cadacc235 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/telemetry/telemetry_%.bbappend
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/telemetry/telemetry_%.bbappend
@@ -1,5 +1,5 @@
SRC_URI = "git://github.com/openbmc/telemetry.git"
-SRCREV = "405c1e4bf8b993cb3800adead546e91b030ecb9b"
+SRCREV = "92cfff44d5790b7e59930e8a6acf15751a3cd891"
EXTRA_OEMESON += " -Dmax-reports=5"
EXTRA_OEMESON += " -Dmax-reading-parameters=200"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/users/phosphor-user-manager/0005-Added-suport-for-multiple-user-manager-services.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/users/phosphor-user-manager/0005-Added-suport-for-multiple-user-manager-services.patch
index 2182201cf..dfd980a2b 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/users/phosphor-user-manager/0005-Added-suport-for-multiple-user-manager-services.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/users/phosphor-user-manager/0005-Added-suport-for-multiple-user-manager-services.patch
@@ -1,7 +1,7 @@
-From ab2ff3d715b00a13b0a670fb010793dc626352e0 Mon Sep 17 00:00:00 2001
+From 6fd1c797ec7440551052e8fc638d06313c9d6836 Mon Sep 17 00:00:00 2001
From: Radivoje Jovanovic <radivoje.jovanovic@intel.com>
Date: Mon, 2 Jul 2018 19:23:25 -0700
-Subject: [PATCH] Added suport for multiple user manager services
+Subject: [PATCH 1/2] Added suport for multiple user manager services
Support added for SSSD service implementation
@@ -10,12 +10,12 @@ Signed-off-by: Radivoje Jovanovic <radivoje.jovanovic@intel.com>
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
---
Makefile.am | 5 +-
- mainapp.cpp | 89 ++++++-
- user_mgr.cpp | 297 ++-------------------
+ mainapp.cpp | 90 +++++-
+ user_mgr.cpp | 297 ++----------------
user_mgr.hpp | 9 +-
- user_service.cpp | 786 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
- user_service.hpp | 233 +++++++++++++++++
- 6 files changed, 1145 insertions(+), 274 deletions(-)
+ user_service.cpp | 789 +++++++++++++++++++++++++++++++++++++++++++++++
+ user_service.hpp | 233 ++++++++++++++
+ 6 files changed, 1149 insertions(+), 274 deletions(-)
create mode 100644 user_service.cpp
create mode 100644 user_service.hpp
@@ -39,18 +39,19 @@ index 7c7271e..58916b0 100644
phosphor_user_manager_LDFLAGS = $(SDBUSPLUS_LIBS) \
$(PHOSPHOR_DBUS_INTERFACES_LIBS) \
diff --git a/mainapp.cpp b/mainapp.cpp
-index c9da030..03c406a 100644
+index e08da61..f4b7f8c 100644
--- a/mainapp.cpp
+++ b/mainapp.cpp
-@@ -14,18 +14,105 @@
- * limitations under the License.
- */
- #include <string>
-+#include <iostream>
-+#include <getopt.h>
+@@ -16,18 +16,106 @@
+ #include "config.h"
+
#include "user_mgr.hpp"
+#include "user_service.hpp"
- #include "config.h"
+
++#include <getopt.h>
++
++#include <iostream>
+ #include <string>
// D-Bus root for user manager
constexpr auto USER_MANAGER_ROOT = "/xyz/openbmc_project/user";
@@ -150,63 +151,66 @@ index c9da030..03c406a 100644
// Claim the bus now
bus.request_name(USER_MANAGER_BUSNAME);
diff --git a/user_mgr.cpp b/user_mgr.cpp
-index 9694fd1..c48196a 100644
+index c65a822..eed81aa 100644
--- a/user_mgr.cpp
+++ b/user_mgr.cpp
-@@ -14,27 +14,20 @@
- // limitations under the License.
- */
+@@ -18,43 +18,34 @@
+
+ #include "user_mgr.hpp"
+
+-#include "file.hpp"
+ #include "shadowlock.hpp"
+ #include "users.hpp"
+ #include <grp.h>
+ #include <pwd.h>
-#include <shadow.h>
--#include <unistd.h>
-#include <sys/types.h>
-#include <sys/wait.h>
#include <time.h>
-+#include <cstdio>
- #include <fstream>
- #include <grp.h>
- #include <pwd.h>
- #include <regex>
--#include <algorithm>
--#include <numeric>
+-#include <unistd.h>
+
+ #include <boost/algorithm/string/split.hpp>
-#include <boost/process/child.hpp>
-#include <boost/process/io.hpp>
- #include <boost/algorithm/string/split.hpp>
+ #include <phosphor-logging/elog-errors.hpp>
+ #include <phosphor-logging/elog.hpp>
+ #include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
#include <xyz/openbmc_project/User/Common/error.hpp>
- #include <phosphor-logging/log.hpp>
- #include <phosphor-logging/elog.hpp>
- #include <phosphor-logging/elog-errors.hpp>
+
+-#include <algorithm>
++#include <cstdio>
+ #include <fstream>
+-#include <numeric>
+ #include <regex>
+#include <stdexcept>
- #include "shadowlock.hpp"
--#include "file.hpp"
- #include "user_mgr.hpp"
- #include "users.hpp"
- #include "config.h"
-@@ -44,12 +37,10 @@ namespace phosphor
+
+ namespace phosphor
+ {
namespace user
{
--static constexpr const char *passwdFileName = "/etc/passwd";
+-static constexpr const char* passwdFileName = "/etc/passwd";
static constexpr size_t ipmiMaxUsers = 15;
static constexpr size_t ipmiMaxUserNameLen = 16;
static constexpr size_t systemMaxUserNameLen = 30;
static constexpr size_t maxSystemUsers = 30;
--static constexpr const char *grpSsh = "ssh";
+-static constexpr const char* grpSsh = "ssh";
static constexpr uint8_t minPasswdLength = 8;
static constexpr int success = 0;
static constexpr int failure = -1;
-@@ -95,79 +86,6 @@ using NoResource =
+@@ -100,79 +91,6 @@ using NoResource =
using Argument = xyz::openbmc_project::Common::InvalidArgument;
-template <typename... ArgTypes>
--static std::vector<std::string> executeCmd(const char *path,
-- ArgTypes &&... tArgs)
+-static std::vector<std::string> executeCmd(const char* path,
+- ArgTypes&&... tArgs)
-{
- std::vector<std::string> stdOutput;
- boost::process::ipstream stdOutStream;
-- boost::process::child execProg(path, const_cast<char *>(tArgs)...,
+- boost::process::child execProg(path, const_cast<char*>(tArgs)...,
- boost::process::std_out > stdOutStream);
- std::string stdOutLine;
-
@@ -254,7 +258,7 @@ index 9694fd1..c48196a 100644
- }
-}
-
--static bool removeStringFromCSV(std::string &csvStr, const std::string &delStr)
+-static bool removeStringFromCSV(std::string& csvStr, const std::string& delStr)
-{
- std::string::size_type delStrPos = csvStr.find(delStr);
- if (delStrPos != std::string::npos)
@@ -273,10 +277,10 @@ index 9694fd1..c48196a 100644
- return false;
-}
-
- bool UserMgr::isUserExist(const std::string &userName)
+ bool UserMgr::isUserExist(const std::string& userName)
{
if (userName.empty())
-@@ -294,39 +212,14 @@ void UserMgr::createUser(std::string userName,
+@@ -299,39 +217,14 @@ void UserMgr::createUser(std::string userName,
{
throwForInvalidPrivilege(priv);
throwForInvalidGroups(groupNames);
@@ -306,7 +310,7 @@ index 9694fd1..c48196a 100644
- (sshRequested ? "/bin/sh" : "/bin/nologin"), "-e",
- (enabled ? "" : "1970-01-02"));
- }
-- catch (const InternalFailure &e)
+- catch (const InternalFailure& e)
- {
- log<level::ERR>("Unable to create new user");
- elog<InternalFailure>();
@@ -319,7 +323,7 @@ index 9694fd1..c48196a 100644
std::string userObj = std::string(usersObjPath) + "/" + userName;
std::sort(groupNames.begin(), groupNames.end());
usersList.emplace(
-@@ -340,19 +233,11 @@ void UserMgr::createUser(std::string userName,
+@@ -345,19 +238,11 @@ void UserMgr::createUser(std::string userName,
void UserMgr::deleteUser(std::string userName)
{
@@ -330,7 +334,7 @@ index 9694fd1..c48196a 100644
- {
- executeCmd("/usr/sbin/userdel", userName.c_str(), "-r");
- }
-- catch (const InternalFailure &e)
+- catch (const InternalFailure& e)
- {
- log<level::ERR>("User delete failed",
- entry("USER_NAME=%s", userName.c_str()));
@@ -343,7 +347,7 @@ index 9694fd1..c48196a 100644
usersList.erase(userName);
-@@ -363,24 +248,13 @@ void UserMgr::deleteUser(std::string userName)
+@@ -368,24 +253,13 @@ void UserMgr::deleteUser(std::string userName)
void UserMgr::renameUser(std::string userName, std::string newUserName)
{
@@ -359,7 +363,7 @@ index 9694fd1..c48196a 100644
- executeCmd("/usr/sbin/usermod", "-l", newUserName.c_str(),
- userName.c_str(), "-d", newHomeDir.c_str(), "-m");
- }
-- catch (const InternalFailure &e)
+- catch (const InternalFailure& e)
- {
- log<level::ERR>("User rename failed",
- entry("USER_NAME=%s", userName.c_str()));
@@ -368,19 +372,19 @@ index 9694fd1..c48196a 100644
+ // Call The User Service to rename user on the system
+ userSrvc->renameUser(userName, newUserName);
+ // Update local list to reflect the name change
- const auto &user = usersList[userName];
+ const auto& user = usersList[userName];
std::string priv = user.get()->userPrivilege();
std::vector<std::string> groupNames = user.get()->userGroups();
-@@ -404,8 +278,6 @@ void UserMgr::updateGroupsAndPriv(const std::string &userName,
+@@ -409,8 +283,6 @@ void UserMgr::updateGroupsAndPriv(const std::string& userName,
{
throwForInvalidPrivilege(priv);
throwForInvalidGroups(groupNames);
- // All user management lock has to be based on /etc/shadow
- phosphor::user::shadow::Lock lock();
throwForUserDoesNotExist(userName);
- const std::vector<std::string> &oldGroupNames =
+ const std::vector<std::string>& oldGroupNames =
usersList[userName].get()->userGroups();
-@@ -421,29 +293,8 @@ void UserMgr::updateGroupsAndPriv(const std::string &userName,
+@@ -426,29 +298,8 @@ void UserMgr::updateGroupsAndPriv(const std::string& userName,
throwForMaxGrpUserCount(groupNames);
}
@@ -402,7 +406,7 @@ index 9694fd1..c48196a 100644
- executeCmd("/usr/sbin/usermod", userName.c_str(), "-G", groups.c_str(),
- "-s", (sshRequested ? "/bin/sh" : "/bin/nologin"));
- }
-- catch (const InternalFailure &e)
+- catch (const InternalFailure& e)
- {
- log<level::ERR>("Unable to modify user privilege / groups");
- elog<InternalFailure>();
@@ -412,9 +416,9 @@ index 9694fd1..c48196a 100644
log<level::INFO>("User groups / privilege updated successfully",
entry("USER_NAME=%s", userName.c_str()));
-@@ -639,19 +490,9 @@ int UserMgr::setPamModuleArgValue(const std::string &moduleName,
+@@ -644,19 +495,9 @@ int UserMgr::setPamModuleArgValue(const std::string& moduleName,
- void UserMgr::userEnable(const std::string &userName, bool enabled)
+ void UserMgr::userEnable(const std::string& userName, bool enabled)
{
- // All user management lock has to be based on /etc/shadow
- phosphor::user::shadow::Lock lock();
@@ -424,7 +428,7 @@ index 9694fd1..c48196a 100644
- executeCmd("/usr/sbin/usermod", userName.c_str(), "-e",
- (enabled ? "" : "1970-01-02"));
- }
-- catch (const InternalFailure &e)
+- catch (const InternalFailure& e)
- {
- log<level::ERR>("Unable to modify user enabled state");
- elog<InternalFailure>();
@@ -434,7 +438,7 @@ index 9694fd1..c48196a 100644
log<level::INFO>("User enabled/disabled state updated successfully",
entry("USER_NAME=%s", userName.c_str()),
-@@ -773,54 +614,8 @@ bool UserMgr::userPasswordExpired(const std::string &userName)
+@@ -779,54 +620,8 @@ bool UserMgr::userPasswordExpired(const std::string& userName)
UserSSHLists UserMgr::getUserAndSshGrpList()
{
@@ -491,15 +495,15 @@ index 9694fd1..c48196a 100644
}
size_t UserMgr::getIpmiUsersCount()
-@@ -831,49 +626,14 @@ size_t UserMgr::getIpmiUsersCount()
+@@ -837,49 +632,14 @@ size_t UserMgr::getIpmiUsersCount()
- bool UserMgr::isUserEnabled(const std::string &userName)
+ bool UserMgr::isUserEnabled(const std::string& userName)
{
- // All user management lock has to be based on /etc/shadow
- phosphor::user::shadow::Lock lock();
- std::array<char, 4096> buffer{};
- struct spwd spwd;
-- struct spwd *resultPtr = nullptr;
+- struct spwd* resultPtr = nullptr;
- int status = getspnam_r(userName.c_str(), &spwd, buffer.data(),
- buffer.max_size(), &resultPtr);
- if (!status && (&spwd == resultPtr))
@@ -515,13 +519,13 @@ index 9694fd1..c48196a 100644
+ return userSrvc->isUserEnabled(userName);
}
- std::vector<std::string> UserMgr::getUsersInGroup(const std::string &groupName)
+ std::vector<std::string> UserMgr::getUsersInGroup(const std::string& groupName)
{
- std::vector<std::string> usersInGroup;
- // Should be more than enough to get the pwd structure.
- std::array<char, 4096> buffer{};
- struct group grp;
-- struct group *resultPtr = nullptr;
+- struct group* resultPtr = nullptr;
-
- int status = getgrnam_r(groupName.c_str(), &grp, buffer.data(),
- buffer.max_size(), &resultPtr);
@@ -545,7 +549,7 @@ index 9694fd1..c48196a 100644
}
DbusUserObj UserMgr::getPrivilegeMapperObject(void)
-@@ -1104,11 +864,9 @@ void UserMgr::initUserObjects(void)
+@@ -1106,11 +866,9 @@ void UserMgr::initUserObjects(void)
{
// All user management lock has to be based on /etc/shadow
phosphor::user::shadow::Lock lock();
@@ -559,20 +563,20 @@ index 9694fd1..c48196a 100644
if (!userNameList.empty())
{
-@@ -1163,8 +921,10 @@ void UserMgr::initUserObjects(void)
+@@ -1165,8 +923,10 @@ void UserMgr::initUserObjects(void)
}
}
--UserMgr::UserMgr(sdbusplus::bus::bus &bus, const char *path) :
+-UserMgr::UserMgr(sdbusplus::bus::bus& bus, const char* path) :
- Ifaces(bus, path, true), bus(bus), path(path)
-+UserMgr::UserMgr(sdbusplus::bus::bus &bus, const char *path,
++UserMgr::UserMgr(sdbusplus::bus::bus& bus, const char* path,
+ UserService::ServiceType srvc) :
+ Ifaces(bus, path, true),
+ bus(bus), path(path)
{
UserMgrIface::allPrivileges(privMgr);
std::sort(groupsMgr.begin(), groupsMgr.end());
-@@ -1272,6 +1032,7 @@ UserMgr::UserMgr(sdbusplus::bus::bus &bus, const char *path) :
+@@ -1274,6 +1034,7 @@ UserMgr::UserMgr(sdbusplus::bus::bus& bus, const char* path) :
}
AccountPolicyIface::accountUnlockTimeout(value32);
}
@@ -581,18 +585,18 @@ index 9694fd1..c48196a 100644
// emit the signal
diff --git a/user_mgr.hpp b/user_mgr.hpp
-index e25ca87..262aaf9 100644
+index f5aac22..5d5ca99 100644
--- a/user_mgr.hpp
+++ b/user_mgr.hpp
-@@ -21,6 +21,7 @@
- #include <unordered_map>
- #include <variant>
- #include "users.hpp"
+@@ -14,6 +14,7 @@
+ // limitations under the License.
+ */
+ #pragma once
+#include "user_service.hpp"
+ #include "users.hpp"
- namespace phosphor
- {
-@@ -28,8 +29,6 @@ namespace user
+ #include <sdbusplus/bus.hpp>
+@@ -30,8 +31,6 @@ namespace user
{
using UserMgrIface = sdbusplus::xyz::openbmc_project::User::server::Manager;
@@ -601,19 +605,19 @@ index e25ca87..262aaf9 100644
using AccountPolicyIface =
sdbusplus::xyz::openbmc_project::User::server::AccountPolicy;
-@@ -76,8 +75,10 @@ class UserMgr : public Ifaces
+@@ -77,8 +76,10 @@ class UserMgr : public Ifaces
*
* @param[in] bus - sdbusplus handler
* @param[in] path - D-Bus path
+ * @param[in] srvc - User service to be used
*/
-- UserMgr(sdbusplus::bus::bus &bus, const char *path);
-+ UserMgr(sdbusplus::bus::bus &bus, const char *path,
+- UserMgr(sdbusplus::bus::bus& bus, const char* path);
++ UserMgr(sdbusplus::bus::bus& bus, const char* path,
+ UserService::ServiceType srvc);
/** @brief create user method.
* This method creates a new user as requested
-@@ -193,6 +194,8 @@ class UserMgr : public Ifaces
+@@ -194,6 +195,8 @@ class UserMgr : public Ifaces
/** @brief object path */
const std::string path;
@@ -624,10 +628,10 @@ index e25ca87..262aaf9 100644
"priv-user", "priv-noaccess"};
diff --git a/user_service.cpp b/user_service.cpp
new file mode 100644
-index 0000000..c3c45bd
+index 0000000..ad4e510
--- /dev/null
+++ b/user_service.cpp
-@@ -0,0 +1,786 @@
+@@ -0,0 +1,789 @@
+/*
+// Copyright (c) 2018 Intel Corporation
+//
@@ -644,15 +648,19 @@ index 0000000..c3c45bd
+// limitations under the License.
+*/
+
++#include "user_service.hpp"
++
++#include "file.hpp"
++#include "shadowlock.hpp"
++
+#include <grp.h>
+#include <pwd.h>
-+#include <numeric>
++
++#include <boost/algorithm/string/split.hpp>
+#include <boost/process/child.hpp>
+#include <boost/process/io.hpp>
-+#include <boost/algorithm/string/split.hpp>
-+#include "shadowlock.hpp"
-+#include "file.hpp"
-+#include "user_service.hpp"
++
++#include <numeric>
+
+/* anonymous namespace for User Service interface implementations.
+// Each class inside this namespace implements a special service
@@ -689,7 +697,7 @@ index 0000000..c3c45bd
+ }
+}
+
-+bool removeStringFromCSV(std::string &csvStr, const std::string &delStr)
++bool removeStringFromCSV(std::string& csvStr, const std::string& delStr)
+{
+ std::string::size_type delStrPos = csvStr.find(delStr);
+ if (delStrPos != std::string::npos)
@@ -770,14 +778,14 @@ index 0000000..c3c45bd
+ }
+
+ std::vector<std::string>
-+ getUsersInGroup(const std::string &groupName) const override
++ getUsersInGroup(const std::string& groupName) const override
+ {
+ std::vector<std::string> usersInGroup;
+ // Should be more than enough to get the pwd structure.
+ std::array<char, 4096> buffer{};
+ struct group grp;
-+ struct group *grpPtr = &grp;
-+ struct group *resultPtr;
++ struct group* grpPtr = &grp;
++ struct group* resultPtr;
+
+ int status = getgrnam_r(groupName.c_str(), grpPtr, buffer.data(),
+ buffer.max_size(), &resultPtr);
@@ -799,9 +807,9 @@ index 0000000..c3c45bd
+ return usersInGroup;
+ }
+
-+ void createUser(const std::string &userName,
-+ const std::vector<std::string> &groupNames,
-+ const std::string &priv, const bool &enabled) const override
++ void createUser(const std::string& userName,
++ const std::vector<std::string>& groupNames,
++ const std::string& priv, const bool& enabled) const override
+ {
+ // All user management lock has to be based on /etc/shadow
+ phosphor::user::shadow::Lock lock();
@@ -827,7 +835,7 @@ index 0000000..c3c45bd
+ "-m", "-N", "-s", (sshRequested ? "/bin/sh" : "/bin/nologin"),
+ "-e", (enabled ? "" : "1970-01-02"));
+ }
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Unable to create new user");
@@ -835,8 +843,8 @@ index 0000000..c3c45bd
+ }
+ }
+
-+ void renameUser(const std::string &userName,
-+ const std::string &newUserName) const override
++ void renameUser(const std::string& userName,
++ const std::string& newUserName) const override
+ {
+ // All user management lock has to be based on /etc/shadow
+ phosphor::user::shadow::Lock lock();
@@ -847,7 +855,7 @@ index 0000000..c3c45bd
+ newUserName.c_str(), userName.c_str(),
+ "-d", newHomeDir.c_str(), "-m");
+ }
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
+ {
+ phosphor::logging::log<phosphor::logging::level::INFO>(
+ "User rename failed",
@@ -856,7 +864,7 @@ index 0000000..c3c45bd
+ }
+ }
+
-+ void deleteUser(const std::string &userName) const override
++ void deleteUser(const std::string& userName) const override
+ {
+ // All user management lock has to be based on /etc/shadow
+ phosphor::user::shadow::Lock lock();
@@ -866,7 +874,7 @@ index 0000000..c3c45bd
+ phosphor::user::executeCmd("/usr/sbin/userdel", userName.c_str(),
+ "-r");
+ }
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
+ {
+ phosphor::logging::log<phosphor::logging::level::INFO>(
+ "User delete failed",
@@ -875,9 +883,9 @@ index 0000000..c3c45bd
+ }
+ }
+
-+ void updateGroupsAndPriv(const std::string &userName,
-+ const std::vector<std::string> &groupNames,
-+ const std::string &priv) const override
++ void updateGroupsAndPriv(const std::string& userName,
++ const std::vector<std::string>& groupNames,
++ const std::string& priv) const override
+ {
+ // All user management lock has to be based on /etc/shadow
+ phosphor::user::shadow::Lock lock();
@@ -902,7 +910,7 @@ index 0000000..c3c45bd
+ "/usr/sbin/usermod", userName.c_str(), "-G", groups.c_str(),
+ "-s", (sshRequested ? "/bin/sh" : "/bin/nologin"));
+ }
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Unable to modify user privilege / groups");
@@ -910,8 +918,8 @@ index 0000000..c3c45bd
+ }
+ }
+
-+ void updateUserStatus(const std::string &userName,
-+ const bool &enabled) const override
++ void updateUserStatus(const std::string& userName,
++ const bool& enabled) const override
+ {
+ // All user management lock has to be based on /etc/shadow
+ phosphor::user::shadow::Lock lock();
@@ -920,7 +928,7 @@ index 0000000..c3c45bd
+ phosphor::user::executeCmd("/usr/sbin/usermod", userName.c_str(),
+ "-e", (enabled ? "" : "1970-01-02"));
+ }
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Unable to modify user enabled state");
@@ -928,13 +936,13 @@ index 0000000..c3c45bd
+ }
+ }
+
-+ bool isUserEnabled(const std::string &userName) const override
++ bool isUserEnabled(const std::string& userName) const override
+ {
+ // All user management lock has to be based on /etc/shadow
+ phosphor::user::shadow::Lock lock();
+ std::array<char, 4096> buffer{};
+ struct spwd spwd;
-+ struct spwd *resultPtr = nullptr;
++ struct spwd* resultPtr = nullptr;
+ int status = getspnam_r(userName.c_str(), &spwd, buffer.data(),
+ buffer.max_size(), &resultPtr);
+ if (!status && (&spwd == resultPtr))
@@ -949,7 +957,7 @@ index 0000000..c3c45bd
+ }
+
+ std::vector<std::string>
-+ getUserGroups(const std::string &userName) const override
++ getUserGroups(const std::string& userName) const override
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "ShadowService::getUserGroups not implemented!");
@@ -957,7 +965,7 @@ index 0000000..c3c45bd
+ return std::vector<std::string>();
+ }
+
-+ void createGroup(const std::string &groupName) const override
++ void createGroup(const std::string& groupName) const override
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "ShadowService::createGroup not implemented!");
@@ -965,22 +973,22 @@ index 0000000..c3c45bd
+ }
+
+ private:
-+ static constexpr const char *passwdFileName = "/etc/passwd";
++ static constexpr const char* passwdFileName = "/etc/passwd";
+};
+
+class SSSDService : public phosphor::user::UserServiceInterface
+{
+ public:
-+ SSSDService(const std::vector<std::string> &groups,
-+ const std::vector<std::string> &privs)
++ SSSDService(const std::vector<std::string>& groups,
++ const std::vector<std::string>& privs)
+ {
+
+ createGroup(lockedGrp);
-+ for (const auto &g : groups)
++ for (const auto& g : groups)
+ {
+ createGroup(g);
+ }
-+ for (const auto &p : privs)
++ for (const auto& p : privs)
+ {
+ createGroup(p);
+ }
@@ -999,7 +1007,7 @@ index 0000000..c3c45bd
+ exeOutput = phosphor::user::executeCmd("/usr/bin/getent", "-s",
+ "sss", "passwd");
+ }
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Unable to get users information "
@@ -1007,7 +1015,7 @@ index 0000000..c3c45bd
+ phosphor::logging::elog<phosphor::user::InternalFailure>();
+ }
+
-+ for (const auto &userLine : exeOutput)
++ for (const auto& userLine : exeOutput)
+ {
+ std::vector<std::string> userInfo;
+ boost::algorithm::split(userInfo, userLine,
@@ -1035,7 +1043,7 @@ index 0000000..c3c45bd
+ }
+
+ std::vector<std::string>
-+ getUsersInGroup(const std::string &groupName) const override
++ getUsersInGroup(const std::string& groupName) const override
+ {
+ std::vector<std::string> userList;
+ std::vector<std::string> exeOutput;
@@ -1045,7 +1053,7 @@ index 0000000..c3c45bd
+ exeOutput = phosphor::user::executeCmd("/usr/sbin/sss_groupshow",
+ groupName.c_str());
+ }
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Unable to get group users from sssd service");
@@ -1067,9 +1075,9 @@ index 0000000..c3c45bd
+ return userList;
+ }
+
-+ void createUser(const std::string &userName,
-+ const std::vector<std::string> &groupNames,
-+ const std::string &priv, const bool &enabled) const override
++ void createUser(const std::string& userName,
++ const std::vector<std::string>& groupNames,
++ const std::string& priv, const bool& enabled) const override
+ {
+ std::string groups = getCSVFromVector(groupNames);
+ bool sshRequested = removeStringFromCSV(groups, phosphor::user::grpSsh);
@@ -1090,7 +1098,7 @@ index 0000000..c3c45bd
+ "/usr/sbin/sss_useradd", "-m", "-G", groups.c_str(), "-s",
+ (sshRequested ? "/bin/sh" : "/bin/nologin"), userName.c_str());
+ }
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Unable to create new user in sssd service");
@@ -1105,8 +1113,8 @@ index 0000000..c3c45bd
+ updateUserStatus(userName, enabled);
+ }
+
-+ void renameUser(const std::string &userName,
-+ const std::string &newUserName) const override
++ void renameUser(const std::string& userName,
++ const std::string& newUserName) const override
+ {
+ std::vector<std::string> exeOutput;
+ // Local Domain for sssd doesn't have a rename feature
@@ -1123,7 +1131,7 @@ index 0000000..c3c45bd
+ exeOutput = phosphor::user::executeCmd(
+ "/usr/bin/getent", "-s", "sss", "passwd", userName.c_str());
+ }
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Unable to get information for user");
@@ -1141,14 +1149,14 @@ index 0000000..c3c45bd
+ deleteUser(userName);
+ }
+
-+ void deleteUser(const std::string &userName) const override
++ void deleteUser(const std::string& userName) const override
+ {
+ try
+ {
+ phosphor::user::executeCmd("/usr/sbin/sss_userdel", "-r",
+ userName.c_str());
+ }
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Unable to delete user from sssd service");
@@ -1156,9 +1164,9 @@ index 0000000..c3c45bd
+ }
+ }
+
-+ void updateGroupsAndPriv(const std::string &userName,
-+ const std::vector<std::string> &groupNames,
-+ const std::string &priv) const override
++ void updateGroupsAndPriv(const std::string& userName,
++ const std::vector<std::string>& groupNames,
++ const std::string& priv) const override
+ {
+ // local domain sssd do not allow to update all list of groups,
+ // so we will remove all groups first (except for the user one)
@@ -1183,7 +1191,7 @@ index 0000000..c3c45bd
+ groups.c_str(), "-s",
+ (sshRequested ? "/bin/sh" : "/bin/nologin"), userName.c_str());
+ }
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Unable to update user groups and "
@@ -1192,8 +1200,8 @@ index 0000000..c3c45bd
+ }
+ }
+
-+ void updateUserStatus(const std::string &userName,
-+ const bool &enabled) const override
++ void updateUserStatus(const std::string& userName,
++ const bool& enabled) const override
+ {
+ std::string enabledStr;
+ std::string lockedStr;
@@ -1224,7 +1232,7 @@ index 0000000..c3c45bd
+ enabledStr.c_str(), lockedGrp.c_str(),
+ lockedStr.c_str(), userName.c_str());
+ }
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Unable to update user status from sssd service");
@@ -1232,7 +1240,7 @@ index 0000000..c3c45bd
+ }
+ }
+
-+ bool isUserEnabled(const std::string &userName) const override
++ bool isUserEnabled(const std::string& userName) const override
+ {
+ std::vector<std::string> userGrps = getUserGroups(userName);
+ return std::find(userGrps.begin(), userGrps.end(), lockedGrp) ==
@@ -1240,7 +1248,7 @@ index 0000000..c3c45bd
+ }
+
+ std::vector<std::string>
-+ getUserGroups(const std::string &userName) const override
++ getUserGroups(const std::string& userName) const override
+ {
+ std::vector<std::string> exeOutput;
+ try
@@ -1248,7 +1256,7 @@ index 0000000..c3c45bd
+ exeOutput =
+ phosphor::user::executeCmd("/usr/bin/groups", userName.c_str());
+ }
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Unable to get groups for user");
@@ -1267,7 +1275,7 @@ index 0000000..c3c45bd
+ return groups;
+ }
+
-+ void createGroup(const std::string &groupName) const override
++ void createGroup(const std::string& groupName) const override
+ {
+ try
+ {
@@ -1277,7 +1285,7 @@ index 0000000..c3c45bd
+ groupName.c_str());
+ }
+ }
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Unable to create group");
@@ -1288,14 +1296,14 @@ index 0000000..c3c45bd
+ private:
+ static const std::string lockedGrp;
+
-+ bool groupExists(const std::string &groupName) const
++ bool groupExists(const std::string& groupName) const
+ {
+ try
+ {
+ phosphor::user::executeCmd("/usr/sbin/sss_groupshow",
+ groupName.c_str());
+ }
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
+ {
+ return false;
+ }
@@ -1311,24 +1319,24 @@ index 0000000..c3c45bd
+namespace user
+{
+
-+UserService::UserService(const ServiceType &srvcType,
-+ const std::vector<std::string> &groups,
-+ const std::vector<std::string> &privs)
++UserService::UserService(const ServiceType& srvcType,
++ const std::vector<std::string>& groups,
++ const std::vector<std::string>& privs)
+{
+ setServiceImpl(srvcType, groups, privs);
+}
+
-+void UserService::updateServiceType(const ServiceType &srvcType,
-+ const std::vector<std::string> &groups,
-+ const std::vector<std::string> &privs)
++void UserService::updateServiceType(const ServiceType& srvcType,
++ const std::vector<std::string>& groups,
++ const std::vector<std::string>& privs)
+{
+ usrSrvcImpl.reset();
+ setServiceImpl(srvcType, groups, privs);
+}
+
-+void UserService::setServiceImpl(const ServiceType &srvcType,
-+ const std::vector<std::string> &groups,
-+ const std::vector<std::string> &privs)
++void UserService::setServiceImpl(const ServiceType& srvcType,
++ const std::vector<std::string>& groups,
++ const std::vector<std::string>& privs)
+{
+ switch (srvcType)
+ {
@@ -1356,8 +1364,7 @@ index 0000000..c3c45bd
+}
+
+UserService::~UserService()
-+{
-+}
++{}
+
+phosphor::user::UserSSHLists UserService::getUserAndSshGrpList() const
+{
@@ -1365,49 +1372,49 @@ index 0000000..c3c45bd
+}
+
+std::vector<std::string>
-+ UserService::getUsersInGroup(const std::string &groupName) const
++ UserService::getUsersInGroup(const std::string& groupName) const
+{
+ return usrSrvcImpl->getUsersInGroup(groupName);
+}
+
-+void UserService::createUser(const std::string &userName,
-+ const std::vector<std::string> &groupNames,
-+ const std::string &priv, const bool &enabled) const
++void UserService::createUser(const std::string& userName,
++ const std::vector<std::string>& groupNames,
++ const std::string& priv, const bool& enabled) const
+{
+ usrSrvcImpl->createUser(userName, groupNames, priv, enabled);
+}
+
-+void UserService::renameUser(const std::string &userName,
-+ const std::string &newUserName) const
++void UserService::renameUser(const std::string& userName,
++ const std::string& newUserName) const
+{
+ usrSrvcImpl->renameUser(userName, newUserName);
+}
+
-+void UserService::deleteUser(const std::string &userName) const
++void UserService::deleteUser(const std::string& userName) const
+{
+ usrSrvcImpl->deleteUser(userName);
+}
+
+void UserService::updateGroupsAndPriv(
-+ const std::string &userName, const std::vector<std::string> &groupNames,
-+ const std::string &priv) const
++ const std::string& userName, const std::vector<std::string>& groupNames,
++ const std::string& priv) const
+{
+ usrSrvcImpl->updateGroupsAndPriv(userName, groupNames, priv);
+}
+
-+void UserService::updateUserStatus(const std::string &userName,
-+ const bool &enabled) const
++void UserService::updateUserStatus(const std::string& userName,
++ const bool& enabled) const
+{
+ usrSrvcImpl->updateUserStatus(userName, enabled);
+}
+
-+bool UserService::isUserEnabled(const std::string &userName) const
++bool UserService::isUserEnabled(const std::string& userName) const
+{
+ return usrSrvcImpl->isUserEnabled(userName);
+}
+
+std::vector<std::string>
-+ UserService::getUserGroups(const std::string &userName) const
++ UserService::getUserGroups(const std::string& userName) const
+{
+ return usrSrvcImpl->getUserGroups(userName);
+}
@@ -1416,7 +1423,7 @@ index 0000000..c3c45bd
+} // namespace phosphor
diff --git a/user_service.hpp b/user_service.hpp
new file mode 100644
-index 0000000..97a049b
+index 0000000..50ee4db
--- /dev/null
+++ b/user_service.hpp
@@ -0,0 +1,233 @@
@@ -1437,12 +1444,12 @@ index 0000000..97a049b
+*/
+
+#pragma once
-+#include <xyz/openbmc_project/Common/error.hpp>
-+#include <xyz/openbmc_project/User/Common/error.hpp>
-+#include <phosphor-logging/log.hpp>
-+#include <phosphor-logging/elog.hpp>
+#include <boost/process/child.hpp>
+#include <boost/process/io.hpp>
++#include <phosphor-logging/elog.hpp>
++#include <phosphor-logging/log.hpp>
++#include <xyz/openbmc_project/Common/error.hpp>
++#include <xyz/openbmc_project/User/Common/error.hpp>
+
+namespace phosphor
+{
@@ -1459,11 +1466,11 @@ index 0000000..97a049b
+const std::string grpSsh = "ssh";
+
+template <typename... ArgTypes>
-+std::vector<std::string> executeCmd(const char *path, ArgTypes &&... tArgs)
++std::vector<std::string> executeCmd(const char* path, ArgTypes&&... tArgs)
+{
+ std::vector<std::string> stdOutput;
+ boost::process::ipstream stdOutStream;
-+ boost::process::child execProg(path, const_cast<char *>(tArgs)...,
++ boost::process::child execProg(path, const_cast<char*>(tArgs)...,
+ boost::process::std_out > stdOutStream);
+ std::string stdOutLine;
+
@@ -1500,23 +1507,23 @@ index 0000000..97a049b
+ virtual ~UserServiceInterface() = default;
+ virtual UserSSHLists getUserAndSshGrpList() const = 0;
+ virtual std::vector<std::string>
-+ getUsersInGroup(const std::string &groupName) const = 0;
-+ virtual void createUser(const std::string &userName,
-+ const std::vector<std::string> &groupNames,
-+ const std::string &priv,
-+ const bool &enabled) const = 0;
-+ virtual void renameUser(const std::string &userName,
-+ const std::string &newUserName) const = 0;
-+ virtual void deleteUser(const std::string &userName) const = 0;
-+ virtual void updateGroupsAndPriv(const std::string &userName,
-+ const std::vector<std::string> &groupNames,
-+ const std::string &priv) const = 0;
-+ virtual void updateUserStatus(const std::string &userName,
-+ const bool &enabled) const = 0;
-+ virtual bool isUserEnabled(const std::string &userName) const = 0;
++ getUsersInGroup(const std::string& groupName) const = 0;
++ virtual void createUser(const std::string& userName,
++ const std::vector<std::string>& groupNames,
++ const std::string& priv,
++ const bool& enabled) const = 0;
++ virtual void renameUser(const std::string& userName,
++ const std::string& newUserName) const = 0;
++ virtual void deleteUser(const std::string& userName) const = 0;
++ virtual void updateGroupsAndPriv(const std::string& userName,
++ const std::vector<std::string>& groupNames,
++ const std::string& priv) const = 0;
++ virtual void updateUserStatus(const std::string& userName,
++ const bool& enabled) const = 0;
++ virtual bool isUserEnabled(const std::string& userName) const = 0;
+ virtual std::vector<std::string>
-+ getUserGroups(const std::string &userName) const = 0;
-+ virtual void createGroup(const std::string &groupName) const = 0;
++ getUserGroups(const std::string& userName) const = 0;
++ virtual void createGroup(const std::string& groupName) const = 0;
+};
+
+/** @class UserService
@@ -1532,10 +1539,10 @@ index 0000000..97a049b
+{
+ public:
+ UserService() = delete;
-+ UserService(const UserService &) = delete;
-+ UserService &operator=(const UserService &) = delete;
-+ UserService(UserService &&) = delete;
-+ UserService &operator=(UserService &&) = delete;
++ UserService(const UserService&) = delete;
++ UserService& operator=(const UserService&) = delete;
++ UserService(UserService&&) = delete;
++ UserService& operator=(UserService&&) = delete;
+
+ // Service Types implemented. None is used to validate.
+ enum class ServiceType
@@ -1545,9 +1552,9 @@ index 0000000..97a049b
+ sssd
+ };
+
-+ UserService(const ServiceType &srvcType,
-+ const std::vector<std::string> &groups,
-+ const std::vector<std::string> &privs);
++ UserService(const ServiceType& srvcType,
++ const std::vector<std::string>& groups,
++ const std::vector<std::string>& privs);
+ ~UserService();
+
+ /** @brief update the current Service type of the instance.
@@ -1559,9 +1566,9 @@ index 0000000..97a049b
+ * @param[in] groups
+ * @param[in] privs
+ */
-+ void updateServiceType(const ServiceType &srvcType,
-+ const std::vector<std::string> &groups,
-+ const std::vector<std::string> &privs);
++ void updateServiceType(const ServiceType& srvcType,
++ const std::vector<std::string>& groups,
++ const std::vector<std::string>& privs);
+
+ /** @brief get user list and SSH group members list
+ * This method gets the list of users from the service.
@@ -1579,7 +1586,7 @@ index 0000000..97a049b
+ * @param[in] groupName - Name of the group which has to be queried
+ */
+ std::vector<std::string>
-+ getUsersInGroup(const std::string &groupName) const;
++ getUsersInGroup(const std::string& groupName) const;
+
+ /** @brief create user method.
+ * This method creates a new user as requested
@@ -1589,9 +1596,9 @@ index 0000000..97a049b
+ * @param[in] priv - Privilege of the user.
+ * @param[in] enabled - State of the user enabled / disabled.
+ */
-+ void createUser(const std::string &userName,
-+ const std::vector<std::string> &groupNames,
-+ const std::string &priv, const bool &enabled) const;
++ void createUser(const std::string& userName,
++ const std::vector<std::string>& groupNames,
++ const std::string& priv, const bool& enabled) const;
+
+ /** @brief rename user method.
+ * This method renames the user as requested
@@ -1599,15 +1606,15 @@ index 0000000..97a049b
+ * @param[in] userName - current name of the user
+ * @param[in] userName - user name to which it has to be renamed.
+ */
-+ void renameUser(const std::string &userName,
-+ const std::string &newUserName) const;
++ void renameUser(const std::string& userName,
++ const std::string& newUserName) const;
+
+ /** @brief delete user method.
+ * This method deletes the user as requested
+ *
+ * @param[in] userName - Name of the user which has to be deleted
+ */
-+ void deleteUser(const std::string &userName) const;
++ void deleteUser(const std::string& userName) const;
+
+ /** @brief Updates user Groups and Privilege.
+ *
@@ -1615,9 +1622,9 @@ index 0000000..97a049b
+ * @param[in] groupNames - Group names list for user.
+ * @param[in] priv - Privilege of the user.
+ */
-+ void updateGroupsAndPriv(const std::string &userName,
-+ const std::vector<std::string> &groupNames,
-+ const std::string &priv) const;
++ void updateGroupsAndPriv(const std::string& userName,
++ const std::vector<std::string>& groupNames,
++ const std::string& priv) const;
+
+ /** @brief Updates user status
+ * If enabled = false: User will be disabled
@@ -1626,8 +1633,8 @@ index 0000000..97a049b
+ * @param[in] userName - Name of the user
+ * @param[in] enabled - Status of the user: enabled / disabled?
+ */
-+ void updateUserStatus(const std::string &userName,
-+ const bool &enabled) const;
++ void updateUserStatus(const std::string& userName,
++ const bool& enabled) const;
+
+ /** @brief Verify if user is enabled or not
+ * If enabled returns true
@@ -1635,24 +1642,24 @@ index 0000000..97a049b
+ *
+ * @param[in] userName - Name of the user
+ */
-+ bool isUserEnabled(const std::string &userName) const;
++ bool isUserEnabled(const std::string& userName) const;
+
+ /** @brief Get the list of groups a user belongs to
+ *
+ * @param[in] userName - Name of the user
+ */
-+ std::vector<std::string> getUserGroups(const std::string &userName) const;
++ std::vector<std::string> getUserGroups(const std::string& userName) const;
+
+ private:
+ // User service implementation.
-+ void setServiceImpl(const ServiceType &srvcType,
-+ const std::vector<std::string> &groups,
-+ const std::vector<std::string> &privs);
++ void setServiceImpl(const ServiceType& srvcType,
++ const std::vector<std::string>& groups,
++ const std::vector<std::string>& privs);
+ std::unique_ptr<UserServiceInterface> usrSrvcImpl;
+};
+
+} // namespace user
+} // namespace phosphor
--
-2.7.4
+2.17.1
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/users/phosphor-user-manager/0006-Use-groupmems-instead-of-getgrnam_r-due-to-overlay.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/users/phosphor-user-manager/0006-Use-groupmems-instead-of-getgrnam_r-due-to-overlay.patch
index 2abfeb78c..7a0eff80e 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/users/phosphor-user-manager/0006-Use-groupmems-instead-of-getgrnam_r-due-to-overlay.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/users/phosphor-user-manager/0006-Use-groupmems-instead-of-getgrnam_r-due-to-overlay.patch
@@ -1,7 +1,7 @@
-From a78bad158bca59dadb93c9c52d6daefa1c52b9cf Mon Sep 17 00:00:00 2001
+From 06064b3d6e56f4e13e6b85552f8525b74d9f1931 Mon Sep 17 00:00:00 2001
From: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
Date: Mon, 24 Feb 2020 13:37:12 +0530
-Subject: [PATCH] Use groupmems instead of getgrnam_r due to overlay
+Subject: [PATCH 2/2] Use groupmems instead of getgrnam_r due to overlay
With JFFS2 overlay, getgrnam_r during initial time returns the
old group details as per the lower dir, instead of the overlay one
@@ -26,18 +26,18 @@ Signed-off-by: jayaprakash Mutyala <mutyalax.jayaprakash@intel.com>
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/user_service.cpp b/user_service.cpp
-index c3c45bd..0a6b171 100644
+index ad4e510..89b27ed 100644
--- a/user_service.cpp
+++ b/user_service.cpp
-@@ -143,28 +143,26 @@ class ShadowService : public phosphor::user::UserServiceInterface
- getUsersInGroup(const std::string &groupName) const override
+@@ -147,28 +147,26 @@ class ShadowService : public phosphor::user::UserServiceInterface
+ getUsersInGroup(const std::string& groupName) const override
{
std::vector<std::string> usersInGroup;
- // Should be more than enough to get the pwd structure.
- std::array<char, 4096> buffer{};
- struct group grp;
-- struct group *grpPtr = &grp;
-- struct group *resultPtr;
+- struct group* grpPtr = &grp;
+- struct group* resultPtr;
-
- int status = getgrnam_r(groupName.c_str(), grpPtr, buffer.data(),
- buffer.max_size(), &resultPtr);
@@ -54,7 +54,7 @@ index c3c45bd..0a6b171 100644
+ "-g", groupName.c_str());
}
- else
-+ catch (const phosphor::user::InternalFailure &e)
++ catch (const phosphor::user::InternalFailure& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"Group not found",
@@ -72,5 +72,5 @@ index c3c45bd..0a6b171 100644
return usersInGroup;
}
--
-2.7.4
+2.17.1
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/users/phosphor-user-manager_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/users/phosphor-user-manager_%.bbappend
index 2b90b01e5..0b3d54986 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/users/phosphor-user-manager_%.bbappend
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/users/phosphor-user-manager_%.bbappend
@@ -1,7 +1,7 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI = "git://github.com/openbmc/phosphor-user-manager"
-SRCREV = "703131fa01422bc28675f5d629edb98d285a1bc4"
+SRCREV = "9638afb9aa848aa0e696c2447e0fbc70a0aa5eed"
EXTRA_OECONF += "${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'allow-root-login' ], '', '--disable-root_user_mgmt', d)}"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/phosphor-watchdog_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/phosphor-watchdog_%.bbappend
index f0b8e8f23..75f04e2ab 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/phosphor-watchdog_%.bbappend
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/phosphor-watchdog_%.bbappend
@@ -1,6 +1,5 @@
FILESEXTRAPATHS_append := ":${THISDIR}/${PN}"
-SRCREV = "c35135d32f9cb84b62de7b72eee3a2e87b4b3d4d"
SRC_URI += "file://0001-Customize-phosphor-watchdog-for-Intel-platforms.patch \
"
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/webui/webui-vue_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/webui/webui-vue_%.bbappend
index c93a2e96b..7dfdc5525 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/webui/webui-vue_%.bbappend
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/webui/webui-vue_%.bbappend
@@ -1,6 +1,6 @@
# Enable downstream autobump
SRC_URI = "git://github.com/openbmc/webui-vue.git"
-SRCREV = "391f94921bffb243d1eb3d72a49402a930b42160"
+SRCREV = "7006806d21cf8d13666524a8124b8395f2f1e156"
do_compile_prepend() {
cp -vf ${S}/.env.intel ${S}/.env