Compare commits

..

2 Commits

Author SHA1 Message Date
118b48c3bc v1.15.3 2026-06-26 16:39:51 +04:00
dayterr
cd5d1c9d0b v1.15.2
v1.15.2
2026-06-19 16:40:41 +03:00
32 changed files with 669 additions and 182 deletions

View File

@@ -1,58 +1,64 @@
## Version 1.15.1
## Version 1.15.3
Методы `Audits` в cloudapi/compute, cloudbroker/compute, cloudapi/account, cloudbroker/account, cloudapi/vins, cloudbroker/vins, cloudapi/rg и cloudbroker/rg стали deprecated и в следующих версиях будут удалены, вместо них необходимо использовать метод `List` в cloudapi/audit и cloudbroker/audit с соответствующими фильтрами
Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и в следующих версиях будут удалены
Методы `ComputeCISet`, `ComputeCIUnset`, `GetAudits` в cloudbroker/compute и `GetAudits` в cloudapi/compute стали deprecated и будут удалены в следующих версиях
Методы `ComputeCISet`, `ComputeCIUnset` в cloudbroker/image стали deprecated и будут удалены в следующих версиях
Методы `Audits` в cloudapi/compute, cloudbroker/compute, cloudapi/account, cloudbroker/account, cloudapi/vins, cloudbroker/vins, cloudapi/rg и cloudbroker/rg стали deprecated и будут удалены в версии 1.16, вместо них необходимо использовать метод `List` в cloudapi/audit и cloudbroker/audit с соответствующими фильтрами
Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и будут удалены в версии 1.16
Методы `ComputeCISet`, `ComputeCIUnset`, `GetAudits` в cloudbroker/compute и `GetAudits` в cloudapi/compute стали deprecated и будут удалены в версии 1.16
Методы `ComputeCISet`, `ComputeCIUnset` в cloudbroker/image стали deprecated и будут удалены в версии 1.16
Методы `Delete`, `Disable`, `Enable`, `GetConsumedCloudUnitsByType`, `GetReservedAccountUnits` в cloudapi/account стали deprecated и будут удалены в версии 1.16
Методы `Disable`, `Enable` в cloudbroker/account стали deprecated и будут удалены в версии 1.16
Метод `IsValidInviteUserToken` в cloudapi/user стал deprecated и будет удален в версии 1.16
Метод `GetLog` в cloudbroker/compute стал deprecated и будет удален в версии 1.16
Методы `ExecuteMaintenanceScript`, `ListEmails`, `ServicesRestart` в cloudbroker/grid стали deprecated и будут удалены в версии 1.16
Метод `Get` в cloudbroker/group стал deprecated и будет удален в версии 1.16
Все методы группы `.SDN()` находятся в альфа-версии.
### Добавлено
#### Общее
#### compute
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-899 | Добавлена валидация полей `ssoUrl` и `decortUrl` в конфигах `Config`, `BVSConfig` и `LegacyConfig`, а также поля `domain` в конфиге `BVSConfig` при вызове конструкторов `New`, `NewBVS`, `NewLegacy` |
| BGOS-922 | Опциональное поле `EnableDefaultGateway` в структуру запроса `NetAttachRequest` в cloudapi/compute и cloudbroker/compute |
| BGOS-922 | Вычисляемое поле `EnableDefaultGateway` в структуру ответа `RecordNetAttach` в cloudapi/compute и cloudbroker/compute |
| BGOS-922 | Вычисляемое поле `EnableDefaultGateway` в структуру ответа `ItemInterface` в cloudbroker/compute |
| BGOS-922 | Вычисляемое поле `EnableDefaultGateway` в структуру ответа `ItemVNFInterface` в cloudapi/compute |
| BGOS-931 | Структура ответа `SnapRecordCompute` в cloudapi/compute |
| BGOS-936 | Вычисляемое поле `NodeID` в структуры ответа `RecordCompute` и `ItemCompute` в cloudapi/compute |
#### disks
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-924 | Вычисляемое поле `Ready` в структуру ответа `MigrateStatus` в cloudbroker/disks |
#### grid
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-926 | Метод `SetResourcesLimit` и структура запроса `SetResourcesLimitRequest` в cloudbroker/grid |
#### kvmx86
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-903 | Структура ответа `MassCreateError` в cloudbroker/kvmx86 |
| BGOS-937 | Опциональное поле `EnableDefaultGateway` в структуру `Interface` в cloudapi/kvmx86 и cloudbroker/kvmx86 |
| BGOS-937 | Опциональное поле `EnableDefaultGateway` в структуру `InterfaceMassCreate` в cloudbroker/kvmx86 |
#### node
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-906 | Метод `Install` и структура запроса `InstallRequest` в cloudbroker/node |
| BGOS-927 | Вычисляемые поля `ReservedCPU` и `ReservedRAM` в структуры ответа `ItemNode` и `RecordNode` в cloudbroker/node |
| BGOS-928 | Метод `SetResourcesLimit` и структура запроса `SetResourcesLimitRequest` в cloudbroker/node |
#### vins
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-923 | Опциональное поле `EnableDefaultGateway` в структуры запросов `CreateInAccountRequest` и `CreateInRGRequest` в cloudapi/vins и cloudbroker/vins |
| BGOS-923 | Опциональное поле `EnableDefaultGateway` в структуру запроса `UpdateRequest` в cloudbroker/vins |
| BGOS-923 | Вычисляемое поле `EnableDefaultGateway` в структуру ответа `RecordVINS` в cloudapi/vins и cloudbroker/vins |
| BGOS-923 | Вычисляемое поле `EnableDefaultGateway` в структуру ответа `ItemVINS` в cloudbroker/vins |
#### zone
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-902 | Вычисляемое поле `SupportedCpuModels` в структуру ответа `TestCPUAlignmentProfileResult` в cloudbroker/zone |
| BGOS-902 | Структура ответа `SupportedCpuModel` в cloudbroker/zone |
### Изменено
#### compute
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-905 | Тип полей `Login` и `Password` с опциональных на обязательные в структуре `OSUser` в cloudbroker/compute |
#### zone
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BGOS-902 | Тип поля `Percentage` с `uint64` на `float64` в структуре ответа `CpuAlignmentProfileCandidate` в cloudbroker/zone |
#### SDN logicalports
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-907 | Тип поля `MAC` с опционального на обязательное в структуре `AddAddress` в sdn/logicalports |
### Удалено
#### compute
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-904 | Опциональное поле `Force` из структуры запроса `MigrateRequest` в cloudbroker/compute |
| BGOS-929 | Вычисляемые поля `ReservedCPU` и `ReservedRAM` в структуры ответа `RecordZone` и `ItemZone` в cloudapi/zone и в cloudbroker/zone |
| BGOS-930 | Метод `SetResourcesLimit` и структура запроса `SetResourcesLimitRequest` в cloudbroker/zone |
| BGOS-930 | Метод `UpdateCPUAlignmentProfile` и структура запроса `UpdateCPUAlignmentProfileRequest` в cloudbroker/zone |

