v1.14.0
This commit is contained in:
47
pkg/cloudbroker/compute/check_compute_placement.go
Normal file
47
pkg/cloudbroker/compute/check_compute_placement.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// CheckComputePlacementRequest struct for check compute placement
|
||||
type CheckComputePlacementRequest struct {
|
||||
// IDs of compute instances to check
|
||||
// Required: true
|
||||
ComputeIDs []uint64 `url:"compute_ids" json:"compute_ids" validate:"required"`
|
||||
|
||||
// Filter by CPU and RAM when checking placement
|
||||
// Required: false
|
||||
// Default: true
|
||||
FilterByCPURAM interface{} `url:"filter_by_cpu_ram,omitempty" json:"filter_by_cpu_ram,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// CheckComputePlacement checks compute placement and returns structured result
|
||||
func (c Compute) CheckComputePlacement(ctx context.Context, req CheckComputePlacementRequest) (CheckComputePlacementResult, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/check_compute_placement"
|
||||
|
||||
if req.FilterByCPURAM == nil {
|
||||
req.FilterByCPURAM = true
|
||||
}
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := make(CheckComputePlacementResult)
|
||||
if err := json.Unmarshal(res, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -394,6 +394,9 @@ type ItemDisk struct {
|
||||
// BLK Discard
|
||||
BLKDiscard bool `json:"blkdiscard"`
|
||||
|
||||
// Block Size
|
||||
BlockSize string `json:"block_size"`
|
||||
|
||||
// Boot partition
|
||||
BootPartition uint64 `json:"bootPartition"`
|
||||
|
||||
@@ -1493,3 +1496,20 @@ type CloneStatus struct {
|
||||
// Progress percent
|
||||
ProgressPercent int `json:"progress_percent"`
|
||||
}
|
||||
|
||||
type CheckComputePlacementError struct {
|
||||
// Code
|
||||
Code int64 `json:"code"`
|
||||
|
||||
// Message
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type CheckComputePlacementItem struct {
|
||||
// Nide IDs
|
||||
NodeIDs []uint64 `json:"node_ids"`
|
||||
// error
|
||||
Error CheckComputePlacementError `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
type CheckComputePlacementResult map[string]CheckComputePlacementItem
|
||||
|
||||
Reference in New Issue
Block a user