Skip to content

Commit

Permalink
feat/rename device in webui (#41)
Browse files Browse the repository at this point in the history
* fix: fix the return mismatch onr appliance rename in cfm-service

* feat: rename appliance by id

* fix: fix the return mismatch on blade rename in cfm-service

* feat: rename blade by id

* feat: remove blade resync button in the Basic Information component

* fix: fix the return mismatch on host rename in cfm-service

* feat: rename host by id and remove resync button in the basic information component

* fix: fix the data type mismatch problem
  • Loading branch information
Meng-20 authored Oct 15, 2024
1 parent 88fe381 commit 9b78d7d
Show file tree
Hide file tree
Showing 6 changed files with 932 additions and 74 deletions.
64 changes: 61 additions & 3 deletions pkg/api/api_default_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,19 @@ func (cfm *CfmApiService) AppliancesUpdateById(ctx context.Context, applianceId
return formatErrorResp(ctx, err.(*common.RequestError))
}

return openapi.Response(http.StatusOK, newAppliance), nil
a := openapi.Appliance{
Id: newAppliance.Id,
IpAddress: "", // Unused
Port: 0, // Unused
Status: "", // Unused
Blades: openapi.MemberItem{
Uri: manager.GetCfmUriBlades(newAppliance.Id),
},
TotalMemoryAvailableMiB: 0,
TotalMemoryAllocatedMiB: 0,
}

return openapi.Response(http.StatusOK, a), nil
}

// AppliancesResync -
Expand Down Expand Up @@ -554,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 -
Expand Down Expand Up @@ -1019,7 +1054,30 @@ func (cfm *CfmApiService) HostsUpdateById(ctx context.Context, hostId string, ne
return formatErrorResp(ctx, err.(*common.RequestError))
}

return openapi.Response(http.StatusOK, newHost), nil
totals, err := newHost.GetMemoryTotals(ctx)
if err != nil {
return formatErrorResp(ctx, err.(*common.RequestError))
}

h := openapi.Host{
Id: newHost.Id,
IpAddress: newHost.GetNetIp(),
Port: int32(newHost.GetNetPort()),
Status: string(newHost.Status),
Ports: openapi.MemberItem{
Uri: manager.GetCfmUriHostPorts(newHost.Id),
},
Memory: openapi.MemberItem{
Uri: manager.GetCfmUriHostMemory(newHost.Id),
},
MemoryDevices: openapi.MemberItem{
Uri: manager.GetCfmUriHostMemoryDevices(newHost.Id),
},
LocalMemoryMiB: totals.LocalMemoryMib,
RemoteMemoryMiB: totals.RemoteMemoryMib,
}

return openapi.Response(http.StatusOK, h), nil
}

// HostsResync -
Expand Down
Loading

0 comments on commit 9b78d7d

Please sign in to comment.