View File

@@ -86,7 +86,7 @@ type ItemSnapshot struct {
// Compute info
Compute RecordCompute `json:"compute"`
// List disk ID
// List of disk IDs
Disks []uint64 `json:"disks"`
// GUID
@@ -182,6 +182,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"`
@@ -479,6 +482,9 @@ type RecordCompute struct {
// Natable VINS network name
NatableVINSNetworkName string `json:"natableVinsNetworkName"`
// Node ID
NodeID uint64 `json:"node_id"`
// Name of OS
OSVersion string `json:"os_version"`
@@ -565,6 +571,261 @@ type RecordCompute struct {
ZoneID uint64 `json:"zoneId"`
}
type SnapRecordCompute struct {
// Access Control List
ACL ListACL `json:"acl"`
// Account ID
AccountID uint64 `json:"accountId"`
// Account name
AccountName string `json:"accountName"`
// Affinity label
AffinityLabel string `json:"affinityLabel"`
// List affinity rules
AffinityRules ListRules `json:"affinityRules"`
// Affinity weight
AffinityWeight uint64 `json:"affinityWeight"`
// List anti affinity rules
AntiAffinityRules ListRules `json:"antiAffinityRules"`
// Auto start when node restarted
AutoStart bool `json:"autoStart"`
// Architecture
Architecture string `json:"arch"`
// Boot image ID
BootImageID uint64 `json:"boot_image_id"`
// Boot order
BootOrder []string `json:"bootOrder"`
// Boot type
BootType string `json:"bootType"`
// Boot disk size
BootDiskSize uint64 `json:"bootdiskSize"`
// CD Image Id
CdImageId uint64 `json:"cdImageId"`
// Chipset
Chipset string `json:"chipset"`
// Clone reference
CloneReference uint64 `json:"cloneReference"`
// List clone IDs
Clones []uint64 `json:"clones"`
// Clock
Clock string `json:"clock"`
// Compute CI ID
ComputeCIID uint64 `json:"computeciId"`
// CPU Pin
CPUPin bool `json:"cpupin"`
// Number of cores
CPU uint64 `json:"cpus"`
// Created by
CreatedBy string `json:"createdBy"`
// Created time
CreatedTime uint64 `json:"createdTime"`
// Custom fields items
CustomFields map[string]interface{} `json:"customFields"`
// Deleted by
DeletedBy string `json:"deletedBy"`
// Deleted time
DeletedTime uint64 `json:"deletedTime"`
// Description
Description string `json:"desc"`
// Devices
Devices interface{} `json:"devices"`
// List disks in compute
Disks ListComputeDisks `json:"disks"`
// Driver
Driver string `json:"driver"`
// Grid ID
GID uint64 `json:"gid"`
// GUID
GUID uint64 `json:"guid"`
// HPBacked
HPBacked bool `json:"hpBacked"`
// Hot resize
HotResize bool `json:"hotResize"`
// ID
ID uint64 `json:"id"`
// Image ID
ImageID uint64 `json:"imageId"`
// Image name
ImageName string `json:"imageName"`
// List interfaces
Interfaces ListInterfaces `json:"interfaces"`
// Loader meta iso information
LoaderMetaIso LoaderMetaIso `json:"loaderMetaIso"`
// Live migration job ID
LiveMigrationJobID uint64 `json:"live_migration_job_id"`
// Loader type
LoaderType string `json:"loaderType"`
// Lock status
LockStatus string `json:"lockStatus"`
// Manager ID
ManagerID uint64 `json:"managerId"`
// Manager type
ManagerType string `json:"managerType"`
// Migration job
MigrationJob uint64 `json:"migrationjob"`
// Milestones
Milestones uint64 `json:"milestones"`
// Name
Name string `json:"name"`
// NeedReboot
NeedReboot bool `json:"needReboot"`
// Network interface naming
NetworkInterfaceNaming string `json:"networkInterfaceNaming"`
// Numa Affinity
NumaAffinity string `json:"numaAffinity"`
//NumaNodeId
NumaNodeId int64 `json:"numaNodeId"`
// Natable VINS ID
NatableVINSID uint64 `json:"natableVinsId"`
// Natable VINS IP
NatableVINSIP string `json:"natableVinsIp"`
// Natable VINS Name
NatableVINSName string `json:"natableVinsName"`
// Natable VINS network
NatableVINSNetwork string `json:"natableVinsNetwork"`
// Natable VINS network name
NatableVINSNetworkName string `json:"natableVinsNetworkName"`
// Name of OS
OSVersion string `json:"os_version"`
// List OS Users
OSUsers ListOSUser `json:"osUsers"`
// Pinned to node
PinnedToNode int64 `json:"pinnedToNode"`
// PreferredCPU
PreferredCPU []int64 `json:"preferredCpu"`
// CPU alignment profile
CPUAlignmentProfile CPUAlignmentProfile `json:"cpu_alignment_profile"`
// Qemu_quest
QemuQuest QemuQuest `json:"qemu_guest"`
// ReadOnly indicates read-only mode state
ReadOnly bool `json:"read_only"`
// Number of RAM
RAM uint64 `json:"ram"`
// Reference ID
ReferenceID string `json:"referenceId"`
// Registered or not
Registered bool `json:"registered"`
// Resource name
ResName string `json:"resName"`
// Reserved Node Cpus
ReservedNodeCpus []uint64 `json:"reservedNodeCpus"`
// Resource group ID
RGID uint64 `json:"rgId"`
// Resource group name
RGName string `json:"rgName"`
// List snapsets
SnapSets ListSnapSets `json:"snapSets"`
// Stateless SepID
StatelessSepID int64 `json:"statelessSepId"`
// Stateless SepType
StatelessSepType string `json:"statelessSepType"`
// Status
Status string `json:"status"`
// Tags
Tags map[string]string `json:"tags"`
// Tech status
TechStatus string `json:"techStatus"`
// Updated by
UpdatedBy string `json:"updatedBy"`
// Updated time
UpdatedTime uint64 `json:"updatedTime"`
// User Managed or not
UserManaged bool `json:"userManaged"`
// Userdata
Userdata interface{} `json:"userdata"`
// vGPUs list
VGPUs []VGPUItem `json:"vgpus"`
// VNC password
VNCPassword string `json:"vncPasswd"`
// Weight
Weight uint64 `json:"weight"`
// Zone ID
// Required: false
ZoneID uint64 `json:"zoneId"`
}
type LoaderMetaIso struct {
// Name
DeviceName string `json:"devicename"`
@@ -690,7 +951,10 @@ type ListOSUser []ItemOSUser
// Main information about snapsets
type ItemSnapSet struct {
// List disk IDs
// Compute info
Compute SnapRecordCompute `json:"compute"`
// List disk ID
Disks []uint64 `json:"disks"`
// GUID
@@ -699,6 +963,9 @@ type ItemSnapSet struct {
// Label
Label string `json:"label"`
// Memory dump image ID
MemoryDumpImage uint64 `json:"memory_dump_image"`
// Timestamp
Timestamp uint64 `json:"timestamp"`
}
@@ -723,6 +990,9 @@ type ItemVNFInterface struct {
// Enabled
Enabled bool `json:"enabled"`
// Enable default gateway
EnableDefaultGateway bool `json:"enable_default_gateway"`
// Enable security groups
EnableSecGroups bool `json:"enable_secgroups"`
@@ -1185,6 +1455,9 @@ type ItemCompute struct {
// Name
Name string `json:"name"`
// Node ID
NodeID uint64 `json:"node_id"`
// NeedReboot
NeedReboot bool `json:"needReboot"`

View File

@@ -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 {

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
@@ -102,6 +103,6 @@ func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
url := "/cloudapi/image/list"
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
return res, err
}

View File

@@ -76,6 +76,11 @@ type Interface 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 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"`
}
// DataDisk detailed struct for DataDisks field in CreateRequest and CreateBlankRequest

View File

@@ -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 := "/cloudapi/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
}

View File

@@ -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
@@ -70,31 +70,9 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er
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 := "/cloudapi/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
}

View File

@@ -694,6 +694,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"`

View File

@@ -111,6 +111,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
@@ -183,4 +189,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"`
}

View File

@@ -16,7 +16,7 @@ type SetCPUAllocationRatioRequest struct {
// CPU allocation ratio, i.e. one pCPU = ratio*vCPU
// Required: true
Ratio float64 `url:"ratio" json:"ratio" validate:"required"`
Ratio uint64 `url:"ratio" json:"ratio" validate:"required"`
}
// SetCPUAllocationRatio sets CPU allocation ratio

View File

@@ -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"`

View File

@@ -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 {

View File

@@ -343,4 +343,7 @@ type MigrateStatus struct {
// Progress percent
ProgressPercent int `json:"progress_percent"`
// Operation status
Ready bool `json:"ready"`
}

View 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))
}

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
@@ -102,6 +103,6 @@ func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
url := "/cloudbroker/image/list"
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
return res, err
}

