From ca67eae71bb7d6e160a4cfeda375c1432684fedd Mon Sep 17 00:00:00 2001 From: Nickle Wang Date: Wed, 3 Jan 2024 18:54:52 +0800 Subject: [PATCH] RedfishClientPkg/RedfishFeatureUtilityLib: use HTTP cache lib Use Redfish Http cache library to query Redfish service. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez --- .../Library/RedfishFeatureUtilityLib.h | 21 +----- .../RedfishFeatureUtilityInternal.h | 3 +- .../RedfishFeatureUtilityLib.c | 67 ++----------------- .../RedfishFeatureUtilityLib.inf | 3 +- 4 files changed, 9 insertions(+), 85 deletions(-) diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h index 24f0ad244..9513a6561 100644 --- a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h +++ b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h @@ -2,7 +2,7 @@ This file defines the Redfish Feature Utility Library interface. (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
- Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -18,25 +18,6 @@ #define REDFISH_ENABLE_SYSTEM_REBOOT() PcdSetBoolS(PcdRedfishSystemRebootRequired, TRUE) -/** - - Read redfish resource by given resource URI. - - @param[in] Service Redfish service instance to make query. - @param[in] ResourceUri Target resource URI. - @param[out] Response HTTP response from redfish service. - - @retval EFI_SUCCESS Resrouce is returned successfully. - @retval Others Errors occur. - -**/ -EFI_STATUS -GetResourceByUri ( - IN REDFISH_SERVICE *Service, - IN EFI_STRING ResourceUri, - OUT REDFISH_RESPONSE *Response - ); - /** Check if this is the Redpath array. Usually the Redpath array represents diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityInternal.h b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityInternal.h index 5d39984c0..b4cfca030 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityInternal.h +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityInternal.h @@ -2,7 +2,7 @@ Common header file for RedfishFeatureUtilityLib driver. (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
- Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -30,6 +30,7 @@ #include #include #include +#include #include diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c index 01c054ae3..34868a138 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c @@ -2,7 +2,7 @@ Redfish feature utility library implementation (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
- Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -147,7 +147,8 @@ SetEtagFromUri ( return Status; } - Status = GetResourceByUri (RedfishService, Uri, &Response); + ZeroMem (&Response, sizeof (Response)); + Status = RedfishHttpGetResource (RedfishService, Uri, &Response, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri)); return Status; @@ -1163,66 +1164,6 @@ ApplyFeatureSettingsBooleanArrayType ( return Status; } -/** - - Read redfish resource by given resource URI. - - @param[in] Service Redfish service instance to make query. - @param[in] ResourceUri Target resource URI. - @param[out] Response HTTP response from redfish service. - - @retval EFI_SUCCESS Resrouce is returned successfully. - @retval Others Errors occur. - -**/ -EFI_STATUS -GetResourceByUri ( - IN REDFISH_SERVICE *Service, - IN EFI_STRING ResourceUri, - OUT REDFISH_RESPONSE *Response - ) -{ - EFI_STATUS Status; - CHAR8 *AsciiResourceUri; - - if ((Service == NULL) || (Response == NULL) || IS_EMPTY_STRING (ResourceUri)) { - return EFI_INVALID_PARAMETER; - } - - AsciiResourceUri = StrUnicodeToAscii (ResourceUri); - if (AsciiResourceUri == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Get resource from redfish service. - // - Status = RedfishGetByUri ( - Service, - AsciiResourceUri, - Response - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: RedfishGetByUri to %a failed: %r\n", __func__, AsciiResourceUri, Status)); - if (Response->Payload != NULL) { - RedfishDumpPayload (Response->Payload); - RedfishFreeResponse ( - NULL, - 0, - NULL, - Response->Payload - ); - Response->Payload = NULL; - } - } - - if (AsciiResourceUri != NULL) { - FreePool (AsciiResourceUri); - } - - return Status; -} - /** Check if this is the Redpath array. Usually the Redpath array represents @@ -3704,7 +3645,7 @@ GetPendingSettings ( return EFI_NOT_FOUND; } - Status = GetResourceByUri (RedfishService, *SettingUri, SettingResponse); + Status = RedfishHttpGetResource (RedfishService, *SettingUri, SettingResponse, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: @Redfish.Settings exists, get resource from: %s failed: %r\n", __func__, *SettingUri, Status)); return Status; diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf index fd66b8ac3..718273b24 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf @@ -2,7 +2,7 @@ # INF for Redfish feature utility library. # # (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
-# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -46,6 +46,7 @@ PrintLib HttpLib RedfishDebugLib + RedfishHttpCacheLib [Protocols] gEdkIIRedfishETagProtocolGuid ## CONSUMED ##