From 9cc183a531e1e309a99784f65b15c0fb1a18ddef Mon Sep 17 00:00:00 2001 From: P Dheeraj Srujan Kumar Date: Fri, 6 May 2022 06:11:20 +0530 Subject: Update to internal 1-0.91-67 Signed-off-by: P Dheeraj Srujan Kumar --- ...rmwareResiliency-and-FirmwareUpdateStatus.patch | 138 ++++++ ...-Property-PhysicalContext-is-invalid-none.patch | 520 +++++++++++++++++++++ ...Severity-for-ServiceFailure-redfish-event.patch | 56 +++ .../bmcweb/0031-Change-PcieType-to-PCIeType.patch | 68 +++ ...-Define-Redfish-interface-Registries-Bios.patch | 11 +- ...fix-for-broken-feature-Pending-Attributes.patch | 43 +- .../0004-Add-Server-Sent-Events-support.patch | 38 +- .../0014-Fix-Event-Subscription-URI.patch | 37 ++ ...0004-Fixed-timestamp-in-telemetry-service.patch | 106 +++++ .../interfaces/bmcweb/telemetry/README | 5 +- ...-Return-404-for-POST-on-Proxy-InsertMedia.patch | 379 +++++++++++++++ 11 files changed, 1371 insertions(+), 30 deletions(-) create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0028-Add-FirmwareResiliency-and-FirmwareUpdateStatus.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0029-Fix-Property-PhysicalContext-is-invalid-none.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0030-Change-Severity-for-ServiceFailure-redfish-event.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0031-Change-PcieType-to-PCIeType.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0014-Fix-Event-Subscription-URI.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Fixed-timestamp-in-telemetry-service.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/vm/0008-Return-404-for-POST-on-Proxy-InsertMedia.patch (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb') diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0028-Add-FirmwareResiliency-and-FirmwareUpdateStatus.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0028-Add-FirmwareResiliency-and-FirmwareUpdateStatus.patch new file mode 100644 index 000000000..934573fd6 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0028-Add-FirmwareResiliency-and-FirmwareUpdateStatus.patch @@ -0,0 +1,138 @@ +From 377fce592890a6dcc8bd45b3ff25290c4edb8908 Mon Sep 17 00:00:00 2001 +From: Jayaprakash Mutyala +Date: Fri, 21 Jan 2022 23:11:27 +0000 +Subject: [PATCH] Add FirmwareResiliency and FirmwareUpdateStatus + +Panic word not suitable for Platform firmware resiliency events. Hence +add the following message registry for PFR events. +1. FirmwareResiliency for warning severity events. +2. FirmwareUpdateStatus for firmware update notifications with +OK severity. + +These message registries are implemented in the following review. +https://gerrit.openbmc-project.xyz/c/openbmc/pfr-manager/+/47609 + +Tested: +Redfish Service Validator test passed for this change. + +1. Update BMC firmware +POST: https:///redfish/v1/UpdateService/ + with binary file +After BMC reboots check for Event log in Redfish +Command: GET: https:///redfish/v1/Systems/system/LogServices/ + EventLog/Entries +Response: +{ + "@odata.id": "/redfish/v1/Systems/system/LogServices/ + EventLog/Entries/1618207226", + "@odata.type": "#LogEntry.v1_8_0.LogEntry", + "Created": "2021-04-12T06:00:26+00:00", + "EntryType": "Event", + "Id": "1618207226", + "Message": "Firmware update occurred due to BMC update + intent.", + "MessageArgs": [ + "BMC update intent" + ], + "MessageId": "OpenBMC.0.2.FirmwareUpdateStatus", + "Name": "System Event Log Entry", + "Severity": "OK" +} +2. Reset BMC. +Command: ipmitool raw 6 2 +After BMC reboots check for Event log in Redfish +Command: GET: https:///redfish/v1/Systems/system/LogServices/ + EventLog/Entries +Response: +{ + "@odata.id": "/redfish/v1/Systems/system/LogServices/ + EventLog/Entries/1618207249", + "@odata.type": "#LogEntry.v1_8_0.LogEntry", + "Created": "2021-04-12T06:02:49+00:00", + "EntryType": "Event", + "Id": "1618207249", + "Message": "Firmware resiliency event occurred due to BMC + reset detected.", + "MessageArgs": [ + "BMC reset detected" + ], + "MessageId": "OpenBMC.0.2.FirmwareResiliency", + "Name": "System Event Log Entry", + "Severity": "Warning" +} + +Signed-off-by: Jayaprakash Mutyala +Signed-off-by: Chalapathi Venkataramashetty +--- + .../registries/openbmc_message_registry.hpp | 33 ++++++++++++++++--- + 1 file changed, 29 insertions(+), 4 deletions(-) + +diff --git a/redfish-core/include/registries/openbmc_message_registry.hpp b/redfish-core/include/registries/openbmc_message_registry.hpp +index 967713f..3747aaf 100644 +--- a/redfish-core/include/registries/openbmc_message_registry.hpp ++++ b/redfish-core/include/registries/openbmc_message_registry.hpp +@@ -21,15 +21,15 @@ namespace redfish::message_registries::openbmc + const Header header = { + "Copyright 2018 OpenBMC. All rights reserved.", + "#MessageRegistry.v1_4_0.MessageRegistry", +- "OpenBMC.0.2.0", ++ "OpenBMC.0.3.0", + "OpenBMC Message Registry", + "en", + "This registry defines the base messages for OpenBMC.", + "OpenBMC", +- "0.2.0", ++ "0.3.0", + "OpenBMC", + }; +-constexpr std::array registry = { ++constexpr std::array registry = { + MessageEntry{ + "ADDDCCorrectable", + { +@@ -560,9 +560,21 @@ constexpr std::array registry = { + {"string"}, + "None.", + }}, ++ MessageEntry{"FirmwareResiliency", ++ { ++ "Indicates the reason for last firmware resiliency event.", ++ "Firmware resiliency event occurred due to %1.", ++ "Warning", ++ "Warning", ++ 1, ++ { ++ "string", ++ }, ++ "None.", ++ }}, + MessageEntry{"FirmwareResiliencyError", + { +- "Indicates firmware encountered resilience error.", ++ "Indicates firmware encountered resiliency error.", + "Firmware resiliency error. Error reason: %1.", + "Critical", + "Critical", +@@ -613,6 +625,19 @@ constexpr std::array registry = { + {"string", "string"}, + "None.", + }}, ++ MessageEntry{ ++ "FirmwareUpdateStatus", ++ { ++ "Indicates the reason for last firmware update on resiliency system.", ++ "Firmware update occurred due to %1.", ++ "OK", ++ "OK", ++ 1, ++ { ++ "string", ++ }, ++ "None.", ++ }}, + MessageEntry{ + "GeneralFirmwareSecurityViolation", + { +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0029-Fix-Property-PhysicalContext-is-invalid-none.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0029-Fix-Property-PhysicalContext-is-invalid-none.patch new file mode 100644 index 000000000..cf8148ff5 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0029-Fix-Property-PhysicalContext-is-invalid-none.patch @@ -0,0 +1,520 @@ +From bf7ef9a5b2e3a6cac3f418d3c7753f29bea66913 Mon Sep 17 00:00:00 2001 +From: sunitakx +Date: Tue, 18 Jan 2022 11:05:05 +0000 +Subject: [PATCH] [Fix]: Property PhysicalContext is invalid "none" + +Issue: Redfish validator is throwing error "PhysicalContext: +This type is invalid none" for multiple temperature sensors + +Endpoint : /redfish/v1/Chassis//Thermal#/Temperatures/ + +Root Cause : PhysicalContext Schema was missing from redfish schema +metadata + +Tested: Redfish validator script passed. + +*** /redfish/v1/Chassis//Thermal#/Temperatures/0 + Type (#Thermal.v1_3_0.Temperature), GET SUCCESS (time: 0) + PASS + +Signed-off-by: sunitakx +Change-Id: Ifbfe7d96e99030c0c5ba67a1aba5080cd049e57b +--- + scripts/update_schemas.py | 1 + + static/redfish/v1/$metadata/index.xml | 3 + + .../PhysicalContext/PhysicalContext.json | 62 +++ + .../v1/JsonSchemas/PhysicalContext/index.json | 22 ++ + .../redfish/v1/schema/PhysicalContext_v1.xml | 357 ++++++++++++++++++ + 5 files changed, 445 insertions(+) + create mode 100644 static/redfish/v1/JsonSchemas/PhysicalContext/PhysicalContext.json + create mode 100644 static/redfish/v1/JsonSchemas/PhysicalContext/index.json + create mode 100644 static/redfish/v1/schema/PhysicalContext_v1.xml + +diff --git a/scripts/update_schemas.py b/scripts/update_schemas.py +index eb6318f..3f0f57c 100755 +--- a/scripts/update_schemas.py ++++ b/scripts/update_schemas.py +@@ -65,6 +65,7 @@ include_list = [ + 'PCIeDeviceCollection', + 'PCIeFunction', + 'PCIeFunctionCollection', ++ 'PhysicalContext', + 'Power', + 'Privileges', # Used in Role + 'Processor', +diff --git a/static/redfish/v1/$metadata/index.xml b/static/redfish/v1/$metadata/index.xml +index c925581..9b080f3 100644 +--- a/static/redfish/v1/$metadata/index.xml ++++ b/static/redfish/v1/$metadata/index.xml +@@ -1568,6 +1568,9 @@ + + + ++ ++ ++ + + + +diff --git a/static/redfish/v1/JsonSchemas/PhysicalContext/PhysicalContext.json b/static/redfish/v1/JsonSchemas/PhysicalContext/PhysicalContext.json +new file mode 100644 +index 0000000..c9ffeee +--- /dev/null ++++ b/static/redfish/v1/JsonSchemas/PhysicalContext/PhysicalContext.json +@@ -0,0 +1,62 @@ ++{ ++ "$schema": "http://redfish.dmtf.org/schemas/v1/redfish-schema.v1_3_0.json", ++ "copyright": "Copyright 2014-2017 Distributed Management Task Force, Inc. (DMTF). For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright", ++ "definitions": { ++ "PhysicalContext": { ++ "deprecated": "This definition has been moved to the unversioned namespace so that external references can pick up changes over time.", ++ "enum": [ ++ "Room", ++ "Intake", ++ "Exhaust", ++ "Front", ++ "Back", ++ "Upper", ++ "Lower", ++ "CPU", ++ "GPU", ++ "Backplane", ++ "SystemBoard", ++ "PowerSupply", ++ "VoltageRegulator", ++ "StorageDevice", ++ "NetworkingDevice", ++ "ComputeBay", ++ "StorageBay", ++ "NetworkBay", ++ "ExpansionBay", ++ "PowerSupplyBay", ++ "Memory", ++ "Chassis", ++ "Fan" ++ ], ++ "enumDescriptions": { ++ "Back": "The back of the chassis.", ++ "Backplane": "A backplane within the chassis.", ++ "CPU": "A Processor (CPU).", ++ "Chassis": "The entire chassis.", ++ "ComputeBay": "Within a compute bay.", ++ "Exhaust": "The exhaust point of the chassis.", ++ "ExpansionBay": "Within an expansion bay.", ++ "Fan": "A fan.", ++ "Front": "The front of the chassis.", ++ "GPU": "A Graphics Processor (GPU).", ++ "Intake": "The intake point of the chassis.", ++ "Lower": "The lower portion of the chassis.", ++ "Memory": "A memory device.", ++ "NetworkBay": "Within a networking bay.", ++ "NetworkingDevice": "A networking device.", ++ "PowerSupply": "A power supply.", ++ "PowerSupplyBay": "Within a power supply bay.", ++ "Room": "The room.", ++ "StorageBay": "Within a storage bay.", ++ "StorageDevice": "A storage device.", ++ "SystemBoard": "The system board (PCB).", ++ "Upper": "The upper portion of the chassis.", ++ "VoltageRegulator": "A voltage regulator device." ++ }, ++ "type": "string" ++ } ++ }, ++ "title": "#PhysicalContext.v1_3_0" ++} ++ +diff --git a/static/redfish/v1/JsonSchemas/PhysicalContext/index.json b/static/redfish/v1/JsonSchemas/PhysicalContext/index.json +new file mode 100644 +index 0000000..729c0ca +--- /dev/null ++++ b/static/redfish/v1/JsonSchemas/PhysicalContext/index.json +@@ -0,0 +1,22 @@ ++{ ++ "@odata.context": "/redfish/v1/$metadata#JsonSchemaFile.JsonSchemaFile", ++ "@odata.id": "/redfish/v1/JsonSchemas/PhysicalContext", ++ "@odata.type": "#JsonSchemaFile.v1_0_2.JsonSchemaFile", ++ "Name": "PhysicalContext Schema File", ++ "Schema": "#PhysicalContext.PhysicalContext", ++ "Description": "PhysicalContext Schema File Location", ++ "Id": "PhysicalContext", ++ "Languages": [ ++ "en" ++ ], ++ "Languages@odata.count": 1, ++ "Location": [ ++ { ++ "Language": "en", ++ "PublicationUri": "http://redfish.dmtf.org/schemas/v1/PhysicalContext.json", ++ "Uri": "/redfish/v1/JsonSchemas/PhysicalContext/PhysicalContext.json" ++ } ++ ], ++ "Location@odata.count": 1 ++} ++ +diff --git a/static/redfish/v1/schema/PhysicalContext_v1.xml b/static/redfish/v1/schema/PhysicalContext_v1.xml +new file mode 100644 +index 0000000..4c54e3e +--- /dev/null ++++ b/static/redfish/v1/schema/PhysicalContext_v1.xml +@@ -0,0 +1,357 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0030-Change-Severity-for-ServiceFailure-redfish-event.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0030-Change-Severity-for-ServiceFailure-redfish-event.patch new file mode 100644 index 000000000..b2ff26c33 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0030-Change-Severity-for-ServiceFailure-redfish-event.patch @@ -0,0 +1,56 @@ +From 12adbae465b3f6b3dc8aa2a444bc295e8261c382 Mon Sep 17 00:00:00 2001 +From: Jayaprakash Mutyala +Date: Tue, 15 Feb 2022 10:14:57 +0000 +Subject: [PATCH] Change Severity for ServiceFailure redfish event + +During Ac cycle stress, at times some services may exit unsuccessfully. +This will not have any functionality impact. So updated Severity of +"ServiceFailure" redfish event to "Ok". + +Tested: +1. Redfish validator - passed for this with change +2. Killed couple of process and observed Redfish EventLog shows updated + Severity. +Redfish URI: +GET: https:///redfish/v1/Systems/system/LogServices/EventLog + /Entries +{ + "@odata.id": "/redfish/v1/Systems/system/LogServices/ + EventLog/Entries/1624604288", + "@odata.type": "#LogEntry.v1_4_0.LogEntry", + "Created": "2021-06-25T06:58:08+00:00", + "EntryType": "Event", + "Id": "1624604288", + "Message": "Service phosphor-ipmi-host.service has exited + unsuccessfully.", + "MessageArgs": [ + "phosphor-ipmi-host.service" + ], + "MessageId": "OpenBMC.0.1.ServiceFailure", + "Name": "System Event Log Entry", + "Severity": "OK" +} + +Signed-off-by: Jayaprakash Mutyala +--- + redfish-core/include/registries/openbmc_message_registry.hpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/redfish-core/include/registries/openbmc_message_registry.hpp b/redfish-core/include/registries/openbmc_message_registry.hpp +index 3747aaf..0b409cf 100644 +--- a/redfish-core/include/registries/openbmc_message_registry.hpp ++++ b/redfish-core/include/registries/openbmc_message_registry.hpp +@@ -2375,8 +2375,8 @@ constexpr std::array registry = { + { + "Indicates that a service has exited unsuccessfully.", + "Service %1 has exited unsuccessfully.", +- "Warning", +- "Warning", ++ "OK", ++ "OK", + 1, + {"string"}, + "None.", +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0031-Change-PcieType-to-PCIeType.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0031-Change-PcieType-to-PCIeType.patch new file mode 100644 index 000000000..71b364468 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0031-Change-PcieType-to-PCIeType.patch @@ -0,0 +1,68 @@ +From 5b69a40d50b7ca024dea83dbadcfdaa5e045918d Mon Sep 17 00:00:00 2001 +From: Anjaliintel-21 +Date: Tue, 15 Feb 2022 16:01:14 +0000 +Subject: [PATCH] Change PcieType to PCIeType + +In the patch:https://github.com/openbmc/bmcweb/commit/62cd45af311e7741064c114581ba34186d6e508c + +Mismatch of PCIeType from pcie.hpp to PCIeDevice_v1.xml.In function requestRoutesSystemPCIeDevice, +PCIeType mentioned for PCIeInterface details, was written as PcieType but in PCIeDevice_v1.xml, +property name is PCIeType which was giving error in the validator. + +Tested using RedfishServiceValidator: +*** /redfish/v1/Systems/system/PCIeDevices +Type (#PCIeDeviceCollection.PCIeDeviceCollection), GET SUCCESS (time: 1.35205) +PASS + +*** /redfish/v1/Systems/system/PCIeDevices/S0B1D0 +Type (#PCIeDevice.v1_4_0.PCIeDevice), GET SUCCESS (time: 1.290409) +PASS + +*** /redfish/v1/Systems/system/PCIeDevices/S0B1D0/PCIeFunctions +Type (#PCIeFunctionCollection.PCIeFunctionCollection), GET SUCCESS (time: 1.287055) +PASS + +*** /redfish/v1/Systems/system/PCIeDevices/S0B1D0/PCIeFunctions/0 +Type (#PCIeFunction.v1_2_0.PCIeFunction), GET SUCCESS (time: 1.336434) +PASS + +*** /redfish/v1/Systems/system/PCIeDevices/S0B2D0 +Type (#PCIeDevice.v1_4_0.PCIeDevice), GET SUCCESS (time: 1.282768) +PASS + +*** /redfish/v1/Systems/system/PCIeDevices/S0B2D0/PCIeFunctions +Type (#PCIeFunctionCollection.PCIeFunctionCollection), GET SUCCESS (time: 1.401044) +PASS + +*** /redfish/v1/Systems/system/PCIeDevices/S0B2D0/PCIeFunctions/0 +Type (#PCIeFunction.v1_2_0.PCIeFunction), GET SUCCESS (time: 1.286989) +PASS + +*** /redfish/v1/Systems/system/PCIeDevices/S0B3D0 +Type (#PCIeDevice.v1_4_0.PCIeDevice), GET SUCCESS (time: 1.331661) +PASS +Elapsed time: 0:01:17 +Counter({'metadataNamespaces': 2337, 'skipOptional': 67, 'pass': 51, 'passGet': 8, 'serviceNamespaces': 4}) +Validation has succeeded. + +Signed-off-by: Anjaliintel-21 +--- + redfish-core/lib/pcie.hpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp +index 1904c26..1b9e28e 100644 +--- a/redfish-core/lib/pcie.hpp ++++ b/redfish-core/lib/pcie.hpp +@@ -223,7 +223,7 @@ inline void requestRoutesSystemPCIeDevice(App& app) + return; + } + asyncResp->res +- .jsonValue["PCIeInterface"]["PcieType"] = ++ .jsonValue["PCIeInterface"]["PCIeType"] = + *generationInUse; + } + asyncResp->res.jsonValue["PCIeFunctions"] = { +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0001-Define-Redfish-interface-Registries-Bios.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0001-Define-Redfish-interface-Registries-Bios.patch index 19a392873..57c183c76 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0001-Define-Redfish-interface-Registries-Bios.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0001-Define-Redfish-interface-Registries-Bios.patch @@ -1,4 +1,4 @@ -From bde7f728d5a87522674bcd5515baaa02bf7b9373 Mon Sep 17 00:00:00 2001 +From 7956c74860a39e75d80f0caadcfbd5570569717d Mon Sep 17 00:00:00 2001 From: Kuiying Wang Date: Fri, 4 Sep 2020 19:24:25 +0800 Subject: [PATCH] Define Redfish interface "/Registries/Bios" and enable @@ -226,6 +226,7 @@ Oem - Resource.Oem No Optional Change-Id: Iecc61018c350f0b8c89df59b2864b941508b1916 Signed-off-by: Kuiying Wang Signed-off-by: Snehalatha Venkatesh +Signed-off-by: Smriti Ayushi --- redfish-core/include/redfish.hpp | 3 + .../include/registries/bios_registry.hpp | 41 ++ @@ -235,7 +236,7 @@ Signed-off-by: Snehalatha Venkatesh create mode 100644 redfish-core/include/registries/bios_registry.hpp diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp -index 0a97150..07a9417 100644 +index 2479332..8bd4bf8 100644 --- a/redfish-core/include/redfish.hpp +++ b/redfish-core/include/redfish.hpp @@ -148,7 +148,10 @@ class RedfishService @@ -297,7 +298,7 @@ index 0000000..c80937a +}; +} // namespace redfish::message_registries::bios diff --git a/redfish-core/lib/bios.hpp b/redfish-core/lib/bios.hpp -index c2fb284..87536d6 100644 +index c2fb284..9d7157c 100644 --- a/redfish-core/lib/bios.hpp +++ b/redfish-core/lib/bios.hpp @@ -3,8 +3,140 @@ @@ -451,7 +452,7 @@ index c2fb284..87536d6 100644 + {"SettingsObject", + {{"@odata.id", "/redfish/v1/Systems/system/Bios/Settings"}}}}; + asyncResp->res.jsonValue["AttributeRegistry"] = "BiosAttributeRegistry"; -+ asyncResp->res.jsonValue["Attributes"] = {}; ++ asyncResp->res.jsonValue["Attributes"] = nlohmann::json::object(); + + crow::connections::systemBus->async_method_call( + [asyncResp](const boost::system::error_code ec, @@ -835,7 +836,7 @@ index c2fb284..87536d6 100644 * BiosReset class supports handle POST method for Reset bios. * The class retrieves and sends data directly to D-Bus. diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp -index 43359e3..b2fb43c 100644 +index ae02189..510b19a 100644 --- a/redfish-core/lib/message_registries.hpp +++ b/redfish-core/lib/message_registries.hpp @@ -17,6 +17,7 @@ diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0006-Add-fix-for-broken-feature-Pending-Attributes.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0006-Add-fix-for-broken-feature-Pending-Attributes.patch index 85b5b3494..e7036c28c 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0006-Add-fix-for-broken-feature-Pending-Attributes.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0006-Add-fix-for-broken-feature-Pending-Attributes.patch @@ -1,6 +1,6 @@ -From 8225b2dc07279c65cdfe2ddc13964d84fd2ed8bb Mon Sep 17 00:00:00 2001 +From 5ba2b29277e982fddaf8622af39902b6a046e259 Mon Sep 17 00:00:00 2001 From: Arun Lal K M -Date: Tue, 4 Jan 2022 01:56:57 +0000 +Date: Wed, 19 Jan 2022 14:44:07 +0000 Subject: [PATCH] Add fix for broken feature 'Pending Attributes'. Fix is added for the following: @@ -11,6 +11,7 @@ Fix is added for the following: 5) POST to '/redfish/v1/Systems/system/Bios/Actions /Bios.ChangePassword/'. 6) Add support for Enumeration. +7) Support DMTF standard of displaying "Value" in BIOS attribute registries. Tested: By giving PATCH to 'redfish/v1/Systems/system/Bios/Settings' @@ -134,11 +135,11 @@ Validation has succeeded. Signed-off-by: Arun Lal K M Signed-off-by: Snehalatha Venkatesh --- - redfish-core/lib/bios.hpp | 592 ++++++++++++++++++++++++-------------- - 1 file changed, 383 insertions(+), 209 deletions(-) + redfish-core/lib/bios.hpp | 602 +++++++++++++++++++++++++------------- + 1 file changed, 391 insertions(+), 211 deletions(-) diff --git a/redfish-core/lib/bios.hpp b/redfish-core/lib/bios.hpp -index 0bb0b9e..69340eb 100644 +index f6d6eff..c327053 100644 --- a/redfish-core/lib/bios.hpp +++ b/redfish-core/lib/bios.hpp @@ -12,13 +12,15 @@ map{attributeName,struct{attributeType,readonlyStatus,displayname, @@ -637,9 +638,9 @@ index 0bb0b9e..69340eb 100644 BMCWEB_LOG_ERROR - << "doPatch resp_handler got error " << ec; + << "getBiosAttributes DBUS error: " << ec; - messages::internalError(asyncResp->res); - return; - } ++ messages::internalError(asyncResp->res); ++ return; ++ } + + const BiosBaseTableType* baseBiosTable = + std::get_if(&retBiosTable); @@ -647,9 +648,9 @@ index 0bb0b9e..69340eb 100644 + if (baseBiosTable == nullptr) + { + BMCWEB_LOG_ERROR << "baseBiosTable is empty."; -+ messages::internalError(asyncResp->res); -+ return; -+ } + messages::internalError(asyncResp->res); + return; + } + + PendingAttributesType pendingAttributes{}; + @@ -895,10 +896,11 @@ index 0bb0b9e..69340eb 100644 } if (optItemTypeRedfish == "OneOf") { -@@ -671,6 +817,17 @@ inline void requestRoutesBiosAttributeRegistry(App& app) +@@ -671,7 +817,21 @@ inline void requestRoutesBiosAttributeRegistry(App& app) std::get_if( &std::get( optItem)); +- optItemJson[optItemTypeRedfish] = + + if (!currValue) + { @@ -910,13 +912,18 @@ index 0bb0b9e..69340eb 100644 + continue; + } + - optItemJson[optItemTypeRedfish] = ++ optItemJson["ValueDisplayName"] = ++ currValue != nullptr ? *currValue ++ : ""; ++ optItemJson["ValueName"] = currValue != nullptr ? *currValue : ""; -@@ -681,6 +838,17 @@ inline void requestRoutesBiosAttributeRegistry(App& app) + } +@@ -681,7 +841,21 @@ inline void requestRoutesBiosAttributeRegistry(App& app) std::get_if( &std::get( optItem)); +- optItemJson[optItemTypeRedfish] = + + if (!currValue) + { @@ -928,10 +935,14 @@ index 0bb0b9e..69340eb 100644 + continue; + } + - optItemJson[optItemTypeRedfish] = ++ optItemJson["ValueDisplayName"] = ++ currValue != nullptr ? *currValue ++ : 0; ++ optItemJson["ValueName"] = currValue != nullptr ? *currValue : 0; -@@ -689,6 +857,12 @@ inline void requestRoutesBiosAttributeRegistry(App& app) + } +@@ -689,6 +863,12 @@ inline void requestRoutesBiosAttributeRegistry(App& app) optionsArray.push_back(optItemJson); } diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0004-Add-Server-Sent-Events-support.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0004-Add-Server-Sent-Events-support.patch index dfa67935c..760462154 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0004-Add-Server-Sent-Events-support.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0004-Add-Server-Sent-Events-support.patch @@ -1,4 +1,4 @@ -From ea7d0091545450721d8b9b901e2593401b50d24c Mon Sep 17 00:00:00 2001 +From 1b9e0f434a4c667f6edbaadb257f7a9709953429 Mon Sep 17 00:00:00 2001 From: AppaRao Puli Date: Fri, 12 Mar 2021 18:53:25 +0000 Subject: [PATCH] Add Server-Sent-Events support @@ -22,12 +22,15 @@ Tested: Change-Id: I36956565cbba30c2007852c9471f477f6d1736e9 Signed-off-by: AppaRao Puli Signed-off-by: P Dheeraj Srujan Kumar +Signed-off-by: Ankita Vilas Gawade + +%% original patch: 0004-Add-Server-Sent-Events-support.patch --- http/http_connection.hpp | 10 +- http/http_response.hpp | 7 +- - http/routing.hpp | 71 ++++++++++ - http/server_sent_event.hpp | 279 +++++++++++++++++++++++++++++++++++++ - 4 files changed, 362 insertions(+), 5 deletions(-) + http/routing.hpp | 71 +++++++++ + http/server_sent_event.hpp | 298 +++++++++++++++++++++++++++++++++++++ + 4 files changed, 381 insertions(+), 5 deletions(-) create mode 100644 http/server_sent_event.hpp diff --git a/http/http_connection.hpp b/http/http_connection.hpp @@ -180,10 +183,10 @@ index fe9c7e9..c748580 100644 self_t* self = static_cast(this); diff --git a/http/server_sent_event.hpp b/http/server_sent_event.hpp new file mode 100644 -index 0000000..41d18ed +index 0000000..c23a4ee --- /dev/null +++ b/http/server_sent_event.hpp -@@ -0,0 +1,279 @@ +@@ -0,0 +1,298 @@ +#pragma once +#include "http_request.hpp" + @@ -201,6 +204,8 @@ index 0000000..41d18ed + +namespace crow +{ ++constexpr auto inputBufferSize = 1024U * 64U; ++constexpr uint8_t maxFailCount = 5; + +struct SseConnection : std::enable_shared_from_this +{ @@ -443,6 +448,22 @@ index 0000000..41d18ed + } + rawData += "\n\n"; + ++ if (rawData.size() > inputBufferSize) ++ { ++ BMCWEB_LOG_DEBUG ++ << "Skipping Send Event/Report to SSE Subscription as Buffer Size Exceeded. Size: " ++ << rawData.size(); ++ failCount++; ++ if (failCount > maxFailCount) ++ { ++ BMCWEB_LOG_ERROR ++ << "Fail Count Threshold reached. Closing SSE Connection"; ++ close("max buffer size not suported"); ++ } ++ return; ++ } ++ failCount = 0; ++ + boost::asio::buffer_copy(inputBuffer.prepare(rawData.size()), + boost::asio::buffer(rawData)); + inputBuffer.commit(rawData.size()); @@ -454,8 +475,9 @@ index 0000000..41d18ed + Adaptor adaptor; + + boost::beast::flat_static_buffer<1024U * 8U> outputBuffer; -+ boost::beast::flat_static_buffer<1024U * 64U> inputBuffer; ++ boost::beast::flat_static_buffer inputBuffer; + bool doingWrite = false; ++ uint8_t failCount = 0; + + std::function&, const crow::Request&, + crow::Response&)> @@ -464,5 +486,5 @@ index 0000000..41d18ed +}; +} // namespace crow -- -2.17.1 +2.25.1 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0014-Fix-Event-Subscription-URI.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0014-Fix-Event-Subscription-URI.patch new file mode 100644 index 000000000..a06389c46 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0014-Fix-Event-Subscription-URI.patch @@ -0,0 +1,37 @@ +From 93daba6ca2de8a82492ea88a7da75a7d337123e1 Mon Sep 17 00:00:00 2001 +From: Gayathri Leburu +Date: Wed, 9 Feb 2022 10:45:19 +0000 +Subject: [PATCH] Fix Event Subscription URI + +While performing GET on /redfish/v1/EventService/Subscriptions/ results +in error 405 - Method not allowed. + +This commit fixes the subscription URI while registering the ROUTE i.e., +during BMCWEB_ROUTE. + +TESTED : + - GET on /redfish/v1/EventService/Subscriptions/ successfully returned + all the list of subscribed events. + +Signed-off-by: Gayathri Leburu +Change-Id: I0edcfd8403e0178fe84d6b8328dabad71c4d5c98 +--- + redfish-core/lib/event_service.hpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp +index 9b4f6bd..7359a82 100644 +--- a/redfish-core/lib/event_service.hpp ++++ b/redfish-core/lib/event_service.hpp +@@ -173,7 +173,7 @@ inline void requestRoutesSubmitTestEvent(App& app) + + inline void requestRoutesEventDestinationCollection(App& app) + { +- BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions") ++ BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions/") + .privileges(redfish::privileges::getEventDestinationCollection) + .methods(boost::beast::http::verb::get)( + [](const crow::Request&, +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Fixed-timestamp-in-telemetry-service.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Fixed-timestamp-in-telemetry-service.patch new file mode 100644 index 000000000..0db2d00ae --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Fixed-timestamp-in-telemetry-service.patch @@ -0,0 +1,106 @@ +From 45c367e066d36ed0f7a38a12c80c1a40930efdfb Mon Sep 17 00:00:00 2001 +From: Krzysztof Grobelny +Date: Wed, 29 Dec 2021 10:28:53 +0100 +Subject: [PATCH] Fixed timestamp in telemetry service + +Telemetry service is using timestamp with milliseconds accuracy. Bmcweb +code assumed that timestamp is in seconds which produced a bad result. +This patchset updates the APIs, and adds a getDateTimeUintMs method, +which can be used to convert a millisecond timestamp into a string. In +the future, this can be used to get more precision out of the API. + +Reference: '9.4.3. Date-Time values' +https://www.dmtf.org/sites/default/files/standards/documents/DSP0266_1.8.0.pdf + +Tested: +- Telemetry service timestamp show correct timestamp with milliseconds + precission. Example: 2022-01-11T13:06:58.648000+00:00 +- Other timestamps in bmcweb did not change +- All unit tests are passing + +Reference: Properties.Readings +https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Telemetry/Report.interface.yaml + +Signed-off-by: Krzysztof Grobelny +Signed-off-by: Ed Tanous +Change-Id: I5b40ef6889b5af8c045ec0d35a758967e53dbed2 +--- + http/utility.hpp | 28 +++++++++++++++++----------- + redfish-core/lib/metric_report.hpp | 4 ++-- + 2 files changed, 19 insertions(+), 13 deletions(-) + +diff --git a/http/utility.hpp b/http/utility.hpp +index 033755e..374caea 100644 +--- a/http/utility.hpp ++++ b/http/utility.hpp +@@ -572,29 +572,35 @@ inline bool base64Decode(const std::string_view input, std::string& output) + return true; + } + +-/** +- * Method returns Date Time information in the ISO extended format +- * +- * @param[in] timestamp in second since the Epoch; it can be negative +- * +- * @return Date Time in the ISO extended format +- */ +-inline std::string getDateTime(boost::posix_time::seconds secondsSinceEpoch) ++namespace details ++{ ++inline std::string getDateTime(boost::posix_time::milliseconds timeSinceEpoch) + { + boost::posix_time::ptime epoch(boost::gregorian::date(1970, 1, 1)); +- boost::posix_time::ptime time = epoch + secondsSinceEpoch; ++ boost::posix_time::ptime time = epoch + timeSinceEpoch; + // append zero offset to the end according to the Redfish spec for Date-Time + return boost::posix_time::to_iso_extended_string(time) + "+00:00"; + } ++} // namespace details + + inline std::string getDateTimeUint(uint64_t secondsSinceEpoch) + { +- return getDateTime(boost::posix_time::seconds(secondsSinceEpoch)); ++ boost::posix_time::seconds boostSeconds(secondsSinceEpoch); ++ return details::getDateTime( ++ boost::posix_time::milliseconds(boostSeconds.total_milliseconds())); ++} ++ ++inline std::string getDateTimeUintMs(uint64_t millisSecondsSinceEpoch) ++{ ++ return details::getDateTime( ++ boost::posix_time::milliseconds(millisSecondsSinceEpoch)); + } + + inline std::string getDateTimeStdtime(std::time_t secondsSinceEpoch) + { +- return getDateTime(boost::posix_time::seconds(secondsSinceEpoch)); ++ boost::posix_time::ptime time = ++ boost::posix_time::from_time_t(secondsSinceEpoch); ++ return boost::posix_time::to_iso_extended_string(time) + "+00:00"; + } + + /** +diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp +index b7ebb99..f933cd4 100644 +--- a/redfish-core/lib/metric_report.hpp ++++ b/redfish-core/lib/metric_report.hpp +@@ -28,7 +28,7 @@ inline nlohmann::json toMetricValues(const Readings& readings) + {"MetricId", id}, + {"MetricProperty", metadata}, + {"MetricValue", std::to_string(sensorValue)}, +- {"Timestamp", crow::utility::getDateTimeUint(timestamp)}, ++ {"Timestamp", crow::utility::getDateTimeUintMs(timestamp)}, + }); + } + +@@ -46,7 +46,7 @@ inline bool fillReport(nlohmann::json& json, const std::string& id, + telemetry::metricReportDefinitionUri + std::string("/") + id; + + const auto& [timestamp, readings] = timestampReadings; +- json["Timestamp"] = crow::utility::getDateTimeUint(timestamp); ++ json["Timestamp"] = crow::utility::getDateTimeUintMs(timestamp); + json["MetricValues"] = toMetricValues(readings); + return true; + } +-- +2.25.1 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 541fa6aba..9bb1e5eb9 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 @@ -9,4 +9,7 @@ Current revisions: file://telemetry/0002-Revert-Remove-LogService-from-TelemetryService.patch - Switched bmcweb to use new telemetry service API - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/44270/28 + file://telemetry/0003-Switched-bmcweb-to-use-new-telemetry-service-API.patch + +- Fixed timestamp in telemetry service + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/50027/3 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/vm/0008-Return-404-for-POST-on-Proxy-InsertMedia.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/vm/0008-Return-404-for-POST-on-Proxy-InsertMedia.patch new file mode 100644 index 000000000..2d9ab1dae --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/vm/0008-Return-404-for-POST-on-Proxy-InsertMedia.patch @@ -0,0 +1,379 @@ +From 793e4d6952b2a121da55d866eb510b26e179750c Mon Sep 17 00:00:00 2001 +From: Przemyslaw Czarnowski +Date: Fri, 4 Feb 2022 15:41:54 +0100 +Subject: [PATCH] Return 404 for POST on Proxy InsertMedia + +.../Actions/VirtualMedia.InsertMedia does not exist for proxy mode. But +it does for legacy, so handler needs to return 404 for proxy and run +mounting in legacy. Similar action has to be done for get, delete and +patch. + +As the check shares the same codebase besides the action itself, this +patch creates generic function for parsing GetManagedObjects, finding +valid VirtualMedia endpoint and invoking specific action handler. + +Tested: +Manually, with the following set of commands: +POST /Proxy /InsertAction : returned 404 +POST /Legacy/InsertAction : returned 200 (mounted) +GET /Proxy /InsertAction : returned 404 +GET /Legacy/InsertAction : returned 405 +PATCH /Proxy /InsertAction : returned 404 +PATCH /Legacy/InsertAction : returned 405 +DELETE/Proxy /InsertAction : returned 404 +DELETE/Legacy/InsertAction : returned 405 + +Signed-off-by: Przemyslaw Czarnowski +--- + redfish-core/lib/virtual_media.hpp | 265 ++++++++++++----------------- + 1 file changed, 108 insertions(+), 157 deletions(-) + +diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp +index da66b4b..6dfc726 100644 +--- a/redfish-core/lib/virtual_media.hpp ++++ b/redfish-core/lib/virtual_media.hpp +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + // for GetObjectType and ManagedObjectType + +@@ -32,13 +33,14 @@ namespace redfish + { + + /** +- * @brief Function checks if insert media request is Legacy or Proxy type +- * and sets suitable response code for unsupported REST method. ++ * @brief Function parses getManagedObject response, finds item, makes generic ++ * validation and invokes callback handler on this item. + * + */ +-void checkProxyMode(const std::shared_ptr& aResp, +- const crow::Request& req, const std::string& name, +- const std::string& resName) ++template ++void findItemAndRunHandler(const std::shared_ptr& aResp, ++ const crow::Request& req, const std::string& name, ++ const std::string& resName, T&& handler) + { + if (name != "bmc") + { +@@ -48,8 +50,8 @@ void checkProxyMode(const std::shared_ptr& aResp, + } + + crow::connections::systemBus->async_method_call( +- [aResp, req, resName](const boost::system::error_code ec, +- const GetObjectType& getObjectType) { ++ [aResp, req, resName, handler](const boost::system::error_code ec, ++ const GetObjectType& getObjectType) { + if (ec) + { + BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " +@@ -70,9 +72,9 @@ void checkProxyMode(const std::shared_ptr& aResp, + BMCWEB_LOG_DEBUG << "GetObjectType: " << service; + + crow::connections::systemBus->async_method_call( +- [service, resName, req, +- aResp](const boost::system::error_code ec, +- ManagedObjectType& subtree) { ++ [service, resName, req, aResp, ++ handler](const boost::system::error_code ec, ++ ManagedObjectType& subtree) { + if (ec) + { + BMCWEB_LOG_DEBUG << "DBUS response error"; +@@ -105,26 +107,8 @@ void checkProxyMode(const std::shared_ptr& aResp, + continue; + } + +- // Check if dbus path is Legacy type +- if (mode.filename() == "Legacy") +- { +- BMCWEB_LOG_DEBUG << "InsertMedia only allowed " +- "with POST method " +- "in legacy mode"; +- aResp->res.result( +- boost::beast::http::status::method_not_allowed); +- +- return; +- } +- // Check if dbus path is Proxy type +- if (mode.filename() == "Proxy") ++ if (handler(service, aResp, item) == true) + { +- // Not possible in proxy mode +- BMCWEB_LOG_DEBUG << "InsertMedia not " +- "allowed in proxy mode"; +- aResp->res.result( +- boost::beast::http::status::not_found); +- + return; + } + } +@@ -289,10 +273,7 @@ static std::optional + std::chrono::seconds(*timeoutValue + timeoutMarginSeconds)) + .count(); + } +- else +- { +- return std::nullopt; +- } ++ return std::nullopt; + } + + /** +@@ -972,14 +953,43 @@ struct InsertMediaActionParams + + inline void requestNBDVirtualMediaRoutes(App& app) + { ++ auto handler = []([[maybe_unused]] const std::string& service, ++ const std::shared_ptr& aResp, ++ std::pair& item) { ++ auto mode = item.first.parent_path(); ++ auto type = mode.parent_path(); ++ // Check if dbus path is Legacy type ++ if (mode.filename() == "Legacy") ++ { ++ BMCWEB_LOG_DEBUG << "InsertMedia only allowed " ++ "with POST method " ++ "in legacy mode"; ++ aResp->res.result(boost::beast::http::status::method_not_allowed); ++ ++ return true; ++ } ++ // Check if dbus path is Proxy type ++ if (mode.filename() == "Proxy") ++ { ++ // Not possible in proxy mode ++ BMCWEB_LOG_DEBUG << "InsertMedia not " ++ "allowed in proxy mode"; ++ aResp->res.result(boost::beast::http::status::not_found); ++ ++ return true; ++ } ++ return false; ++ }; + BMCWEB_ROUTE(app, "/redfish/v1/Managers//VirtualMedia//Actions/" + "VirtualMedia.InsertMedia") + .privileges({{"Login"}}) + .methods(boost::beast::http::verb::get)( +- [](const crow::Request& req, +- const std::shared_ptr& asyncResp, +- const std::string& name, const std::string& resName) { +- checkProxyMode(asyncResp, req, name, resName); ++ [handler](const crow::Request& req, ++ const std::shared_ptr& asyncResp, ++ const std::string& name, const std::string& resName) { ++ findItemAndRunHandler(asyncResp, req, name, resName, ++ std::move(handler)); + }); + + for (auto method : +@@ -991,10 +1001,12 @@ inline void requestNBDVirtualMediaRoutes(App& app) + "VirtualMedia.InsertMedia") + .privileges({{"ConfigureManager"}}) + .methods(method)( +- [](const crow::Request& req, +- const std::shared_ptr& asyncResp, +- const std::string& name, const std::string& resName) { +- checkProxyMode(asyncResp, req, name, resName); ++ [handler = std::move(handler)]( ++ const crow::Request& req, ++ const std::shared_ptr& asyncResp, ++ const std::string& name, const std::string& resName) { ++ findItemAndRunHandler(asyncResp, req, name, resName, ++ std::move(handler)); + }); + } + +@@ -1006,129 +1018,68 @@ inline void requestNBDVirtualMediaRoutes(App& app) + [](const crow::Request& req, + const std::shared_ptr& asyncResp, + const std::string& name, const std::string& resName) { +- if (name != "bmc") +- { +- messages::resourceNotFound(asyncResp->res, +- "VirtualMedia.Insert", resName); +- +- return; +- } +- InsertMediaActionParams actionParams; +- +- // Read obligatory parameters (url of +- // image) +- if (!json_util::readJson( +- req, asyncResp->res, "Image", actionParams.imageUrl, +- "WriteProtected", actionParams.writeProtected, +- "UserName", actionParams.userName, "Password", +- actionParams.password, "Inserted", +- actionParams.inserted, "TransferMethod", +- actionParams.transferMethod, "TransferProtocolType", +- actionParams.transferProtocolType)) +- { +- BMCWEB_LOG_DEBUG << "Image is not provided"; +- return; +- } +- +- bool paramsValid = validateParams( +- asyncResp->res, actionParams.imageUrl, +- actionParams.inserted, actionParams.transferMethod, +- actionParams.transferProtocolType); +- +- if (paramsValid == false) +- { +- return; +- } +- +- crow::connections::systemBus->async_method_call( +- [asyncResp, actionParams, +- resName](const boost::system::error_code ec, +- const GetObjectType& getObjectType) mutable { +- if (ec) ++ // handle legacy mode (parse parameters and start action ++ // for proxy mode return 404. ++ auto handler = ++ [req, resName]( ++ const std::string& service, ++ const std::shared_ptr& asyncResp, ++ std::pair& item) { ++ auto mode = item.first.parent_path(); ++ auto type = mode.parent_path(); ++ if (mode.filename() == "Proxy") + { +- BMCWEB_LOG_ERROR +- << "ObjectMapper::GetObject call failed: " +- << ec; +- messages::internalError(asyncResp->res); ++ // Not possible in proxy mode ++ BMCWEB_LOG_DEBUG << "InsertMedia not " ++ "allowed in proxy mode"; ++ messages::resourceNotFound( ++ asyncResp->res, "VirtualMedia.InsertMedia", ++ resName); + +- return; ++ return true; + } +- std::string service = getObjectType.begin()->first; +- BMCWEB_LOG_DEBUG << "GetObjectType: " << service; +- +- crow::connections::systemBus->async_method_call( +- [service, resName, actionParams, +- asyncResp](const boost::system::error_code ec, +- ManagedObjectType& subtree) mutable { +- if (ec) +- { +- BMCWEB_LOG_DEBUG << "DBUS response error"; + +- return; +- } +- +- for (const auto& object : subtree) +- { +- const std::string& path = +- static_cast( +- object.first); +- +- std::size_t lastIndex = path.rfind('/'); +- if (lastIndex == std::string::npos) +- { +- continue; +- } +- +- lastIndex += 1; +- +- if (path.substr(lastIndex) == resName) +- { +- lastIndex = path.rfind("Proxy"); +- if (lastIndex != std::string::npos) +- { +- // Not possible in proxy mode +- BMCWEB_LOG_DEBUG +- << "InsertMedia not " +- "allowed in proxy mode"; +- messages::resourceNotFound( +- asyncResp->res, +- "VirtualMedia.InsertMedia", +- resName); +- +- return; +- } ++ InsertMediaActionParams actionParams; ++ ++ // Read obligatory parameters (url of ++ // image) ++ if (!json_util::readJson( ++ req, asyncResp->res, "Image", ++ actionParams.imageUrl, "WriteProtected", ++ actionParams.writeProtected, "UserName", ++ actionParams.userName, "Password", ++ actionParams.password, "Inserted", ++ actionParams.inserted, "TransferMethod", ++ actionParams.transferMethod, ++ "TransferProtocolType", ++ actionParams.transferProtocolType)) ++ { ++ BMCWEB_LOG_DEBUG << "Image is not provided"; ++ return true; ++ } + +- lastIndex = path.rfind("Legacy"); +- if (lastIndex == std::string::npos) +- { +- continue; +- } ++ bool paramsValid = validateParams( ++ asyncResp->res, actionParams.imageUrl, ++ actionParams.inserted, actionParams.transferMethod, ++ actionParams.transferProtocolType); + +- // manager is irrelevant for +- // VirtualMedia dbus calls +- doMountVmLegacy( +- asyncResp, service, resName, +- actionParams.imageUrl, +- !(*actionParams.writeProtected), +- std::move(*actionParams.userName), +- std::move(*actionParams.password)); ++ if (paramsValid == false) ++ { ++ return true; ++ } + +- return; +- } +- } +- BMCWEB_LOG_DEBUG << "Parent item not found"; +- messages::resourceNotFound( +- asyncResp->res, "VirtualMedia", resName); +- }, +- service, "/xyz/openbmc_project/VirtualMedia", +- "org.freedesktop.DBus.ObjectManager", +- "GetManagedObjects"); +- }, +- "xyz.openbmc_project.ObjectMapper", +- "/xyz/openbmc_project/object_mapper", +- "xyz.openbmc_project.ObjectMapper", "GetObject", +- "/xyz/openbmc_project/VirtualMedia", +- std::array()); ++ // manager is irrelevant for ++ // VirtualMedia dbus calls ++ doMountVmLegacy(asyncResp, service, resName, ++ actionParams.imageUrl, ++ !(*actionParams.writeProtected), ++ std::move(*actionParams.userName), ++ std::move(*actionParams.password)); ++ ++ return true; ++ }; ++ findItemAndRunHandler(asyncResp, req, name, resName, handler); + }); + + BMCWEB_ROUTE( +-- +2.31.1 + -- cgit v1.2.3