blob: a8bba16676ddb69042661bfbc59f81e2083cb4c3 [file] [log] [blame]
Christopher Meis59ef1e72025-04-16 08:53:25 +02001#pragma once
2
3#include <boost/asio/io_context.hpp>
Christopher Meis59ef1e72025-04-16 08:53:25 +02004#include <nlohmann/json.hpp>
5#include <sdbusplus/asio/connection.hpp>
6
Ed Tanousdbf95b22025-10-13 11:38:35 -07007#include <flat_map>
8
Christopher Meis59ef1e72025-04-16 08:53:25 +02009using DBusValueVariant =
10 std::variant<std::string, int64_t, uint64_t, double, int32_t, uint32_t,
11 int16_t, uint16_t, uint8_t, bool, std::vector<uint8_t>>;
Ed Tanousdbf95b22025-10-13 11:38:35 -070012using DBusInterface = std::flat_map<std::string, DBusValueVariant, std::less<>>;
13using DBusObject = std::flat_map<std::string, DBusInterface, std::less<>>;
Christopher Meis59ef1e72025-04-16 08:53:25 +020014
15constexpr const char* configurationOutDir = "/var/configuration/";
16constexpr const char* versionHashFile = "/var/configuration/version";
17constexpr const char* versionFile = "/etc/os-release";
18
19namespace em_utils
20{
21
22namespace properties
23{
24constexpr const char* interface = "org.freedesktop.DBus.Properties";
25constexpr const char* get = "Get";
26} // namespace properties
27
Christopher Meis59ef1e72025-04-16 08:53:25 +020028bool fwVersionIsSame();
29
Chau Ly79629442025-08-20 10:27:20 +000030void handleLeftOverTemplateVars(nlohmann::json::iterator& keyPair);
31
Christopher Meis59ef1e72025-04-16 08:53:25 +020032std::optional<std::string> templateCharReplace(
33 nlohmann::json::iterator& keyPair, const DBusObject& object, size_t index,
Chau Ly8ee43692025-10-09 07:22:08 +000034 const std::optional<std::string>& replaceStr = std::nullopt,
35 bool handleLeftOver = true);
Christopher Meis59ef1e72025-04-16 08:53:25 +020036
37std::optional<std::string> templateCharReplace(
38 nlohmann::json::iterator& keyPair, const DBusInterface& interface,
39 size_t index, const std::optional<std::string>& replaceStr = std::nullopt);
40
Christopher Meis811160e2025-08-08 08:48:37 +020041std::string buildInventorySystemPath(std::string& boardName,
42 const std::string& boardType);
43
Christopher Meis59ef1e72025-04-16 08:53:25 +020044} // namespace em_utils