- Remove RedfishHttpCacheLib and use EDK2 RedfishHttpLib. - Remove RedfishLib. - Remove CreatePayloadToPostResource and CreatePayloadToPatchResource because we no longer need them.
Signed-off-by: Nickle Wang <nick...@nvidia.com> Cc: Abner Chang <abner.ch...@amd.com> Cc: Igor Kulchytskyy <ig...@ami.com> --- .../RedfishFeatureUtilityLib.inf | 3 +- .../Library/RedfishFeatureUtilityLib.h | 46 +---- .../RedfishFeatureUtilityInternal.h | 3 +- .../RedfishFeatureUtilityLib.c | 182 +----------------- 4 files changed, 6 insertions(+), 228 deletions(-) diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf index d8f3da373..1cb2d5595 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf @@ -40,7 +40,7 @@ ConverterCommonLib DebugLib MemoryAllocationLib - RedfishLib + RedfishHttpLib RedfishPlatformConfigLib UefiLib UefiBootServicesTableLib @@ -48,7 +48,6 @@ PrintLib HttpLib RedfishDebugLib - RedfishHttpCacheLib [Protocols] gEdkIIRedfishETagProtocolGuid ## CONSUMED ## diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h index 1b6d3f4cf..ba9ea0150 100644 --- a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h +++ b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h @@ -12,7 +12,7 @@ #ifndef REDFISH_FEATURE_UTILITY_LIB_H_ #define REDFISH_FEATURE_UTILITY_LIB_H_ -#include <Library/RedfishLib.h> +#include <RedfishServiceData.h> #include <Protocol/EdkIIRedfishPlatformConfig.h> #include <Protocol/EdkIIRedfishInterchangeData.h> #include <RedfishJsonStructure/RedfishCsCommon.h> @@ -352,50 +352,6 @@ ApplyFeatureSettingsBooleanArrayType ( IN RedfishCS_bool_Array *ArrayHead ); -/** - - Create HTTP payload and send them to redfish service with POST method. - - @param[in] Service Redfish service. - @param[in] TargetPayload Target payload - @param[in] Json Data in JSON format. - @param[out] Location Returned location string from Redfish service. - @param[out] Etag Returned ETAG string from Redfish service. - - @retval EFI_SUCCESS Data is sent to redfish service successfully. - @retval Others Errors occur. - -**/ -EFI_STATUS -CreatePayloadToPostResource ( - IN REDFISH_SERVICE *Service, - IN REDFISH_PAYLOAD *TargetPayload, - IN CHAR8 *Json, - OUT EFI_STRING *Location, - OUT CHAR8 **Etag - ); - -/** - - Create HTTP payload and send them to redfish service with PATCH method. - - @param[in] Service Redfish service. - @param[in] TargetPayload Target payload - @param[in] Json Data in JSON format. - @param[out] Etag Returned ETAG string from Redfish service. - - @retval EFI_SUCCESS Data is sent to redfish service successfully. - @retval Others Errors occur. - -**/ -EFI_STATUS -CreatePayloadToPatchResource ( - IN REDFISH_SERVICE *Service, - IN REDFISH_PAYLOAD *TargetPayload, - IN CHAR8 *Json, - OUT CHAR8 **Etag - ); - /** Save Redfish URI in database for further use. diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityInternal.h b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityInternal.h index b4cfca030..b1c2ee468 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityInternal.h +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityInternal.h @@ -21,7 +21,7 @@ #include <Library/DebugLib.h> #include <Library/JsonLib.h> #include <Library/MemoryAllocationLib.h> -#include <Library/RedfishLib.h> +#include <Library/RedfishHttpLib.h> #include <Library/RedfishFeatureUtilityLib.h> #include <Library/RedfishPlatformConfigLib.h> #include <Library/UefiBootServicesTableLib.h> @@ -30,7 +30,6 @@ #include <Library/PrintLib.h> #include <Library/HttpLib.h> #include <Library/RedfishDebugLib.h> -#include <Library/RedfishHttpCacheLib.h> #include <Guid/VariableFormat.h> diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c index 21ce8ddad..cc2b37b79 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c @@ -154,7 +154,7 @@ SetEtagFromUri ( } ZeroMem (&Response, sizeof (Response)); - Status = RedfishHttpGetResource (RedfishService, Uri, &Response, TRUE); + Status = RedfishHttpGetResource (RedfishService, Uri, NULL, &Response, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri)); return Status; @@ -215,14 +215,7 @@ ON_RELEASE: FreePool (PendingSettingUri); } - if (Response.Payload != NULL) { - RedfishFreeResponse ( - Response.StatusCode, - Response.HeaderCount, - Response.Headers, - Response.Payload - ); - } + RedfishHttpFreeResponse (&Response); return Status; } @@ -1894,175 +1887,6 @@ CheckIsServerEtagSupported ( return FixedPcdGetBool (PcdRedfishServiceEtagSupported); } -/** - - Create HTTP payload and send them to redfish service with PATCH method. - - @param[in] Service Redfish service. - @param[in] TargetPayload Target payload - @param[in] Json Data in JSON format. - @param[out] Etag Returned ETAG string from Redfish service. - - @retval EFI_SUCCESS Data is sent to redfish service successfully. - @retval Others Errors occur. - -**/ -EFI_STATUS -CreatePayloadToPatchResource ( - IN REDFISH_SERVICE *Service, - IN REDFISH_PAYLOAD *TargetPayload, - IN CHAR8 *Json, - OUT CHAR8 **Etag OPTIONAL - ) -{ - REDFISH_PAYLOAD Payload; - EDKII_JSON_VALUE ResourceJsonValue; - REDFISH_RESPONSE PatchResponse; - EFI_STATUS Status; - - if ((Service == NULL) || (TargetPayload == NULL) || IS_EMPTY_STRING (Json)) { - return EFI_INVALID_PARAMETER; - } - - ResourceJsonValue = JsonLoadString (Json, 0, NULL); - Payload = RedfishCreatePayload (ResourceJsonValue, Service); - if (Payload == NULL) { - DEBUG ((DEBUG_ERROR, "%a:%d Failed to create JSON payload from JSON value!\n", __func__, __LINE__)); - Status = EFI_DEVICE_ERROR; - goto EXIT_FREE_JSON_VALUE; - } - - ZeroMem (&PatchResponse, sizeof (REDFISH_RESPONSE)); - Status = RedfishPatchToPayload (TargetPayload, Payload, &PatchResponse); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a:%d Failed to PATCH payload to Redfish service.\n", __func__, __LINE__)); - - DEBUG_CODE_BEGIN (); - DEBUG ((DEBUG_ERROR, "%a: Request:\n", __func__)); - DumpRedfishPayload (DEBUG_ERROR, Payload); - DEBUG ((DEBUG_ERROR, "%a: Response:\n", __func__)); - DumpRedfishResponse (__func__, DEBUG_ERROR, &PatchResponse); - DEBUG_CODE_END (); - goto EXIT_FREE_JSON_VALUE; - } - - // - // Find ETag - // - Status = GetHttpResponseEtag (&PatchResponse, Etag); - if (Status == EFI_UNSUPPORTED) { - Status = EFI_SUCCESS; - DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported on Redfish service.\n", __func__)); - } else { - Status = EFI_DEVICE_ERROR; - DEBUG ((DEBUG_ERROR, "%a: Fail to get Location header nor Location property from HTTP response payload.\n", __func__)); - } - - RedfishFreeResponse ( - PatchResponse.StatusCode, - PatchResponse.HeaderCount, - PatchResponse.Headers, - PatchResponse.Payload - ); - -EXIT_FREE_JSON_VALUE: - if (Payload != NULL) { - RedfishCleanupPayload (Payload); - } - - JsonValueFree (ResourceJsonValue); - - return Status; -} - -/** - - Create HTTP payload and send them to redfish service with POST method. - - @param[in] Service Redfish service. - @param[in] TargetPayload Target payload - @param[in] Json Data in JSON format. - @param[out] Location Returned location string from Redfish service. - @param[out] Etag Returned ETAG string from Redfish service. - - @retval EFI_SUCCESS Data is sent to redfish service successfully. - @retval Others Errors occur. - -**/ -EFI_STATUS -CreatePayloadToPostResource ( - IN REDFISH_SERVICE *Service, - IN REDFISH_PAYLOAD *TargetPayload, - IN CHAR8 *Json, - OUT EFI_STRING *Location, - OUT CHAR8 **Etag OPTIONAL - ) -{ - REDFISH_PAYLOAD Payload; - EDKII_JSON_VALUE ResourceJsonValue; - REDFISH_RESPONSE PostResponse; - EFI_STATUS Status; - - if ((Service == NULL) || (TargetPayload == NULL) || IS_EMPTY_STRING (Json) || (Location == NULL)) { - return EFI_INVALID_PARAMETER; - } - - ResourceJsonValue = JsonLoadString (Json, 0, NULL); - Payload = RedfishCreatePayload (ResourceJsonValue, Service); - if (Payload == NULL) { - DEBUG ((DEBUG_ERROR, "%a:%d Failed to create JSON payload from JSON value!\n", __func__, __LINE__)); - Status = EFI_DEVICE_ERROR; - goto EXIT_FREE_JSON_VALUE; - } - - ZeroMem (&PostResponse, sizeof (REDFISH_RESPONSE)); - Status = RedfishPostToPayload (TargetPayload, Payload, &PostResponse); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a:%d Failed to POST payload to Redfish service.\n", __func__, __LINE__)); - - DEBUG_CODE_BEGIN (); - DEBUG ((DEBUG_ERROR, "%a: Request:\n", __func__)); - DumpRedfishPayload (DEBUG_ERROR, Payload); - DEBUG ((DEBUG_ERROR, "%a: Response:\n", __func__)); - DumpRedfishResponse (__func__, DEBUG_ERROR, &PostResponse); - DEBUG_CODE_END (); - - goto EXIT_FREE_JSON_VALUE; - } - - Status = GetHttpResponseEtag (&PostResponse, Etag); - if (Status == EFI_UNSUPPORTED) { - Status = EFI_SUCCESS; - DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported on Redfish service.\n", __func__)); - } else if (EFI_ERROR (Status)) { - Status = EFI_DEVICE_ERROR; - DEBUG ((DEBUG_ERROR, "%a: Fail to get ETAG header nor ETAG property from HTTP response payload.\n", __func__)); - } - - // - // per Redfish spec. the URL of new resource will be returned in "Location" header. - // - Status = GetHttpResponseLocation (&PostResponse, Location); - if (EFI_ERROR (Status)) { - Status = EFI_DEVICE_ERROR; - DEBUG ((DEBUG_ERROR, "%a: Fail to get Location header nor Location proerty from HTTP response payload.\n", __func__)); - } - - RedfishFreeResponse ( - PostResponse.StatusCode, - PostResponse.HeaderCount, - PostResponse.Headers, - PostResponse.Payload - ); - - RedfishCleanupPayload (Payload); - -EXIT_FREE_JSON_VALUE: - JsonValueFree (ResourceJsonValue); - - return Status; -} - /** Return redfish URI by given config language. It's call responsibility to release returned buffer. @@ -3756,7 +3580,7 @@ GetPendingSettings ( return EFI_NOT_FOUND; } - Status = RedfishHttpGetResource (RedfishService, *SettingUri, SettingResponse, TRUE); + Status = RedfishHttpGetResource (RedfishService, *SettingUri, NULL, 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; -- 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116145): https://edk2.groups.io/g/devel/message/116145 Mute This Topic: https://groups.io/mt/104640226/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-