diff options
author | Tejas Patil <tejaspp@ami.com> | 2021-06-04 15:13:14 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2021-06-30 18:53:00 +0300 |
commit | 7c8c4058e265f784679b9144ff33b89f50f1bf59 (patch) | |
tree | a0d84205dc258a9023d83104e002a26ef263c9a3 | |
parent | 9ed366138a49ad8cded1817369294080a5f7162d (diff) | |
download | bmcweb-7c8c4058e265f784679b9144ff33b89f50f1bf59.tar.xz |
Add DateTime & Offset in Managers & LogServices
This commit adds the support for "DateTimeLocalOffset" property under
"/redfish/v1/Managers/bmc/" Redfish URI.
And it also adds the support for "DateTime" & "DateTimeLocalOffset"
properties under "/redfish/v1/Systems/system/LogServices/<id>/" &
"/redfish/v1/Managers/bmc/LogServices/<id>/" Redfish URI's.
These properties shows the current Date, Time & the UTC offset that the
current DateTime property value contains.
Tested:
- Redfish Validator Test passed.
curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X GET https://${bmc}/redfish/v1/Managers/bmc/
{
"@odata.id": "/redfish/v1/Managers/bmc",
"@odata.type": "#Manager.v1_11_0.Manager",
"Actions": {
"#Manager.Reset": {
"@Redfish.ActionInfo": "/redfish/v1/Managers/bmc/ResetActionInfo",
"target": "/redfish/v1/Managers/bmc/Actions/Manager.Reset"
},
"#Manager.ResetToDefaults": {
"ResetType@Redfish.AllowableValues": [
"ResetAll"
],
"target": "/redfish/v1/Managers/bmc/Actions/Manager.ResetToDefaults"
}
},
"DateTime": "2021-06-04T12:18:28+00:00",
"DateTimeLocalOffset": "+00:00",
"Description": "Baseboard Management Controller",
"EthernetInterfaces": {
"@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces"
},
"FirmwareVersion": "2.11.0-dev-114-gc1989599d",
"GraphicalConsole": {
"ConnectTypesSupported": [
"KVMIP"
],
"MaxConcurrentSessions": 4,
"ServiceEnabled": true
},
"Id": "bmc",
"LastResetTime": "2021-06-04T12:07:02+00:00",
"Links": {
"ActiveSoftwareImage": {
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/419c86fb"
},
"ManagerForServers": [
{
"@odata.id": "/redfish/v1/Systems/system"
}
],
"ManagerForServers@odata.count": 1,
"SoftwareImages": [
{
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/419c86fb"
}
],
"SoftwareImages@odata.count": 1
},
"LogServices": {
"@odata.id": "/redfish/v1/Managers/bmc/LogServices"
},
"ManagerType": "BMC",
"Model": "OpenBmc",
"Name": "OpenBmc Manager",
"NetworkProtocol": {
"@odata.id": "/redfish/v1/Managers/bmc/NetworkProtocol"
},
"Oem": {
"@odata.id": "/redfish/v1/Managers/bmc#/Oem",
"@odata.type": "#OemManager.Oem",
"OpenBmc": {
"@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc",
"@odata.type": "#OemManager.OpenBmc",
"Certificates": {
"@odata.id": "/redfish/v1/Managers/bmc/Truststore/Certificates"
}
}
},
"PowerState": "On",
"SerialConsole": {
"ConnectTypesSupported": [
"IPMI",
"SSH"
],
"MaxConcurrentSessions": 15,
"ServiceEnabled": true
},
"ServiceEntryPointUUID": "1832ebbb-0b54-44e9-90d7-b49108f6863c",
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
},
"UUID": "7fe3d13d-4ae7-4a4f-add1-2d60308124b4"
}
curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X GET https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/
{
"@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog",
"@odata.type": "#LogService.v1_1_0.LogService",
"Actions": {
"#LogService.ClearLog": {
"target": "/redfish/v1/Systems/system/LogServices/EventLog/Actions/LogService.ClearLog"
}
},
"DateTime": "2021-06-04T12:11:10+00:00",
"DateTimeLocalOffset": "+00:00",
"Description": "System Event Log Service",
"Entries": {
"@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries"
},
"Id": "EventLog",
"Name": "Event Log Service",
"OverWritePolicy": "WrapsWhenFull"
}
Signed-off-by: Tejas Patil <tejaspp@ami.com>
Change-Id: I416d13ae11e236cf4552f817a9bd69b48f9b5afb
-rw-r--r-- | Redfish.md | 4 | ||||
-rw-r--r-- | http/utility.hpp | 26 | ||||
-rw-r--r-- | redfish-core/include/event_service_manager.hpp | 21 | ||||
-rw-r--r-- | redfish-core/lib/log_services.hpp | 47 | ||||
-rw-r--r-- | redfish-core/lib/managers.hpp | 7 | ||||
-rw-r--r-- | redfish-core/lib/task.hpp | 2 |
6 files changed, 93 insertions, 14 deletions
diff --git a/Redfish.md b/Redfish.md index 103a22e6a9..9970240536 100644 --- a/Redfish.md +++ b/Redfish.md @@ -313,6 +313,7 @@ PowerControl Voltages PowerSupplies Redundancy ##### Manager - Actions - DateTime +- DateTimeLocalOffset - Description - EthernetInterfaces - FirmwareVersion @@ -553,6 +554,8 @@ the other. #### /redfish/v1/Systems/system/LogServices/EventLog/ ##### LogService - Actions +- DateTime +- DateTimeLocalOffset - Description - Entries - OverWritePolicy @@ -698,6 +701,7 @@ the other. - FirmwareInventory - HttpPushUri - HttpPushUriOptions +- MaxImageSizeBytes - ServiceEnabled #### /redfish/v1/UpdateService/FirmwareInventory/ diff --git a/http/utility.hpp b/http/utility.hpp index 19ffe9fe66..6f81be8b26 100644 --- a/http/utility.hpp +++ b/http/utility.hpp @@ -594,10 +594,32 @@ inline std::string getDateTime(const std::time_t& time) return redfishDateTime; } -inline std::string dateTimeNow() +/** + * Returns the current Date, Time & the local Time Offset + * infromation in a pair + * + * @param[in] None + * + * @return std::pair<std::string, std::string>, which consist + * of current DateTime & the TimeOffset strings respectively. + */ +inline std::pair<std::string, std::string> getDateTimeOffsetNow() { std::time_t time = std::time(nullptr); - return getDateTime(time); + std::string dateTime = getDateTime(time); + + /* extract the local Time Offset value from the + * recevied dateTime string. + */ + std::string timeOffset("Z00:00"); + std::size_t lastPos = dateTime.size(); + std::size_t len = timeOffset.size(); + if (lastPos > len) + { + timeOffset = dateTime.substr(lastPos - len); + } + + return std::make_pair(dateTime, timeOffset); } inline bool constantTimeStringCompare(const std::string_view a, diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp index 11190ef100..de4035616a 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -439,14 +439,15 @@ class Subscription logEntryArray.push_back({}); nlohmann::json& logEntryJson = logEntryArray.back(); - logEntryJson = {{"EventId", "TestID"}, - {"EventType", "Event"}, - {"Severity", "OK"}, - {"Message", "Generated test event"}, - {"MessageId", "OpenBMC.0.2.TestEventLog"}, - {"MessageArgs", nlohmann::json::array()}, - {"EventTimestamp", crow::utility::dateTimeNow()}, - {"Context", customText}}; + logEntryJson = { + {"EventId", "TestID"}, + {"EventType", "Event"}, + {"Severity", "OK"}, + {"Message", "Generated test event"}, + {"MessageId", "OpenBMC.0.2.TestEventLog"}, + {"MessageArgs", nlohmann::json::array()}, + {"EventTimestamp", crow::utility::getDateTimeOffsetNow().first}, + {"Context", customText}}; nlohmann::json msg = {{"@odata.type", "#Event.v1_4_0.Event"}, {"Id", std::to_string(eventSeqNum)}, @@ -1060,7 +1061,7 @@ class EventServiceManager nlohmann::json event = { {"EventId", eventId}, {"MemberId", memberId}, - {"EventTimestamp", crow::utility::dateTimeNow()}, + {"EventTimestamp", crow::utility::getDateTimeOffsetNow().first}, {"OriginOfCondition", origin}}; for (nlohmann::json::iterator it = event.begin(); it != event.end(); ++it) @@ -1116,7 +1117,7 @@ class EventServiceManager { std::shared_ptr<Subscription> entry = it.second; nlohmann::json msgJson = { - {"Timestamp", crow::utility::dateTimeNow()}, + {"Timestamp", crow::utility::getDateTimeOffsetNow().first}, {"OriginOfCondition", "/ibm/v1/HMC/BroadcastService"}, {"Name", "Broadcast Message"}, {"Message", broadcastMsg}}; diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index 2b064146e9..2800e86a12 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -995,6 +995,14 @@ inline void requestRoutesEventLogService(App& app) "System Event Log Service"; asyncResp->res.jsonValue["Id"] = "EventLog"; asyncResp->res.jsonValue["OverWritePolicy"] = "WrapsWhenFull"; + + std::pair<std::string, std::string> redfishDateTimeOffset = + crow::utility::getDateTimeOffsetNow(); + + asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first; + asyncResp->res.jsonValue["DateTimeLocalOffset"] = + redfishDateTimeOffset.second; + asyncResp->res.jsonValue["Entries"] = { {"@odata.id", "/redfish/v1/Systems/system/LogServices/EventLog/Entries"}}; @@ -1830,6 +1838,14 @@ inline void requestRoutesBMCJournalLogService(App& app) "BMC Journal Log Service"; asyncResp->res.jsonValue["Id"] = "BMC Journal"; asyncResp->res.jsonValue["OverWritePolicy"] = "WrapsWhenFull"; + + std::pair<std::string, std::string> redfishDateTimeOffset = + crow::utility::getDateTimeOffsetNow(); + asyncResp->res.jsonValue["DateTime"] = + redfishDateTimeOffset.first; + asyncResp->res.jsonValue["DateTimeLocalOffset"] = + redfishDateTimeOffset.second; + asyncResp->res.jsonValue["Entries"] = { {"@odata.id", "/redfish/v1/Managers/bmc/LogServices/Journal/Entries"}}; @@ -2071,6 +2087,14 @@ inline void requestRoutesBMCDumpService(App& app) asyncResp->res.jsonValue["Description"] = "BMC Dump LogService"; asyncResp->res.jsonValue["Id"] = "Dump"; asyncResp->res.jsonValue["OverWritePolicy"] = "WrapsWhenFull"; + + std::pair<std::string, std::string> redfishDateTimeOffset = + crow::utility::getDateTimeOffsetNow(); + asyncResp->res.jsonValue["DateTime"] = + redfishDateTimeOffset.first; + asyncResp->res.jsonValue["DateTimeLocalOffset"] = + redfishDateTimeOffset.second; + asyncResp->res.jsonValue["Entries"] = { {"@odata.id", "/redfish/v1/Managers/bmc/LogServices/Dump/Entries"}}; @@ -2174,6 +2198,14 @@ inline void requestRoutesSystemDumpService(App& app) "System Dump LogService"; asyncResp->res.jsonValue["Id"] = "Dump"; asyncResp->res.jsonValue["OverWritePolicy"] = "WrapsWhenFull"; + + std::pair<std::string, std::string> redfishDateTimeOffset = + crow::utility::getDateTimeOffsetNow(); + asyncResp->res.jsonValue["DateTime"] = + redfishDateTimeOffset.first; + asyncResp->res.jsonValue["DateTimeLocalOffset"] = + redfishDateTimeOffset.second; + asyncResp->res.jsonValue["Entries"] = { {"@odata.id", "/redfish/v1/Systems/system/LogServices/Dump/Entries"}}; @@ -2285,6 +2317,13 @@ inline void requestRoutesCrashdumpService(App& app) asyncResp->res.jsonValue["Id"] = "Oem Crashdump"; asyncResp->res.jsonValue["OverWritePolicy"] = "WrapsWhenFull"; asyncResp->res.jsonValue["MaxNumberOfRecords"] = 3; + + std::pair<std::string, std::string> redfishDateTimeOffset = + crow::utility::getDateTimeOffsetNow(); + asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first; + asyncResp->res.jsonValue["DateTimeLocalOffset"] = + redfishDateTimeOffset.second; + asyncResp->res.jsonValue["Entries"] = { {"@odata.id", "/redfish/v1/Systems/system/LogServices/Crashdump/Entries"}}; @@ -2730,6 +2769,14 @@ inline void requestRoutesPostCodesLogService(App& app) {"Entries", {{"@odata.id", "/redfish/v1/Systems/system/LogServices/" "PostCodes/Entries"}}}}; + + std::pair<std::string, std::string> redfishDateTimeOffset = + crow::utility::getDateTimeOffsetNow(); + asyncResp->res.jsonValue["DateTime"] = + redfishDateTimeOffset.first; + asyncResp->res.jsonValue["DateTimeLocalOffset"] = + redfishDateTimeOffset.second; + asyncResp->res.jsonValue["Actions"]["#LogService.ClearLog"] = { {"target", "/redfish/v1/Systems/system/LogServices/PostCodes/" diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp index b286f196f5..c6e601962c 100644 --- a/redfish-core/lib/managers.hpp +++ b/redfish-core/lib/managers.hpp @@ -1987,7 +1987,12 @@ inline void requestRoutesManager(App& app) "/redfish/v1/Managers/bmc/Actions/Manager.ResetToDefaults"; resetToDefaults["ResetType@Redfish.AllowableValues"] = {"ResetAll"}; - asyncResp->res.jsonValue["DateTime"] = crow::utility::dateTimeNow(); + std::pair<std::string, std::string> redfishDateTimeOffset = + crow::utility::getDateTimeOffsetNow(); + + asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first; + asyncResp->res.jsonValue["DateTimeLocalOffset"] = + redfishDateTimeOffset.second; // TODO (Gunnar): Remove these one day since moved to ComputerSystem // Still used by OCP profiles diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp index 33f983a2ad..bca25a16a7 100644 --- a/redfish-core/lib/task.hpp +++ b/redfish-core/lib/task.hpp @@ -464,7 +464,7 @@ inline void requestRoutesTaskService(App& app) asyncResp->res.jsonValue["Name"] = "Task Service"; asyncResp->res.jsonValue["Id"] = "TaskService"; asyncResp->res.jsonValue["DateTime"] = - crow::utility::dateTimeNow(); + crow::utility::getDateTimeOffsetNow().first; asyncResp->res.jsonValue["CompletedTaskOverWritePolicy"] = "Oldest"; |