diff options
author | Ed Tanous <edtanous@google.com> | 2022-02-08 11:23:54 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-08-09 18:23:34 +0300 |
commit | 65e4f1f7f44677ebaa0373f153084b97ba1a1194 (patch) | |
tree | 281fa76d09b15f9171b62f5c6f3a77c16c60906b /redfish-core/include/resource_messages.hpp | |
parent | 4e7776689b7d66cfb3c199985c9e70fea7be77c2 (diff) | |
download | bmcweb-65e4f1f7f44677ebaa0373f153084b97ba1a1194.tar.xz |
Optimize resource event schema
Very similar to how the base registry was optimized for binary size,
optimize the resource event registry, by making the getLogFromRegistry a
common method for both registries.
Tested: Only usage of these calls appears to be in management console.
The code and pattern we're using here is well unit tested, and seems
reasonable that we could rely on the compile time checks, but if not, I
could use some help testing this.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I9cc442966df2ed301b14547727a5eb727c0c3a29
Diffstat (limited to 'redfish-core/include/resource_messages.hpp')
-rw-r--r-- | redfish-core/include/resource_messages.hpp | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/redfish-core/include/resource_messages.hpp b/redfish-core/include/resource_messages.hpp index 95ace94f78..e66ae6fc93 100644 --- a/redfish-core/include/resource_messages.hpp +++ b/redfish-core/include/resource_messages.hpp @@ -1,41 +1,43 @@ #pragma once +#include <nlohmann/json.hpp> +#include <registries/resource_event_message_registry.hpp> + namespace redfish { namespace messages { +nlohmann::json + getLogResourceEvent(redfish::registries::resource_event::Index name, + std::span<const std::string_view> args) +{ + size_t index = static_cast<size_t>(name); + if (index >= redfish::registries::resource_event::registry.size()) + { + return {}; + } + return getLogFromRegistry(redfish::registries::resource_event::header, + redfish::registries::resource_event::registry, + index, args); +} + inline nlohmann::json resourceChanged() { - return nlohmann::json{ - {"EventType", "ResourceChanged"}, - {"MessageId", "ResourceEvent.1.0.3.ResourceChanged"}, - {"Message", "One or more resource properties have changed."}, - {"MessageArgs", {}}, - {"Severity", "OK"}, - {"MessageSeverity", "OK"}}; + return getLogResourceEvent( + redfish::registries::resource_event::Index::resourceChanged, {}); } inline nlohmann::json resourceCreated() { - return nlohmann::json{ - {"EventType", "ResourceAdded"}, - {"MessageId", "ResourceEvent.1.0.3.ResourceCreated"}, - {"Message", "The resource has been created successfully."}, - {"MessageArgs", {}}, - {"Severity", "OK"}, - {"MessageSeverity", "OK"}}; + return getLogResourceEvent( + redfish::registries::resource_event::Index::resourceCreated, {}); } inline nlohmann::json resourceRemoved() { - return nlohmann::json{ - {"EventType", "ResourceRemoved"}, - {"MessageId", "ResourceEvent.1.0.3.ResourceRemoved"}, - {"Message", "The resource has been removed successfully."}, - {"MessageArgs", {}}, - {"Severity", "OK"}, - {"MessageSeverity", "OK"}}; + return getLogResourceEvent( + redfish::registries::resource_event::Index::resourceCreated, {}); } } // namespace messages |