You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
package grid
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"net/http"
|
|
|
|
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
|
|
|
|
"strconv"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// SetCPUAllocationParameterRequest for setting CPU allocation parameter
|
|
|
|
|
type SetCPUAllocationParameterRequest struct {
|
|
|
|
|
// Grid ID
|
|
|
|
|
// Required: true
|
|
|
|
|
GridID uint64 `url:"gridId" json:"gridId" validate:"required"`
|
|
|
|
|
|
|
|
|
|
// CPU allocation parameter.
|
|
|
|
|
// If "strict" VM can't be run if not enough CPU resources.
|
|
|
|
|
// "loose" allow running VM if not enough resources.
|
|
|
|
|
// Required: true
|
|
|
|
|
StrictLoose string `url:"strict_loose" json:"strict_loose" validate:"required,strict_loose"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetCPUAllocationParameter sets CPU allocation parameter
|
|
|
|
|
func (g Grid) SetCPUAllocationParameter(ctx context.Context, req SetCPUAllocationParameterRequest) (bool, error) {
|
|
|
|
|
err := validators.ValidateRequest(req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
url := "/cloudbroker/grid/setCpuAllocationParameter"
|
|
|
|
|
|
|
|
|
|
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result, err := strconv.ParseBool(string(res))
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
|
}
|