View File

@@ -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"`

View File

@@ -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"`

View File

@@ -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"`
@@ -161,8 +167,11 @@ type CpuInfo struct {
// Flags
Flags []string `json:"flags"`
// Mddel name
// Model name
ModelName string `json:"model_name"`
// Max supported generation
MaxSupportedGeneration string `json:"max_supported_generation"`
}
// Main information about node
@@ -257,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"`

View 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))
}

View File

@@ -11,12 +11,12 @@ import (
// ConsumptionRequest struct to get consumption info
type ConsumptionRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// Required: false
SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"`
}
// Consumption gets SEP consumption info
func (s SEP) Consumption(ctx context.Context, req ConsumptionRequest) (*RecordConsumption, error) {
func (s SEP) Consumption(ctx context.Context, req ConsumptionRequest) (*ListConsumption, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
@@ -29,7 +29,7 @@ func (s SEP) Consumption(ctx context.Context, req ConsumptionRequest) (*RecordCo
return nil, err
}
info := RecordConsumption{}
info := ListConsumption{}
err = json.Unmarshal(res, &info)
if err != nil {

View File

@@ -47,8 +47,22 @@ type ByPool struct {
UsageLimit uint64 `json:"usage_limit"`
}
// List of Resource groups
type ListConsumption struct {
// Data
Data []RecordConsumption `json:"data"`
// Enrtry count
EntryCount uint64 `json:"entryCount"`
}
// Main information about consumption
type RecordConsumption struct {
// ID
ID uint64 `json:"id"`
// Name
Name string `json:"name"`
// By pool
ByPool map[string]ByPool `json:"byPool"`
@@ -57,6 +71,9 @@ type RecordConsumption struct {
// Type
Type string `json:"type"`
// Consumed by
ConsumedBy []uint64 `json:"consumedBy"`
}
// Main information about URI

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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"`

View File

@@ -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

View File

@@ -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"`
}

View 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))
}

