From 20a969aab2ef3567b1a65bf1eee782fd1eb26e7a Mon Sep 17 00:00:00 2001 From: Mengling Ding Date: Thu, 10 Oct 2024 17:56:49 -0500 Subject: [PATCH] fix: fix the return mismatch on blade rename in cfm-service --- pkg/api/api_default_service.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/pkg/api/api_default_service.go b/pkg/api/api_default_service.go index 422cd38..049b8d1 100644 --- a/pkg/api/api_default_service.go +++ b/pkg/api/api_default_service.go @@ -566,7 +566,30 @@ func (cfm *CfmApiService) BladesUpdateById(ctx context.Context, applianceId stri return formatErrorResp(ctx, err.(*common.RequestError)) } - return openapi.Response(http.StatusOK, newBlade), nil + totals, err := newBlade.GetResourceTotals(ctx) + if err != nil { + return formatErrorResp(ctx, err.(*common.RequestError)) + } + + b := openapi.Blade{ + Id: newBlade.Id, + IpAddress: newBlade.GetNetIp(), + Port: int32(newBlade.GetNetPort()), + Status: string(newBlade.Status), + Ports: openapi.MemberItem{ + Uri: manager.GetCfmUriBladePorts(appliance.Id, newBlade.Id), + }, + Resources: openapi.MemberItem{ + Uri: manager.GetCfmUriBladeResources(appliance.Id, newBlade.Id), + }, + Memory: openapi.MemberItem{ + Uri: manager.GetCfmUriBladeMemory(appliance.Id, newBlade.Id), + }, + TotalMemoryAvailableMiB: totals.TotalMemoryAvailableMiB, + TotalMemoryAllocatedMiB: totals.TotalMemoryAllocatedMiB, + } + + return openapi.Response(http.StatusOK, b), nil } // BladesGetResourceById -