From 74eec26b6ba3b14716db87cb8a837c33bdb69f62 Mon Sep 17 00:00:00 2001 From: Sunitha Harish Date: Thu, 25 Jun 2020 10:00:01 -0500 Subject: EventService: Add ResourceEvent registries This commit adds new files for DMTF resource registry and corresponding json message definitions. Tested by: 1. GET https://${bmc}/redfish/v1/Registries 2. GET https://${bmc}/redfish/v1/Registries/ResourceEvent 3. GET https://${bmc}/redfish/v1/Registries/ResourceEvent/ResourceEvent 4. Redfish Validator passed ( giving out messages as == Severity: The given property is deprecated by revision: This property has been deprecated in favor of MessageSeverity, which ties the values to the enumerations defined for the Health property within Status.) Signed-off-by: Sunitha Harish Change-Id: Iacbedaeca85c0dcfc955bcf9b10973c0d47c98e0 --- .../registries/resource_event_message_registry.hpp | 310 +++++++++++++++++++++ redfish-core/include/resource_messages.hpp | 42 +++ redfish-core/lib/message_registries.hpp | 18 +- 3 files changed, 369 insertions(+), 1 deletion(-) create mode 100644 redfish-core/include/registries/resource_event_message_registry.hpp create mode 100644 redfish-core/include/resource_messages.hpp (limited to 'redfish-core') diff --git a/redfish-core/include/registries/resource_event_message_registry.hpp b/redfish-core/include/registries/resource_event_message_registry.hpp new file mode 100644 index 0000000000..6790317ef6 --- /dev/null +++ b/redfish-core/include/registries/resource_event_message_registry.hpp @@ -0,0 +1,310 @@ +/* +// Copyright (c) 2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ +/**************************************************************** + * This is an auto-generated header which contains definitions + * for Redfish DMTF defined messages. + ***************************************************************/ +#pragma once +#include + +namespace redfish::message_registries::resource_event +{ +const Header header = { + "Copyright 2014-2020 DMTF in cooperation with the Storage Networking " + "Industry Association (SNIA). All rights reserved.", + "#MessageRegistry.v1_4_0.MessageRegistry", + "ResourceEvent.1.0.3", + "Resource Event Message Registry", + "en", + "This registry defines the messages to use for resource events.", + "ResourceEvent", + "1.0.3", + "DMTF", +}; +constexpr const char* url = + "https://redfish.dmtf.org/registries/ResourceEvent.1.0.3.json"; + +constexpr std::array registry = { + MessageEntry{"LicenseAdded", + { + "Indicates that a license has been added.", + "A license for '%1' has been added. The following " + "message was returned: '%2'.", + "OK", + "OK", + 2, + { + "string", + "string", + }, + "See vendor specific instructions for specific actions.", + }}, + MessageEntry{"LicenseChanged", + { + "Indicates that a license has changed.", + "A license for '%1' has changed. The following message " + "was returned: '%2'.", + "Warning", + "Warning", + 2, + { + "string", + "string", + }, + "See vendor specific instructions for specific actions.", + }}, + MessageEntry{"LicenseExpired", + { + "Indicates that a license has expired.", + "A license for '%1' has expired. The following message " + "was returned: '%2'.", + "Warning", + "Warning", + 2, + { + "string", + "string", + }, + "See vendor specific instructions for specific actions.", + }}, + MessageEntry{ + "ResourceChanged", + { + "Indicates that one or more resource properties have changed. " + "This is not used whenever there is another event message for that " + "specific change, such as only the state has changed.", + "One or more resource properties have changed.", + "OK", + "OK", + 0, + {}, + "None.", + }}, + MessageEntry{"ResourceCreated", + { + "Indicates that all conditions of a successful creation " + "operation have been met.", + "The resource has been created successfully.", + "OK", + "OK", + 0, + {}, + "None", + }}, + MessageEntry{"ResourceErrorThresholdCleared", + { + "Indicates that a specified resource property has cleared " + "its error threshold. Examples would be drive I/O " + "errors, or network link errors.", + "The resource property %1 has cleared the error threshold " + "of value %2.", + "OK", + "OK", + 2, + { + "string", + "number", + }, + "None.", + }}, + MessageEntry{"ResourceErrorThresholdExceeded", + { + "Indicates that a specified resource property has " + "exceeded its error threshold. Examples would be drive " + "I/O errors, or network link errors.", + "The resource property %1 has exceeded error threshold of " + "value %2.", + "Critical", + "Critical", + 2, + { + "string", + "number", + }, + "None.", + }}, + MessageEntry{ + "ResourceErrorsCorrected", + { + "Indicates that a specified resource property has corrected " + "errors. Examples would be drive I/O errors, or network link " + "errors.", + "The resource property %1 has corrected errors of type '%2'.", + "OK", + "OK", + 2, + { + "string", + "string", + }, + "None.", + }}, + MessageEntry{ + "ResourceErrorsDetected", + { + "Indicates that a specified resource property has detected errors. " + " Examples would be drive I/O errors, or network link errors.", + "The resource property %1 has detected errors of type '%2'.", + "Warning", + "Warning", + 2, + { + "string", + "string", + }, + "Resolution dependent upon error type.", + }}, + MessageEntry{"ResourceRemoved", + { + "Indicates that all conditions of a successful remove " + "operation have been met.", + "The resource has been removed successfully.", + "OK", + "OK", + 0, + {}, + "None", + }}, + MessageEntry{"ResourceSelfTestCompleted", + { + "Indicates that a self-test has completed.", + "A self-test has completed.", + "OK", + "OK", + 0, + {}, + "None.", + }}, + MessageEntry{"ResourceSelfTestFailed", + { + "Indicates that a self-test has failed. Suggested " + "resolution may be provided as OEM data.", + "A self-test has failed. The following message was " + "returned: '%1'.", + "Critical", + "Critical", + 1, + { + "string", + }, + "See vendor specific instructions for specific actions.", + }}, + MessageEntry{ + "ResourceStatusChangedCritical", + { + "Indicates that the health of a resource has changed to Critical.", + "The health of resource `%1` has changed to %2.", + "Critical", + "Critical", + 2, + { + "string", + "string", + }, + "None.", + }}, + MessageEntry{ + "ResourceStatusChangedOK", + { + "Indicates that the health of a resource has changed to OK.", + "The health of resource '%1' has changed to %2.", + "OK", + "OK", + 2, + { + "string", + "string", + }, + "None.", + }}, + MessageEntry{ + "ResourceStatusChangedWarning", + { + "Indicates that the health of a resource has changed to Warning.", + "The health of resource `%1` has changed to %2.", + "Warning", + "Warning", + 2, + { + "string", + "string", + }, + "None.", + }}, + MessageEntry{ + "ResourceVersionIncompatible", + { + "Indicates that an incompatible version of software has been " + "detected. Examples may be after a component or system level " + "software update.", + "An incompatible version of software '%1' has been detected.", + "Warning", + "Warning", + 1, + { + "string", + }, + "Compare the version of the resource with the compatible version " + "of the software.", + }}, + MessageEntry{"ResourceWarningThresholdCleared", + { + "Indicates that a specified resource property has cleared " + "its warning threshold. Examples would be drive I/O " + "errors, or network link errors. Suggested resolution " + "may be provided as OEM data.", + "The resource property %1 has cleared the warning " + "threshold of value %2.", + "OK", + "OK", + 2, + { + "string", + "number", + }, + "None.", + }}, + MessageEntry{"ResourceWarningThresholdExceeded", + { + "Indicates that a specified resource property has " + "exceeded its warning threshold. Examples would be drive " + "I/O errors, or network link errors. Suggested " + "resolution may be provided as OEM data.", + "The resource property %1 has exceeded its warning " + "threshold of value %2.", + "Warning", + "Warning", + 2, + { + "string", + "number", + }, + "None.", + }}, + MessageEntry{ + "URIForResourceChanged", + { + "Indicates that the URI for a resource has changed. Examples for " + "this would be physical component replacement or redistribution.", + "The URI for the resource has changed.", + "OK", + "OK", + 0, + {}, + "None.", + }}, +}; +} // namespace redfish::message_registries::resource_event diff --git a/redfish-core/include/resource_messages.hpp b/redfish-core/include/resource_messages.hpp new file mode 100644 index 0000000000..4ff1c86967 --- /dev/null +++ b/redfish-core/include/resource_messages.hpp @@ -0,0 +1,42 @@ +#pragma once + +namespace redfish +{ +namespace messages +{ + +nlohmann::json ResourceChanged(void) +{ + return nlohmann::json{ + {"EventType", "ResourceChanged"}, + {"MessageId", "ResourceEvent.1.0.3.ResourceChanged"}, + {"Message", "One or more resource properties have changed."}, + {"MessageArgs", {}}, + {"Severity", "OK"}, + {"MessageSeverity", "OK"}}; +} + +nlohmann::json ResourceCreated(void) +{ + return nlohmann::json{ + {"EventType", "ResourceAdded"}, + {"MessageId", "ResourceEvent.1.0.3.ResourceCreated"}, + {"Message", "The resource has been created successfully."}, + {"MessageArgs", {}}, + {"Severity", "OK"}, + {"MessageSeverity", "OK"}}; +} + +nlohmann::json ResourceRemoved(void) +{ + return nlohmann::json{ + {"EventType", "ResourceRemoved"}, + {"MessageId", "ResourceEvent.1.0.3.ResourceRemoved"}, + {"Message", "The resource has been removed successfully."}, + {"MessageArgs", {}}, + {"Severity", "OK"}, + {"MessageSeverity", "OK"}}; +} + +} // namespace messages +} // namespace redfish diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp index 89538f3f15..57e0ad2433 100644 --- a/redfish-core/lib/message_registries.hpp +++ b/redfish-core/lib/message_registries.hpp @@ -19,6 +19,7 @@ #include "registries.hpp" #include "registries/base_message_registry.hpp" #include "registries/openbmc_message_registry.hpp" +#include "registries/resource_event_message_registry.hpp" #include "registries/task_event_message_registry.hpp" namespace redfish @@ -56,10 +57,11 @@ class MessageRegistryFileCollection : public Node {"@odata.id", "/redfish/v1/Registries"}, {"Name", "MessageRegistryFile Collection"}, {"Description", "Collection of MessageRegistryFiles"}, - {"Members@odata.count", 3}, + {"Members@odata.count", 4}, {"Members", {{{"@odata.id", "/redfish/v1/Registries/Base"}}, {{"@odata.id", "/redfish/v1/Registries/TaskEvent"}}, + {{"@odata.id", "/redfish/v1/Registries/ResourceEvent"}}, {{"@odata.id", "/redfish/v1/Registries/OpenBMC"}}}}}; res.end(); @@ -113,6 +115,11 @@ class MessageRegistryFile : public Node header = &message_registries::openbmc::header; dmtf.clear(); } + else if (registry == "ResourceEvent") + { + header = &message_registries::resource_event::header; + url = message_registries::resource_event::url; + } else { messages::resourceNotFound( @@ -207,6 +214,15 @@ class MessageRegistry : public Node registryEntries.emplace_back(&entry); } } + else if (registry == "ResourceEvent") + { + header = &message_registries::resource_event::header; + for (const message_registries::MessageEntry& entry : + message_registries::resource_event::registry) + { + registryEntries.emplace_back(&entry); + } + } else { messages::resourceNotFound( -- cgit v1.2.3