View 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
}

View File

@@ -30,7 +30,6 @@ func (m *migrator) Migrate(ctxOrigin context.Context, dxVMID, nodeID uint64) (bo
req := compute.MigrateRequest{
ComputeID: dxVMID,
TargetNodeID: nodeID,
Force: false,
}
ctx, cancel := context.WithTimeout(ctxOrigin, m.cfg.QueryTimeout)
ok, err := m.client.CloudBroker().Compute().Migrate(ctx, req)

View File

@@ -123,7 +123,7 @@ func TestGetListCloudAPI(t *testing.T) {
getResult("Compute list", bytes, compute.ListComputes{}, t)
// Get
listComp, _ := client.CloudAPI().Compute().List(context.Background(), compute.ListRequest{})
if len(listComp.Data) > 0 {
if listComp != nil && len(listComp.Data) > 0 {
id := listComp.Data[0].ID
bytes, err = client.CloudAPI().Compute().GetRaw(context.Background(), compute.GetRequest{ComputeID: id})
if err != nil {
@@ -711,7 +711,7 @@ func TestGetListCloudbroker(t *testing.T) {
getResult("Node list", bytes, node_cb.ListNodes{}, t)
// Get
listNode, _ := client.CloudBroker().Node().List(context.Background(), node_cb.ListRequest{})
if len(listLB.Data) > 0 {
if listNode != nil && len(listNode.Data) > 0 {
id := listNode.Data[0].ID
bytes, err = client.CloudBroker().Node().GetRaw(context.Background(), node_cb.GetRequest{NID: id})
if err != nil {
@@ -725,11 +725,11 @@ func TestGetListCloudbroker(t *testing.T) {
}
getResult("Node get_network_info", bytes, node_cb.RecordNodeNetworkInfo{}, t)
} else {
t.Errorf("Can not test Node get because LB list is empty")
t.Errorf("Can not test Node get because node list is empty")
}
// Node GetPCIDevices
if len(listNode.Data) > 0 {
if listNode != nil && len(listNode.Data) > 0 {
id := listNode.Data[0].ID
bytes, err = client.CloudBroker().Node().GetPCIDevicesRaw(context.Background(), node_cb.GetPCIDevicesRequest{NodeID: id})
if err != nil {

View File

@@ -780,6 +780,7 @@ func getRequestsMapCloudbroker() map[string]interface{} {
"/restmachine/cloudbroker/grid/setPasswordPolicy": grid_cb.SetPasswordPolicyRequest{},
"/restmachine/cloudbroker/grid/status": EmptyStruct{},
"/restmachine/cloudbroker/grid/getSettings": grid_cb.GetSettingsRequest{},
"/restmachine/cloudbroker/grid/set_resources_limit": grid_cb.SetResourcesLimitRequest{},
// group
"/restmachine/cloudbroker/group/get": group_cb.GetRequest{},
@@ -907,6 +908,7 @@ func getRequestsMapCloudbroker() map[string]interface{} {
"/restmachine/cloudbroker/node/get_logical_cores_count": node_cb.GetLogicalCoresCountRequest{},
"/restmachine/cloudbroker/node/set_cpu_allocation_ratio": node_cb.SetCpuAllocationRatioRequest{},
"/restmachine/cloudbroker/node/set_mem_allocation_ratio": node_cb.SetMemAllocationRatioRequest{},
"/restmachine/cloudbroker/node/set_resources_limit": node_cb.SetResourcesLimitRequest{},
"/restmachine/cloudbroker/node/autostart": node_cb.AutoStartRequest{},
"/restmachine/cloudbroker/node/get_network_info": node_cb.GetNetworkInfoRequest{},
"/restmachine/cloudbroker/node/get_pci_devices": node_cb.GetPCIDevicesRequest{},
@@ -1111,19 +1113,21 @@ func getRequestsMapCloudbroker() map[string]interface{} {
"/restmachine/cloudbroker/vins/migrateToZone": vins_cb.MigrateToZoneRequest{},
// zone
"/restmachine/cloudbroker/zone/get": zone_cb.GetRequest{},
"/restmachine/cloudbroker/zone/list": zone_cb.ListRequest{},
"/restmachine/cloudbroker/zone/create": zone_cb.CreateRequest{},
"/restmachine/cloudbroker/zone/delete": zone_cb.DeleteRequest{},
"/restmachine/cloudbroker/zone/update": zone_cb.UpdateRequest{},
"/restmachine/cloudbroker/zone/addNode": zone_cb.AddNodeRequest{},
"/restmachine/cloudbroker/zone/delNode": zone_cb.DelNodeRequest{},
"/restmachine/cloudbroker/zone/node_autostart": zone_cb.NodeAutoStartRequest{},
"/restmachine/cloudbroker/zone/add_cpu_alignment_profile": zone_cb.AddCPUAlignmentProfileRequest{},
"/restmachine/cloudbroker/zone/get": zone_cb.GetRequest{},
"/restmachine/cloudbroker/zone/list": zone_cb.ListRequest{},
"/restmachine/cloudbroker/zone/create": zone_cb.CreateRequest{},
"/restmachine/cloudbroker/zone/delete": zone_cb.DeleteRequest{},
"/restmachine/cloudbroker/zone/update": zone_cb.UpdateRequest{},
"/restmachine/cloudbroker/zone/addNode": zone_cb.AddNodeRequest{},
"/restmachine/cloudbroker/zone/delNode": zone_cb.DelNodeRequest{},
"/restmachine/cloudbroker/zone/node_autostart": zone_cb.NodeAutoStartRequest{},
"/restmachine/cloudbroker/zone/add_cpu_alignment_profile": zone_cb.AddCPUAlignmentProfileRequest{},
"/restmachine/cloudbroker/zone/delete_cpu_alignment_profile": zone_cb.DeleteCPUAlignmentProfileRequest{},
"/restmachine/cloudbroker/zone/get_cpu_alignment_profile": zone_cb.GetCPUAlignmentProfileRequest{},
"/restmachine/cloudbroker/zone/list_cpu_alignment_profile": zone_cb.ListCPUAlignmentProfileRequest{},
"/restmachine/cloudbroker/zone/test_cpu_alignment_profile": zone_cb.TestCPUAlignmentProfileRequest{},
"/restmachine/cloudbroker/zone/get_cpu_alignment_profile": zone_cb.GetCPUAlignmentProfileRequest{},
"/restmachine/cloudbroker/zone/list_cpu_alignment_profile": zone_cb.ListCPUAlignmentProfileRequest{},
"/restmachine/cloudbroker/zone/test_cpu_alignment_profile": zone_cb.TestCPUAlignmentProfileRequest{},
"/restmachine/cloudbroker/zone/set_resources_limit": zone_cb.SetResourcesLimitRequest{},
"/restmachine/cloudbroker/zone/update_cpu_alignment_profile": zone_cb.UpdateCPUAlignmentProfileRequest{},
// security policy
"/sdn/security_policy/create": secpolicies.CreateRequest{},

View File

@@ -183,6 +183,9 @@ func GetMapFromBytes(bytes []byte) (map[string]interface{}, error) {
if err != nil {
return nil, err
}
if len(unmarshalSlice) == 0 {
return map[string]interface{}{}, nil
}
t, ok := unmarshalSlice[0].(map[string]interface{})
if !ok {
return nil, err
@@ -228,10 +231,20 @@ func getMapBytes(value map[string]interface{}) map[string]interface{} {
func GetMapFromStructure(structure any) map[string]interface{} {
typ := reflect.TypeOf(structure)
return getMapStruct(typ)
for typ.Kind() == reflect.Slice || typ.Kind() == reflect.Ptr {
typ = typ.Elem()
}
return getMapStruct(typ, make(map[reflect.Type]bool))
}
func getMapStruct(t reflect.Type) map[string]interface{} {
func getMapStruct(t reflect.Type, visited map[reflect.Type]bool) map[string]interface{} {
if visited[t] {
return map[string]interface{}{}
}
visited[t] = true
defer func() { visited[t] = false }()
temporary := make(map[string]interface{})
for i := 0; i < t.NumField(); i++ {
tag := t.Field(i).Tag.Get("json")
@@ -243,16 +256,16 @@ func getMapStruct(t reflect.Type) map[string]interface{} {
elem := t.Field(i).Type.Elem()
switch elem.Kind() {
case reflect.Struct:
temporary[tag] = getMapStruct(elem)
temporary[tag] = getMapStruct(elem, visited)
default:
temporary[tag] = map[string]interface{}{}
}
case reflect.Struct:
if tag == "" {
return getMapStruct(t.Field(i).Type)
return getMapStruct(t.Field(i).Type, visited)
} else {
temporary[tag] = getMapStruct(t.Field(i).Type)
temporary[tag] = getMapStruct(t.Field(i).Type, visited)
}
// в этом месте работает некорректно для вложенных структур без json тегов (scope - все в cloudbroker)