v1.15.3
This commit is contained in:
@@ -148,6 +148,9 @@ type RecordNetAttach struct {
|
||||
// Enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// Enable default gateway
|
||||
EnableDefaultGateway bool `json:"enable_default_gateway"`
|
||||
|
||||
// Enable security groups
|
||||
EnableSecGroups bool `json:"enable_secgroups"`
|
||||
|
||||
@@ -597,6 +600,9 @@ type ItemInterface struct {
|
||||
// Enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// Enable default gateway
|
||||
EnableDefaultGateway bool `json:"enable_default_gateway"`
|
||||
|
||||
// Enable security groups
|
||||
EnableSecGroups bool `json:"enable_secgroups"`
|
||||
|
||||
|
||||
@@ -81,6 +81,11 @@ type NetAttachRequest struct {
|
||||
// Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK)
|
||||
// Required: false
|
||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Flag indicating whether default gateway is enabled for this interface
|
||||
// Required: false
|
||||
// Default: true
|
||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type wrapperNetAttachRequest struct {
|
||||
|
||||
@@ -343,4 +343,7 @@ type MigrateStatus struct {
|
||||
|
||||
// Progress percent
|
||||
ProgressPercent int `json:"progress_percent"`
|
||||
|
||||
// Operation status
|
||||
Ready bool `json:"ready"`
|
||||
}
|
||||
|
||||
44
pkg/cloudbroker/grid/set_resources_limit.go
Normal file
44
pkg/cloudbroker/grid/set_resources_limit.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package grid
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// SetResourcesLimitRequest struct to set resources limit
|
||||
type SetResourcesLimitRequest struct {
|
||||
// ID of the grid
|
||||
// Required: true
|
||||
GID uint64 `url:"grid_id" json:"grid_id" validate:"required"`
|
||||
|
||||
// Number of CPU cores reserved
|
||||
// Default: 0
|
||||
// Required: true
|
||||
ReservedCPU uint64 `url:"reserved_cpu" json:"reserved_cpu"`
|
||||
|
||||
// Amount of RAM in MB reserved
|
||||
// Default: 0
|
||||
// Required: true
|
||||
ReservedRAM uint64 `url:"reserved_ram" json:"reserved_ram"`
|
||||
}
|
||||
|
||||
// SetResourcesLimit sets reserved CPU and RAM limits for the grid
|
||||
func (g Grid) SetResourcesLimit(ctx context.Context, req SetResourcesLimitRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/grid/set_resources_limit"
|
||||
|
||||
res, err := g.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return strconv.ParseBool(string(res))
|
||||
}
|
||||
@@ -59,6 +59,11 @@ type Interface struct {
|
||||
// Required: false
|
||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Flag indicating whether default gateway are enabled for this interface, not applicable to netType EXTNET, VFNIC, TRUNK, or SDN
|
||||
// Default: true
|
||||
// Required: false
|
||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// SDN Segment ID
|
||||
// Required: false
|
||||
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
||||
|
||||
@@ -56,6 +56,11 @@ type InterfaceMassCreate struct {
|
||||
// Required: false
|
||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Flag indicating whether default gateway are enabled for this interface, not applicable to netType EXTNET, VFNIC, TRUNK, or SDN
|
||||
// Default: true
|
||||
// Required: false
|
||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// SDN Segment ID
|
||||
// Required: false
|
||||
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
||||
|
||||
@@ -50,6 +50,12 @@ type RecordNode struct {
|
||||
// ReservedCPUs
|
||||
ReservedCPUs []interface{} `json:"reservedCpus"`
|
||||
|
||||
// Reserved CPU
|
||||
ReservedCPU uint64 `json:"reserved_cpu"`
|
||||
|
||||
// Reserved RAM
|
||||
ReservedRAM uint64 `json:"reserved_ram"`
|
||||
|
||||
// Roles
|
||||
Roles []string `json:"roles"`
|
||||
|
||||
@@ -260,6 +266,12 @@ type ItemNode struct {
|
||||
// ReservedCPUs
|
||||
ReservedCPUs []interface{} `json:"reservedCpus"`
|
||||
|
||||
// Reserved CPU
|
||||
ReservedCPU uint64 `json:"reserved_cpu"`
|
||||
|
||||
// Reserved RAM
|
||||
ReservedRAM uint64 `json:"reserved_ram"`
|
||||
|
||||
// Roles
|
||||
Roles []string `json:"roles"`
|
||||
|
||||
|
||||
42
pkg/cloudbroker/node/set_resources_limit.go
Normal file
42
pkg/cloudbroker/node/set_resources_limit.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// SetResourcesLimitRequest struct to set resources limit for node
|
||||
type SetResourcesLimitRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NodeID uint64 `url:"node_id" json:"node_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 node
|
||||
func (n Node) SetResourcesLimit(ctx context.Context, req SetResourcesLimitRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/set_resources_limit"
|
||||
|
||||
res, err := n.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return strconv.ParseBool(string(res))
|
||||
}
|
||||
@@ -2,10 +2,10 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
@@ -62,11 +62,11 @@ type CreateInAccountRequest struct {
|
||||
// Required: false
|
||||
// Default: false
|
||||
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type wrapperCreateRequestInAcc struct {
|
||||
CreateInAccountRequest
|
||||
Routes []string `url:"routes,omitempty"`
|
||||
// Flag indicating whether default gateway is enabled for this VINS
|
||||
// Required: false
|
||||
// Default: true
|
||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// CreateInAccount creates VINS in account level
|
||||
@@ -76,31 +76,9 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
var routes []string
|
||||
|
||||
if len(req.Routes) != 0 {
|
||||
routes = make([]string, 0, len(req.Routes))
|
||||
|
||||
for r := range req.Routes {
|
||||
b, err := json.Marshal(req.Routes[r])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
routes = append(routes, string(b))
|
||||
}
|
||||
} else {
|
||||
routes = []string{"[]"}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateRequestInAcc{
|
||||
CreateInAccountRequest: req,
|
||||
Routes: routes,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vins/createInAccount"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
@@ -56,11 +56,11 @@ type CreateInRGRequest struct {
|
||||
// Required: false
|
||||
// Default: false
|
||||
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type wrapperCreateRequestInRG struct {
|
||||
CreateInRGRequest
|
||||
Routes []string `url:"routes,omitempty"`
|
||||
// Flag indicating whether default gateway is enabled for this VINS
|
||||
// Required: false
|
||||
// Default: true
|
||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// CreateInRG creates VINS in resource group level
|
||||
@@ -69,31 +69,10 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
var routes []string
|
||||
|
||||
if len(req.Routes) != 0 {
|
||||
routes = make([]string, 0, len(req.Routes))
|
||||
|
||||
for r := range req.Routes {
|
||||
b, err := json.Marshal(req.Routes[r])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
routes = append(routes, string(b))
|
||||
}
|
||||
} else {
|
||||
routes = []string{"[]"}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateRequestInRG{
|
||||
CreateInRGRequest: req,
|
||||
Routes: routes,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vins/createInRG"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -523,6 +523,9 @@ type RecordVINS struct {
|
||||
// Description
|
||||
Description string `json:"desc"`
|
||||
|
||||
// Enable Default Gateway
|
||||
EnableDefaultGateway bool `json:"enable_default_gateway"`
|
||||
|
||||
// Enable Security Groups
|
||||
EnableSecGroups bool `json:"enable_secgroups"`
|
||||
|
||||
@@ -736,6 +739,9 @@ type ItemVINS struct {
|
||||
// Description
|
||||
Description string `json:"desc"`
|
||||
|
||||
// Enable Default Gateway
|
||||
EnableDefaultGateway bool `json:"enable_default_gateway"`
|
||||
|
||||
// Enable Security Groups
|
||||
EnableSecGroups bool `json:"enable_secgroups"`
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ type UpdateRequest struct {
|
||||
// Flag indicating whether security groups are enabled for this network
|
||||
// Required: false
|
||||
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Flag indicating whether default gateway is enabled for this VINS
|
||||
// Required: false
|
||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// Update updates a vins parameters
|
||||
|
||||
@@ -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/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/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/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/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