v15.3.0
This commit is contained in:
@@ -177,6 +177,12 @@ type RecordZone struct {
|
||||
|
||||
// CPU alignment profiles
|
||||
CpuAlignmentProfiles []CpuAlignmentProfile `json:"cpu_alignment_profiles"`
|
||||
|
||||
// Reserved CPU
|
||||
ReservedCPU uint64 `json:"reserved_cpu"`
|
||||
|
||||
// Reserved RAM
|
||||
ReservedRAM uint64 `json:"reserved_ram"`
|
||||
}
|
||||
|
||||
// A zone item from a list
|
||||
@@ -249,4 +255,10 @@ type ItemZone struct {
|
||||
|
||||
// CPU alignment profiles
|
||||
CpuAlignmentProfiles []CpuAlignmentProfile `json:"cpu_alignment_profiles"`
|
||||
|
||||
// Reserved CPU
|
||||
ReservedCPU uint64 `json:"reserved_cpu"`
|
||||
|
||||
// Reserved RAM
|
||||
ReservedRAM uint64 `json:"reserved_ram"`
|
||||
}
|
||||
|
||||
42
pkg/cloudbroker/zone/set_resources_limit.go
Normal file
42
pkg/cloudbroker/zone/set_resources_limit.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package zone
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
// SetResourcesLimitRequest struct to set resources limit
|
||||
type SetResourcesLimitRequest struct {
|
||||
// ID of the zone
|
||||
// Required: true
|
||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||
|
||||
// Number of CPU cores reserved
|
||||
// Required: true
|
||||
ReservedCPU uint64 `url:"reserved_cpu" json:"reserved_cpu"`
|
||||
|
||||
// Amount of RAM in MB reserved
|
||||
// Required: true
|
||||
ReservedRAM uint64 `url:"reserved_ram" json:"reserved_ram"`
|
||||
}
|
||||
|
||||
// SetResourcesLimit sets reserved CPU and RAM limits for the zone
|
||||
func (e Zone) SetResourcesLimit(ctx context.Context, req SetResourcesLimitRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/zone/set_resources_limit"
|
||||
|
||||
res, err := e.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return strconv.ParseBool(string(res))
|
||||
}
|
||||
46
pkg/cloudbroker/zone/update_cpu_alignment_profile.go
Normal file
46
pkg/cloudbroker/zone/update_cpu_alignment_profile.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package zone
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
// UpdateCPUAlignmentProfileRequest struct to update CPU alignment profile of zone
|
||||
type UpdateCPUAlignmentProfileRequest struct {
|
||||
// ID of zone
|
||||
// Required: true
|
||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||
|
||||
// Minimum percentage of hypervisors that must support the selected CPU model for the balanced profile
|
||||
// Default: 70
|
||||
// Required: false
|
||||
HypervisorSimilarityInPercentage uint64 `url:"hypervisor_similarity_in_percentage,omitempty" json:"hypervisor_similarity_in_percentage,omitempty" validate:"omitempty,max=100"`
|
||||
}
|
||||
|
||||
// UpdateCPUAlignmentProfile updates CPU alignment profile of zone
|
||||
func (e Zone) UpdateCPUAlignmentProfile(ctx context.Context, req UpdateCPUAlignmentProfileRequest) ([]CpuAlignmentProfile, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/zone/update_cpu_alignment_profile"
|
||||
|
||||
res, err := e.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var profiles []CpuAlignmentProfile
|
||||
|
||||
err = json.Unmarshal(res, &profiles)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return profiles, nil
|
||||
}
|
||||
Reference in New Issue
Block a user