Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use edk2 redfish http lib #79

Merged
merged 13 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .github/workflows/uncrustify-check.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# 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
#
Expand Down Expand Up @@ -40,12 +40,17 @@ fi

for file in $CHANGED_FILES
do
echo "Uncrustify check file: $file"
uncrustify -c $CONFIG_FILE -f $file --check
if [ $? -ne 0 ]
if [ -e "$file" ]
then
echo "Uncrustify check failure on file: $file"
FAILURE=1
echo "Uncrustify check file: $file"
uncrustify -c $CONFIG_FILE -f $file --check
if [ $? -ne 0 ]
then
echo "Uncrustify check failure on file: $file"
FAILURE=1
fi
else
echo "File does not exist (deleted file?): $file"
fi
done

Expand Down
92 changes: 41 additions & 51 deletions RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Redfish feature driver implementation - common functions

(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
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

Expand Down Expand Up @@ -68,7 +68,7 @@ RedfishConsumeResourceCommon (
// No change
//
DEBUG ((DEBUG_MANAGEABILITY, "%a, ETAG: %s has no change, ignore consume action\n", __func__, Private->Uri));
Status = EFI_ALREADY_STARTED;
Status = EFI_SUCCESS;
goto ON_RELEASE;
}

Expand Down Expand Up @@ -268,18 +268,18 @@ ProvisioningBiosResource (
IN EFI_STRING ConfigureLang
)
{
CHAR8 *Json;
CHAR8 *JsonWithAddendum;
EFI_STATUS Status;
EFI_STRING NewResourceLocation;
CHAR8 *EtagStr;
CHAR8 ResourceId[16];
CHAR8 *Json;
CHAR8 *JsonWithAddendum;
EFI_STATUS Status;
EFI_STRING NewResourceLocation;
CHAR8 ResourceId[16];
REDFISH_RESPONSE Response;

if (IS_EMPTY_STRING (ConfigureLang) || (Private == NULL)) {
return EFI_INVALID_PARAMETER;
}

EtagStr = NULL;
ZeroMem (&Response, sizeof (REDFISH_RESPONSE));
AsciiSPrint (ResourceId, sizeof (ResourceId), "%d", Index);

Status = ProvisioningBiosProperties (
Expand Down Expand Up @@ -327,27 +327,27 @@ ProvisioningBiosResource (
JsonWithAddendum = NULL;
}

Status = CreatePayloadToPostResource (Private->RedfishService, Private->Payload, Json, &NewResourceLocation, &EtagStr);
Status = RedfishHttpPostResource (Private->RedfishService, Private->Uri, Json, &Response);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, post Bios resource for %s failed: %r\n", __func__, ConfigureLang, Status));
goto RELEASE_RESOURCE;
}

ASSERT (NewResourceLocation != NULL);

//
// Keep location of new resource.
// Per Redfish spec. the URL of new resource will be returned in "Location" header.
//
if (NewResourceLocation != NULL) {
RedfishSetRedfishUri (ConfigureLang, NewResourceLocation);
Status = GetHttpResponseLocation (&Response, &NewResourceLocation);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: cannot find new location: %r\n", __func__, Status));
goto RELEASE_RESOURCE;
}

//
// Handle Etag
// Keep location of new resource.
//
if (EtagStr != NULL) {
SetEtagWithUri (EtagStr, NewResourceLocation);
FreePool (EtagStr);
if (NewResourceLocation != NULL) {
DEBUG ((DEBUG_MANAGEABILITY, "%a: Location: %s\n", __func__, NewResourceLocation));
RedfishSetRedfishUri (ConfigureLang, NewResourceLocation);
}

RELEASE_RESOURCE:
Expand All @@ -360,6 +360,8 @@ ProvisioningBiosResource (
FreePool (Json);
}

RedfishHttpFreeResponse (&Response);

return Status;
}

Expand Down Expand Up @@ -402,19 +404,19 @@ ProvisioningBiosExistResource (
IN REDFISH_RESOURCE_COMMON_PRIVATE *Private
)
{
EFI_STATUS Status;
EFI_STRING ConfigureLang;
CHAR8 *EtagStr;
CHAR8 *Json;
CHAR8 *JsonWithAddendum;
EFI_STATUS Status;
EFI_STRING ConfigureLang;
CHAR8 *Json;
CHAR8 *JsonWithAddendum;
REDFISH_RESPONSE Response;

if (Private == NULL) {
return EFI_INVALID_PARAMETER;
}

EtagStr = NULL;
Json = NULL;
ConfigureLang = NULL;
ZeroMem (&Response, sizeof (REDFISH_RESPONSE));

ConfigureLang = RedfishGetConfigLanguage (Private->Uri);
if (ConfigureLang == NULL) {
Expand Down Expand Up @@ -473,23 +475,17 @@ ProvisioningBiosExistResource (

DEBUG ((REDFISH_DEBUG_TRACE, "%a, provisioning existing resource for %s\n", __func__, ConfigureLang));
//
// PUT back to instance
// PATCH back to instance
//
Status = CreatePayloadToPatchResource (Private->RedfishService, Private->Payload, Json, &EtagStr);
Status = RedfishHttpPatchResource (Private->RedfishService, Private->Uri, Json, &Response);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, patch resource for %s failed: %r\n", __func__, ConfigureLang, Status));
}

//
// Handle Etag
//
if (EtagStr != NULL) {
SetEtagWithUri (EtagStr, Private->Uri);
FreePool (EtagStr);
}

ON_RELEASE:

RedfishHttpFreeResponse (&Response);

if (Json != NULL) {
FreePool (Json);
}
Expand Down Expand Up @@ -609,19 +605,19 @@ RedfishUpdateResourceCommon (
IN CHAR8 *InputJson
)
{
EFI_STATUS Status;
CHAR8 *Json;
CHAR8 *JsonWithAddendum;
EFI_STRING ConfigureLang;
CHAR8 *EtagStr;
EFI_STATUS Status;
CHAR8 *Json;
CHAR8 *JsonWithAddendum;
EFI_STRING ConfigureLang;
REDFISH_RESPONSE Response;

if ((Private == NULL) || IS_EMPTY_STRING (InputJson)) {
return EFI_INVALID_PARAMETER;
}

EtagStr = NULL;
Json = NULL;
ConfigureLang = NULL;
ZeroMem (&Response, sizeof (REDFISH_RESPONSE));

ConfigureLang = RedfishGetConfigLanguage (Private->Uri);
if (ConfigureLang == NULL) {
Expand Down Expand Up @@ -680,23 +676,17 @@ RedfishUpdateResourceCommon (

DEBUG ((REDFISH_DEBUG_TRACE, "%a, update resource for %s\n", __func__, ConfigureLang));
//
// PUT back to instance
// PATCH back to instance
//
Status = CreatePayloadToPatchResource (Private->RedfishService, Private->Payload, Json, &EtagStr);
Status = RedfishHttpPatchResource (Private->RedfishService, Private->Uri, Json, &Response);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, patch resource for %s failed: %r\n", __func__, ConfigureLang, Status));
}

//
// Handle Etag
//
if (EtagStr != NULL) {
SetEtagWithUri (EtagStr, Private->Uri);
FreePool (EtagStr);
}

ON_RELEASE:

RedfishHttpFreeResponse (&Response);

if (Json != NULL) {
FreePool (Json);
}
Expand Down
Loading
Loading