Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b7137683ab | |||
| 10e3e19892 | |||
| aaf0857ff0 |
39
CHANGELOG.md
39
CHANGELOG.md
@@ -1,33 +1,6 @@
|
||||
## Version 1.3.1
|
||||
|
||||
### Features
|
||||
|
||||
- Added FilterByGID for cloudapi/locations/list handler response, used to filter locations by specified GID.
|
||||
- Added /cloudbroker/pcidevices endpoints support
|
||||
- /cloudbroker/pcidevices/create
|
||||
- /cloudbroker/pcidevices/delete
|
||||
- /cloudbroker/pcidevices/disable
|
||||
- /cloudbroker/pcidevices/enable
|
||||
- /cloudbroker/pcidevices/list
|
||||
- Added /cloudbroker/vgpu endpoints support
|
||||
- /cloudbroker/vgpu/allocate
|
||||
- /cloudbroker/vgpu/create
|
||||
- /cloudbroker/vgpu/deallocate
|
||||
- /cloudbroker/vgpu/destroy
|
||||
- /cloudbroker/vgpu/list
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Fixed cloudbroker/cloudapi/account/update request model types.
|
||||
- Fixed cloudbroker/cloudapi/rg/update request model types.
|
||||
- Fixed cloudapi/account DeactivationTime field type.
|
||||
- Fixed cloudapi/k8s/workersGroupAdd return value type.
|
||||
- Fixed cloudapi/disks/listUnattached return value type.
|
||||
- Added ListDisksUnattached model as a cloudapi/disks/listUnattached handler response with filters.
|
||||
- Fixed cloudapi/extnet Excluded field type.
|
||||
- Fixed cloudapi/rg RecordResourceUsage model.
|
||||
- Fixed cloudapi/compute ItemACL model.
|
||||
|
||||
### Tests
|
||||
|
||||
- Covered cloudapi/disks ListDisksUnattached filters with unit tests.
|
||||
## Version 1.4.2
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Fixed cloudapi/cloudbroker/compute/pfwAdd publicPortEnd request field type
|
||||
- Fixed typo in cloudapi/k8s/disable/enable request name
|
||||
|
||||
@@ -8,6 +8,7 @@ Decort SDK - это библиотека, написанная на языке G
|
||||
- Версия 1.1.x Decort-SDK соответствует 3.8.5 версии платформы
|
||||
- Версия 1.2.x Decort-SDK соответствует 3.8.5 версии платформы
|
||||
- Версия 1.3.x Decort-SDK соответствует 3.8.5 версии платформы
|
||||
- Версия 1.4.x Decort-SDK соответствует 3.8.6 версии платформы
|
||||
|
||||
## Оглавление
|
||||
|
||||
|
||||
3
go.mod
3
go.mod
@@ -5,14 +5,15 @@ go 1.20
|
||||
require (
|
||||
github.com/go-playground/validator/v10 v10.11.2
|
||||
github.com/google/go-querystring v1.1.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
golang.org/x/crypto v0.5.0 // indirect
|
||||
golang.org/x/sys v0.4.0 // indirect
|
||||
golang.org/x/text v0.6.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
6
go.sum
6
go.sum
@@ -1,3 +1,4 @@
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
@@ -11,10 +12,14 @@ github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
|
||||
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
@@ -26,6 +31,7 @@ golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
|
||||
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
@@ -3,6 +3,7 @@ package validators
|
||||
import (
|
||||
"github.com/go-playground/validator/v10"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// protoValidator is used to validate Proto fields.
|
||||
@@ -215,3 +216,43 @@ func hwPathValidator(fe validator.FieldLevel) bool {
|
||||
|
||||
return ok
|
||||
}
|
||||
|
||||
// networkPluginValidator is used to validate NetworkPlugin field
|
||||
func networkPluginValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
fieldValue = strings.ToLower(fieldValue)
|
||||
|
||||
return StringInSlice(fieldValue, networkPluginValues)
|
||||
}
|
||||
|
||||
// networkPluginsValidator is used to validate NetworkPlugins field
|
||||
func networkPluginsValidator(fe validator.FieldLevel) bool {
|
||||
fieldSlice, ok := fe.Field().Interface().([]string)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, item := range fieldSlice {
|
||||
item = strings.ToLower(item)
|
||||
|
||||
if !StringInSlice(item, networkPluginValues) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func interfaceStateValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
fieldValue = strings.ToLower(fieldValue)
|
||||
|
||||
return StringInSlice(fieldValue, interfaceStateValues)
|
||||
}
|
||||
|
||||
func strictLooseValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
fieldValue = strings.ToLower(fieldValue)
|
||||
|
||||
return StringInSlice(fieldValue, strictLooseValues)
|
||||
}
|
||||
|
||||
@@ -187,10 +187,36 @@ func errorMessage(fe validator.FieldError) string {
|
||||
fe.Field(),
|
||||
joinValues(sepFieldTypeValues))
|
||||
|
||||
// HWPath Validators
|
||||
case "hwPath":
|
||||
return fmt.Sprintf("%s %s must be in format 0000:1f:2b.0",
|
||||
prefix,
|
||||
fe.Field())
|
||||
|
||||
// Network plugin Validators
|
||||
case "networkPlugin":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(networkPluginValues))
|
||||
|
||||
case "networkPlugins":
|
||||
return fmt.Sprintf("%s %s must contain only the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(networkPluginValues))
|
||||
|
||||
case "strict_loose":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(strictLooseValues))
|
||||
|
||||
case "interfaceState":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(interfaceStateValues))
|
||||
}
|
||||
|
||||
return fe.Error()
|
||||
|
||||
@@ -164,5 +164,25 @@ func registerAllValidators(validate *validator.Validate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("networkPlugin", networkPluginValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("networkPlugins", networkPluginsValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("strict_loose", strictLooseValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("interfaceState", interfaceStateValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -37,4 +37,10 @@ var (
|
||||
imageArchitectureValues = []string{"X86_64", "PPC64_LE"}
|
||||
|
||||
sepFieldTypeValues = []string{"int", "str", "bool", "list", "dict"}
|
||||
|
||||
networkPluginValues = []string{"flannel", "weawenet", "calico"}
|
||||
|
||||
strictLooseValues = []string{"strict", "loose"}
|
||||
|
||||
interfaceStateValues = []string{"on", "off"}
|
||||
)
|
||||
|
||||
@@ -44,7 +44,7 @@ type CreateRequest struct {
|
||||
|
||||
// If true send emails when a user is granted access to resources
|
||||
// Required: false
|
||||
SendAccessEmails bool `url:"sendAccessEmails,omitempty" json:"sendAccessEmails,omitempty"`
|
||||
SendAccessEmails bool `url:"sendAccessEmails" json:"sendAccessEmails"`
|
||||
|
||||
// Limit (positive) or disable (0) GPU resources
|
||||
// Required: false
|
||||
|
||||
@@ -158,6 +158,12 @@ type RecordAccount struct {
|
||||
// Computes
|
||||
Computes Computes `json:"computes"`
|
||||
|
||||
// CPU allocation parameter
|
||||
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
||||
|
||||
// CPU allocation ratio
|
||||
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
@@ -192,7 +198,7 @@ type RecordAccount struct {
|
||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||
|
||||
// Resource types
|
||||
ResourceTypes []string `json:"resourceTypes"`
|
||||
ResTypes []string `json:"resourceTypes"`
|
||||
|
||||
// Send access emails
|
||||
SendAccessEmails bool `json:"sendAccessEmails"`
|
||||
|
||||
@@ -3,8 +3,6 @@ package account
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
@@ -26,15 +24,10 @@ func (a Account) Restore(ctx context.Context, req RestoreRequest) (bool, error)
|
||||
|
||||
url := "/cloudapi/account/restore"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
_, err = a.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
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ type UpdateRequest struct {
|
||||
|
||||
// If true send emails when a user is granted access to resources
|
||||
// Required: false
|
||||
SendAccessEmails bool `url:"sendAccessEmails,omitempty" json:"sendAccessEmails,omitempty"`
|
||||
SendAccessEmails bool `url:"sendAccessEmails" json:"sendAccessEmails"`
|
||||
|
||||
// Limit (positive) or disable (0) GPU resources
|
||||
// Required: false
|
||||
|
||||
@@ -35,11 +35,8 @@ type RecordBasicService struct {
|
||||
// Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// List of Service Compute Group IDs
|
||||
Groups []uint64 `json:"groups"`
|
||||
|
||||
// List of compute groups by name
|
||||
GroupsName []string `json:"groupsName"`
|
||||
// List of Service Compute Groups
|
||||
Groups ListGroups `json:"groups"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
@@ -95,6 +92,12 @@ type RecordBasicService struct {
|
||||
|
||||
// Main information about Compute
|
||||
type ItemCompute struct {
|
||||
// Account ID
|
||||
AccountID uint64
|
||||
|
||||
// Architecture
|
||||
Architecture string `json:"arch"`
|
||||
|
||||
// Compute group ID
|
||||
CompGroupID uint64 `json:"compgroupId"`
|
||||
|
||||
@@ -109,11 +112,47 @@ type ItemCompute struct {
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// StackID
|
||||
StackID uint64 `json:"stackId"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Tech status
|
||||
TechStatus string `json:"techStatus"`
|
||||
}
|
||||
|
||||
// List of Computes
|
||||
type ListComputes []ItemCompute
|
||||
|
||||
// Main information about Group
|
||||
type ItemGroup struct {
|
||||
// Amount of computes
|
||||
Computes uint64 `json:"computes"`
|
||||
|
||||
// Consistency
|
||||
Consistency bool `json:"consistency"`
|
||||
|
||||
// Group ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Group name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// TechStatus
|
||||
TechStatus string `json:"techStatus"`
|
||||
}
|
||||
|
||||
// List of Groups
|
||||
type ListGroups []ItemGroup
|
||||
|
||||
// Main information about Snapshot
|
||||
type ItemSnapshot struct {
|
||||
// GUID
|
||||
|
||||
41
pkg/cloudapi/compute/boot_order_get.go
Normal file
41
pkg/cloudapi/compute/boot_order_get.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for getting boot order
|
||||
type BootOrderGetRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
}
|
||||
|
||||
// BootOrderGet gets actual compute boot order information
|
||||
func (c Compute) BootOrderGet(ctx context.Context, req BootOrderGetRequest) ([]string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return nil, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/bootOrderGet"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
orders := make([]string, 0)
|
||||
|
||||
err = json.Unmarshal(res, &orders)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return orders, nil
|
||||
}
|
||||
49
pkg/cloudapi/compute/boot_order_set.go
Normal file
49
pkg/cloudapi/compute/boot_order_set.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for setting boot order
|
||||
type BootOrderSetRequest struct {
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// List of boot devices
|
||||
// Should be one of:
|
||||
// - cdrom
|
||||
// - network
|
||||
// - hd
|
||||
// Required: true
|
||||
Order []string `url:"order" json:"order" validate:"min=1,computeOrder"`
|
||||
}
|
||||
|
||||
// BootOrderSet sets compute boot order
|
||||
func (c Compute) BootOrderSet(ctx context.Context, req BootOrderSetRequest) ([]string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return nil, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/bootOrderSet"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
orders := make([]string, 0)
|
||||
|
||||
err = json.Unmarshal(res, &orders)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return orders, nil
|
||||
}
|
||||
47
pkg/cloudapi/compute/change_link_state.go
Normal file
47
pkg/cloudapi/compute/change_link_state.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for changing link state
|
||||
type ChangeLinkStateRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Interface name or MAC address
|
||||
// Required: true
|
||||
Interface string `url:"interface" json:"interface" validate:"required"`
|
||||
|
||||
// Interface state
|
||||
// Must be either "on" or "off"
|
||||
// Required: true
|
||||
State string `url:"state" json:"state" validate:"required,interfaceState"`
|
||||
}
|
||||
|
||||
// ChangeLinkState changes the status link virtual of compute
|
||||
func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/changeLinkState"
|
||||
|
||||
res, err := c.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
|
||||
}
|
||||
@@ -22,6 +22,11 @@ type DiskAddRequest struct {
|
||||
// Required: true
|
||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
||||
|
||||
// Storage endpoint provider ID
|
||||
// By default the same with boot disk
|
||||
// Required: false
|
||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Type of the disk
|
||||
// Should be one of:
|
||||
// - D
|
||||
@@ -29,11 +34,6 @@ type DiskAddRequest struct {
|
||||
// Required: false
|
||||
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty" validate:"omitempty,computeDiskType"`
|
||||
|
||||
// Storage endpoint provider ID
|
||||
// By default the same with boot disk
|
||||
// Required: false
|
||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool name
|
||||
// By default will be chosen automatically
|
||||
// Required: false
|
||||
|
||||
@@ -17,6 +17,10 @@ type DiskAttachRequest struct {
|
||||
// ID of the disk to attach
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
|
||||
// Type of the disk B;D
|
||||
// Required: false
|
||||
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty" validate:"omitempty,computeDiskType"`
|
||||
}
|
||||
|
||||
// DiskAttach attach disk to compute
|
||||
|
||||
@@ -150,6 +150,9 @@ type RecordNetAttach struct {
|
||||
// Default GW
|
||||
DefGW string `json:"defGw"`
|
||||
|
||||
// Enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// FLIPGroup ID
|
||||
FLIPGroupID uint64 `json:"flipgroupId"`
|
||||
|
||||
@@ -178,7 +181,7 @@ type RecordNetAttach struct {
|
||||
NetType string `json:"netType"`
|
||||
|
||||
// PCI slot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
PCISlot int64 `json:"pciSlot"`
|
||||
|
||||
// QOS
|
||||
QOS QOS `json:"qos"`
|
||||
@@ -483,6 +486,9 @@ type ItemVNFInterface struct {
|
||||
// Default GW
|
||||
DefGW string `json:"defGw"`
|
||||
|
||||
// Enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// FLIPGroup ID
|
||||
FLIPGroupID uint64 `json:"flipgroupId"`
|
||||
|
||||
@@ -511,7 +517,7 @@ type ItemVNFInterface struct {
|
||||
NetType string `json:"netType"`
|
||||
|
||||
// PCI slot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
PCISlot int64 `json:"pciSlot"`
|
||||
|
||||
// QOS
|
||||
QOS QOS `json:"qos"`
|
||||
@@ -611,7 +617,7 @@ type ItemComputeDisk struct {
|
||||
Passwd string `json:"passwd"`
|
||||
|
||||
// PCI slot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
PCISlot int64 `json:"pciSlot"`
|
||||
|
||||
// Pool
|
||||
Pool string `json:"pool"`
|
||||
@@ -895,7 +901,7 @@ type InfoDisk struct {
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// PCISlot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
PCISlot int64 `json:"pciSlot"`
|
||||
}
|
||||
|
||||
// List information about computes
|
||||
|
||||
@@ -19,8 +19,9 @@ type PFWAddRequest struct {
|
||||
PublicPortStart uint64 `url:"publicPortStart" json:"publicPortStart" validate:"required"`
|
||||
|
||||
// End port number (inclusive) for the ranged rule
|
||||
// Default value: -1
|
||||
// Required: false
|
||||
PublicPortEnd uint64 `url:"publicPortEnd,omitempty" json:"publicPortEnd,omitempty"`
|
||||
PublicPortEnd int64 `url:"publicPortEnd,omitempty" json:"publicPortEnd,omitempty"`
|
||||
|
||||
// Internal base port number
|
||||
// Required: true
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
// Request struct for get list types of disks
|
||||
type ListTypesRequest struct {
|
||||
// Show detailed disk types by seps
|
||||
// Required: false
|
||||
Detailed bool `url:"detailed,omitempty" json:"detailed,omitempty"`
|
||||
// Required: true
|
||||
Detailed bool `url:"detailed" json:"detailed" validate:"required"`
|
||||
}
|
||||
|
||||
// ListTypes gets list defined disk types
|
||||
|
||||
@@ -377,7 +377,7 @@ type RecordDisk struct {
|
||||
ParentID uint64 `json:"parentId"`
|
||||
|
||||
// PCI slot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
PCISlot int64 `json:"pciSlot"`
|
||||
|
||||
// Pool
|
||||
Pool string `json:"pool"`
|
||||
|
||||
@@ -59,6 +59,9 @@ type ListExtNetComputes []ItemExtNetCompute
|
||||
|
||||
// QOS
|
||||
type QOS struct {
|
||||
// EBurst
|
||||
EBurst uint64 `json:"eBurst"`
|
||||
|
||||
// ERate
|
||||
ERate uint64 `json:"eRate"`
|
||||
|
||||
|
||||
@@ -23,6 +23,9 @@ type RecordK8CI struct {
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Network plugins
|
||||
NetworkPlugins []string `json:"networkPlugins"`
|
||||
|
||||
// Version
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
@@ -26,6 +26,11 @@ type CreateRequest struct {
|
||||
// Required: true
|
||||
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required"`
|
||||
|
||||
// Network plugin
|
||||
// Must be one of these values: flannel, weawenet, calico
|
||||
// Required: true
|
||||
NetworkPlugin string `url:"networkPlugin" json:"networkPlugin" validate:"required,networkPlugin"`
|
||||
|
||||
// ID of SEP to create boot disks for master nodes. Uses images SEP ID if not set
|
||||
// Required: false
|
||||
MasterSEPID uint64 `url:"masterSepId,omitempty" json:"masterSepId,omitempty"`
|
||||
|
||||
@@ -9,14 +9,14 @@ import (
|
||||
)
|
||||
|
||||
// Request struct for disable/enable kubernetes cluster
|
||||
type DisabelEnableRequest struct {
|
||||
type DisableEnableRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
}
|
||||
|
||||
// Disable disables kubernetes cluster by ID
|
||||
func (k8s K8S) Disable(ctx context.Context, req DisabelEnableRequest) (bool, error) {
|
||||
func (k8s K8S) Disable(ctx context.Context, req DisableEnableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
@@ -40,7 +40,7 @@ func (k8s K8S) Disable(ctx context.Context, req DisabelEnableRequest) (bool, err
|
||||
}
|
||||
|
||||
// Enable enables kubernetes cluster by ID
|
||||
func (k8s K8S) Enable(ctx context.Context, req DisabelEnableRequest) (bool, error) {
|
||||
func (k8s K8S) Enable(ctx context.Context, req DisableEnableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
|
||||
@@ -101,6 +101,9 @@ type RecordK8S struct {
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Network plugin
|
||||
NetworkPlugin string `json:"networkPlugin"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
@@ -246,6 +249,9 @@ type ItemK8SCluster struct {
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Network plugin
|
||||
NetworkPlugin string `json:"networkPlugin"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
|
||||
@@ -2,9 +2,8 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
@@ -24,11 +23,11 @@ type WorkerAddRequest struct {
|
||||
}
|
||||
|
||||
// WorkerAdd add worker nodes to a Kubernetes cluster
|
||||
func (k8s K8S) WorkerAdd(ctx context.Context, req WorkerAddRequest) (bool, error) {
|
||||
func (k8s K8S) WorkerAdd(ctx context.Context, req WorkerAddRequest) ([]uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
return nil, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,12 +35,14 @@ func (k8s K8S) WorkerAdd(ctx context.Context, req WorkerAddRequest) (bool, error
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
result := make([]uint64, 0)
|
||||
|
||||
err = json.Unmarshal(res, &result)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
@@ -59,6 +59,12 @@ type RecordResourceGroup struct {
|
||||
// Access Control List
|
||||
ACL ListACL `json:"acl"`
|
||||
|
||||
// CPU allocation parameter
|
||||
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
||||
|
||||
// CPU allocation ratio
|
||||
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
@@ -107,12 +113,18 @@ type RecordResourceGroup struct {
|
||||
// Resource limits
|
||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||
|
||||
// List of resource types
|
||||
ResTypes []string `json:"resourceTypes"`
|
||||
|
||||
// Secret
|
||||
Secret string `json:"secret"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// UniqPools
|
||||
UniqPools []string `json:"uniqPools"`
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
@@ -124,12 +136,6 @@ type RecordResourceGroup struct {
|
||||
|
||||
// List of compute IDs
|
||||
Computes []uint64 `json:"vms"`
|
||||
|
||||
// List of resource types
|
||||
ResTypes []string `json:"resourceTypes"`
|
||||
|
||||
// UniqPools
|
||||
UniqPools []string `json:"uniqPools"`
|
||||
}
|
||||
|
||||
// Main information about resource group
|
||||
@@ -146,6 +152,12 @@ type ItemResourceGroup struct {
|
||||
// Access Control List
|
||||
ACL ListACL `json:"acl"`
|
||||
|
||||
// CPU allocation parameter
|
||||
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
||||
|
||||
// CPU allocation ratio
|
||||
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
@@ -194,12 +206,18 @@ type ItemResourceGroup struct {
|
||||
// Resource limits
|
||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||
|
||||
// List of resource types
|
||||
ResTypes []string `json:"resourceTypes"`
|
||||
|
||||
// Secret
|
||||
Secret string `json:"secret"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// UniqPools
|
||||
UniqPools []string `json:"uniqPools"`
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
@@ -211,12 +229,6 @@ type ItemResourceGroup struct {
|
||||
|
||||
// List of compute IDs
|
||||
Computes []uint64 `json:"vms"`
|
||||
|
||||
// List of resource types
|
||||
ResTypes []string `json:"resourceTypes"`
|
||||
|
||||
// UniqPools
|
||||
UniqPools []string `json:"uniqPools"`
|
||||
}
|
||||
|
||||
// List of resource groups
|
||||
|
||||
@@ -261,7 +261,7 @@ type ItemVNFInterface struct {
|
||||
NetType string `json:"netType"`
|
||||
|
||||
// PCI slot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
PCISlot int64 `json:"pciSlot"`
|
||||
|
||||
// QOS
|
||||
QOS QOS `json:"qos"`
|
||||
|
||||
@@ -44,7 +44,7 @@ type CreateRequest struct {
|
||||
|
||||
// If true send emails when a user is granted access to resources
|
||||
// Required: false
|
||||
SendAccessEmails bool `url:"sendAccessEmails,omitempty" json:"sendAccessEmails,omitempty"`
|
||||
SendAccessEmails bool `url:"sendAccessEmails" json:"sendAccessEmails"`
|
||||
|
||||
// Limit (positive) or disable (0) GPU resources
|
||||
// Required: false
|
||||
|
||||
@@ -123,6 +123,12 @@ type InfoAccount struct {
|
||||
// Company URL
|
||||
CompanyURL string `json:"companyurl"`
|
||||
|
||||
// CPU allocation parameter
|
||||
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
||||
|
||||
// CPU allocation ratio
|
||||
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
@@ -154,7 +160,7 @@ type InfoAccount struct {
|
||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||
|
||||
// Resource types
|
||||
ResourceTypes []string `json:"resourceTypes"`
|
||||
ResTypes []string `json:"resourceTypes"`
|
||||
|
||||
// Send access emails
|
||||
SendAccessEmails bool `json:"sendAccessEmails"`
|
||||
|
||||
45
pkg/cloudbroker/account/set_cpu_allocation_parameter.go
Normal file
45
pkg/cloudbroker/account/set_cpu_allocation_parameter.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request for setting CPU allocation parameter
|
||||
type SetCPUAllocationParameterRequest struct {
|
||||
// Account ID
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accoutnId" 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 (a Account) SetCPUAllocationParameter(ctx context.Context, req SetCPUAllocationParameterRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/setCpuAllocationParameter"
|
||||
|
||||
res, err := a.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
|
||||
}
|
||||
43
pkg/cloudbroker/account/set_cpu_allocation_ratio.go
Normal file
43
pkg/cloudbroker/account/set_cpu_allocation_ratio.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request for setting CPU allocation ratio
|
||||
type SetCPUAllocationRatioRequest struct {
|
||||
// Account ID
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accoutnId" validate:"required"`
|
||||
|
||||
// CPU allocation ratio, i.e. one pCPU = ratio*vCPU
|
||||
// Required: true
|
||||
Ratio float64 `url:"ratio" json:"ratio" validate:"required"`
|
||||
}
|
||||
|
||||
// SetCPUAllocationRatio sets CPU allocation ratio
|
||||
func (a Account) SetCPUAllocationRatio(ctx context.Context, req SetCPUAllocationRatioRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/setCpuAllocationRatio"
|
||||
|
||||
res, err := a.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
|
||||
}
|
||||
@@ -48,7 +48,7 @@ type UpdateRequest struct {
|
||||
|
||||
// If true send emails when a user is granted access to resources
|
||||
// Required: false
|
||||
SendAccessEmails bool `url:"sendAccessEmails,omitempty" json:"sendAccessEmails,omitempty"`
|
||||
SendAccessEmails bool `url:"sendAccessEmails" json:"sendAccessEmails"`
|
||||
|
||||
// Limit (positive) or disable (0) GPU resources
|
||||
// Required: false
|
||||
|
||||
47
pkg/cloudbroker/compute/change_link_state.go
Normal file
47
pkg/cloudbroker/compute/change_link_state.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for changing link state
|
||||
type ChangeLinkStateRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Interface name or MAC address
|
||||
// Required: true
|
||||
Interface string `url:"interface" json:"interface" validate:"required"`
|
||||
|
||||
// Interface state
|
||||
// Must be either "on" or "off"
|
||||
// Required: true
|
||||
State string `url:"state" json:"state" validate:"required,interfaceState"`
|
||||
}
|
||||
|
||||
// ChangeLinkState changes the status link virtual of compute
|
||||
func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/changeLinkState"
|
||||
|
||||
res, err := c.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
|
||||
}
|
||||
@@ -12,27 +12,27 @@ import (
|
||||
type DiskAddRequest struct {
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Name for disk
|
||||
// Required: true
|
||||
DiskName string `url:"diskName" json:"diskName" validate:"required"`
|
||||
DiskName string `url:"diskName" json:"diskName" validate:"required"`
|
||||
|
||||
// Disk size in GB
|
||||
// Required: true
|
||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
||||
|
||||
// Storage endpoint provider ID
|
||||
// By default the same with boot disk
|
||||
// Required: false
|
||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Type of the disk
|
||||
// Should be one of:
|
||||
// - D
|
||||
// - B
|
||||
// Required: false
|
||||
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty" validate:"omitempty,computeDiskType"`
|
||||
|
||||
// Storage endpoint provider ID
|
||||
// By default the same with boot disk
|
||||
// Required: false
|
||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty" validate:"omitempty,computeDiskType"`
|
||||
|
||||
// Pool name
|
||||
// By default will be chosen automatically
|
||||
|
||||
@@ -147,7 +147,7 @@ type RecordNetAttach struct {
|
||||
NetType string `json:"netType"`
|
||||
|
||||
// PCI slot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
PCISlot int64 `json:"pciSlot"`
|
||||
|
||||
// QOS
|
||||
QOS QOS `json:"qos"`
|
||||
@@ -396,7 +396,7 @@ type ItemDisk struct {
|
||||
Password string `json:"passwd"`
|
||||
|
||||
// PCI slot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
PCISlot int64 `json:"pciSlot"`
|
||||
|
||||
// Pool
|
||||
Pool string `json:"pool"`
|
||||
@@ -498,7 +498,7 @@ type ItemInterface struct {
|
||||
NetType string `json:"netType"`
|
||||
|
||||
// PCI slot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
PCISlot int64 `json:"pciSlot"`
|
||||
|
||||
// QOS
|
||||
QOS QOS `json:"qos"`
|
||||
@@ -738,7 +738,7 @@ type InfoDisk struct {
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// PCISlot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
PCISlot int64 `json:"pciSlot"`
|
||||
}
|
||||
|
||||
// List computes
|
||||
|
||||
@@ -19,8 +19,9 @@ type PFWAddRequest struct {
|
||||
PublicPortStart uint64 `url:"publicPortStart" json:"publicPortStart" validate:"required"`
|
||||
|
||||
// End port number (inclusive) for the ranged rule
|
||||
// Default value: -1
|
||||
// Required: false
|
||||
PublicPortEnd uint64 `url:"publicPortEnd,omitempty" json:"publicPortEnd,omitempty"`
|
||||
PublicPortEnd int64 `url:"publicPortEnd,omitempty" json:"publicPortEnd,omitempty"`
|
||||
|
||||
// Internal base port number
|
||||
// Required: true
|
||||
|
||||
45
pkg/cloudbroker/grid/set_cpu_allocation_parameter.go
Normal file
45
pkg/cloudbroker/grid/set_cpu_allocation_parameter.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package grid
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request 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 {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
43
pkg/cloudbroker/grid/set_cpu_allocation_ratio_for_vm.go
Normal file
43
pkg/cloudbroker/grid/set_cpu_allocation_ratio_for_vm.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package grid
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request for setting CPU allocation ratio for computes
|
||||
type SetCPUAllocationRatioForVMRequest struct {
|
||||
// Grid ID
|
||||
// Required: true
|
||||
GridID uint64 `url:"gridId" json:"gridId" validate:"required"`
|
||||
|
||||
// Default CPU allocation ratio for computes
|
||||
// Required: true
|
||||
Ratio float64 `url:"ratio" json:"ratio" validate:"required"`
|
||||
}
|
||||
|
||||
// SetCPUAllocationRatio sets CPU allocation ratio for computes
|
||||
func (g Grid) SetCPUAllocationRatioForVM(ctx context.Context, req SetCPUAllocationRatioForVMRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/grid/setCpuAllocationRatioForVM"
|
||||
|
||||
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
|
||||
}
|
||||
@@ -34,6 +34,11 @@ type CreateRequest struct {
|
||||
// Required: true
|
||||
MasterDriver string `url:"masterDriver" json:"masterDriver" validate:"driver"`
|
||||
|
||||
// Network plugins
|
||||
// Values of slice must be flannel, weawenet or calico
|
||||
//Required: true
|
||||
NetworkPlugins []string `url:"networkPlugins" json:"networkPlugins" validate:"required,networkPlugins"`
|
||||
|
||||
// Image ID for worker K8S node
|
||||
// Required: true
|
||||
WorkerImageID uint64 `url:"workerImageId" json:"workerImageId" validate:"required"`
|
||||
|
||||
@@ -26,6 +26,11 @@ type CreateRequest struct {
|
||||
// Required: true
|
||||
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required"`
|
||||
|
||||
// Network plugin
|
||||
// Must be one of these values: flunnel, weawenet, calico
|
||||
// Required: true
|
||||
NetworkPlugin string `url:"networkPlugin" json:"networkPlugin" validate:"required,networkPlugin"`
|
||||
|
||||
// ID of SEP to create boot disks for master nodes.
|
||||
// Uses images SEP ID if not set
|
||||
// Required: false
|
||||
|
||||
@@ -101,6 +101,9 @@ type RecordK8S struct {
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Network plugin
|
||||
NetworkPlugin string `json:"networkPlugin"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
@@ -245,6 +248,9 @@ type ItemK8S struct {
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Network plugin
|
||||
NetworkPlugin string `json:"networkPlugin"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
|
||||
@@ -131,6 +131,12 @@ type ItemRG struct {
|
||||
// List ACL
|
||||
ACL ListACL `json:"acl"`
|
||||
|
||||
// CPU allocation parameter
|
||||
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
||||
|
||||
// CPU allocation ratio
|
||||
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
@@ -176,12 +182,18 @@ type ItemRG struct {
|
||||
// Resource limits
|
||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||
|
||||
// Resource types list
|
||||
ResTypes []string `json:"resourceTypes"`
|
||||
|
||||
// Secret
|
||||
Secret string `json:"secret"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Uniq pools
|
||||
UniqPools []string `json:"uniqPools"`
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
@@ -193,12 +205,6 @@ type ItemRG struct {
|
||||
|
||||
// List virtual machine IDs
|
||||
VMs []uint64 `json:"vms"`
|
||||
|
||||
// Resource types list
|
||||
ResTypes []string `json:"resourceTypes"`
|
||||
|
||||
// Uniq pools
|
||||
UniqPools []string `json:"uniqPools"`
|
||||
}
|
||||
|
||||
// List resource groups
|
||||
|
||||
45
pkg/cloudbroker/rg/set_cpu_allocation_parameter.go
Normal file
45
pkg/cloudbroker/rg/set_cpu_allocation_parameter.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package rg
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request for setting CPU allocation parameter
|
||||
type SetCPUAllocationParameterRequest struct {
|
||||
// Resource group ID
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" 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 (r RG) SetCPUAllocationParameter(ctx context.Context, req SetCPUAllocationParameterRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/rg/setCpuAllocationParameter"
|
||||
|
||||
res, err := r.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
|
||||
}
|
||||
43
pkg/cloudbroker/rg/set_cpu_allocation_ratio.go
Normal file
43
pkg/cloudbroker/rg/set_cpu_allocation_ratio.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package rg
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request for setting CPU allocation ratio
|
||||
type SetCPUAllocationRatioRequest struct {
|
||||
// Resource group ID
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// CPU allocation ratio, i.e. one pCPU = ratio*vCPU
|
||||
// Required: true
|
||||
Ratio float64 `url:"ratio" json:"ratio" validate:"required"`
|
||||
}
|
||||
|
||||
// SetCPUAllocationRatio sets CPU allocation ratio
|
||||
func (r RG) SetCPUAllocationRatio(ctx context.Context, req SetCPUAllocationRatioRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/rg/setCpuAllocationRatio"
|
||||
|
||||
res, err := r.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
|
||||
}
|
||||
@@ -138,7 +138,7 @@ type ItemInterface struct {
|
||||
NetType string `json:"netType"`
|
||||
|
||||
// PCI slot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
PCISlot int64 `json:"pciSlot"`
|
||||
|
||||
// QOS
|
||||
QOS QOS `json:"qos"`
|
||||
|
||||
Reference in New Issue
Block a user