Compare commits

...

3 Commits

Author SHA1 Message Date
30e464e4d2 v1.14.6 2026-04-03 16:26:42 +03:00
9258a1574b v1.14.5 2026-03-27 17:29:52 +03:00
dayterr
444a33dc7e v1.14.4
v1.14.4
2026-03-20 17:14:16 +03:00
52 changed files with 968 additions and 135 deletions

View File

@@ -1,4 +1,4 @@
## Version 1.14.3 ## Version 1.14.6
Методы `Audits` в cloudapi/compute, cloudbroker/compute, cloudapi/account, cloudbroker/account, cloudapi/vins, cloudbroker/vins, cloudapi/rg и cloudbroker/rg стали deprecated и в следующих версиях будут удалены, вместо них необходимо использовать метод `List` в cloudapi/audit и cloudbroker/audit с соответствующими фильтрами Методы `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 и в следующих версиях будут удалены Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и в следующих версиях будут удалены
@@ -9,62 +9,69 @@
### Добавлено ### Добавлено
#### compute #### extnet
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-805 | Вычисляемое поле `Provision` в структуру ответа `ItemComputeDisk` в cloudapi/compute и в структуру ответа `ItemDisk` в cloudbroker/compute | | BGOS-825 | Опциональное поле `EnableSecGroups` в структуру запроса `CreateRequest` в cloudbroker/extnet |
#### disks #### grid
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-806 | Вычисляемое поле `Provision` в структуры ответа `ItemDisk`, `ItemDiskUnattached` и `RecordDisk` в cloudapi/disks и в структуру ответа `InfoDisk` в cloudbroker/disks | | BGOS-828 | Вычисляемое поле `ZeroAccessEnabled` в структуру ответа `ItemLocation` в cloudbroker/grid |
### node #### dpdknet
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-802 | Опциональное поле `Target` в структуру запроса `GetLogicalCoresCountRequest` в cloudbroker/node | | BGOS-825 | Опциональное поле `EnableSecGroups` в структуру запроса `CreateRequest` в cloudbroker/dpdknet |
#### rg ### sep
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-803 | Опциональное поле `CPUAllocationParameter` в структуру запроса `UpdateRequest` в cloudbroker/rg | | BGOS-832 | Метод `AddPoolAsync` в cloudbroker/sep |
#### SDN Logical Ports #### vins
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-695 | Опциональное поле `Labels` в структуры запроса `CreateRequest` и `UpdateRequest` в sdn/logical_ports | | BGOS-825 | Опциональное поле `EnableSecGroups` в структуру запроса `CreateInAccountRequest` в cloudbroker/vins и cloudapi/vins |
| BGOS-695 | Вычисляемое поле `Labels` в структуру ответа `LogicalPort` в sdn/logical_ports | | BGOS-825 | Опциональное поле `EnableSecGroups` в структуру запроса `CreateInRGRequest` в cloudbroker/vins и cloudapi/vins |
| BGOS-695 | Опциональные поля `OperationStatus` и `HypervisorStatus` в структуру запроса `ListRequest` в sdn/logical_ports |
| BGOS-695 | Вычисляемые поля `OperationStatus` и `HypervisorStatus` в структуре `Status` в структуру ответа `LogicalPort` в sdn/logical_ports |
### Изменено ### Изменено
#### compute #### compute
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-794 | Тип возвращаемого значения метода `AbortSharedSnapshotMerge` с `bool` на `string` в cloudapi/compute и в cloudbroker/compute | | BGOS-827 | Описание поля `EnableSecGroups` в структуре запроса `NetAttachRequest` в cloudapi/compute и в cloudbroker/compute |
#### kvmx86 #### kvmx86
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-808 | Минимальное значение поля `MTU` в структуре `Interface` в cloudapi/kvmx86 и cloudbroker/kvmx86 и в структуре `InterfaceMassCreate` в cloudbroker/kvmx86 с 1 на 1500 | | BGOS-827 | Описание поля `EnableSecGroups` в структуре `Interface` в структуре запроса `CreateRequest` и `CreateBlankRequest` в cloudapi/kvmx86 и в cloudbroker/kvmx86 |
| BGOS-827 | Описание поля `EnableSecGroups` в структуре `InterfaceMassCreate` в структурах запроса `MassCreateRequest` в cloudbroker/kvmx86 |
#### zone #### lb
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-807 | JSON-тег у вычисляемого поля `LBIDs` в структуре ответа `RecordZone` с `lbIds` на `lbsIds` в cloudapi/zone | | BGOS-830 | Тип ответа метода `HighlyAvailable` в cloudapi/lb с uint64 на bool |
#### SDN Logical Ports #### sep
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-695 | Имя вычисляемого поля со `Status` на `OperationStatus` в sdn/logical_ports | | BGOS-834 | Тип ответа метода `DelConsumerNodes` с bool на interface в cloudbroker/sep |
#### sep
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BGOS-833 | Тип ответа метода `ConfigFieldEdit` с bool на структуру `RecordConfigFieldEdit` в cloudbroker/sep |
### Удалено ### Удалено
#### SDN Logical Ports #### grid
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-695 | Обязательное поле `IsExcludedFromFirewall` в структурах запроса `CreateRequest` и `UpdateRequest` в sdn/logical_ports | | BGOS-826 | Структура запроса `AddRequest` и метод `Add` в cloudbroker/grid |
| BGOS-695 | Вычисляемое поле `IsExcludedFromFirewall` в структуре `Bindings` в структуре ответа `LogicalPort` в sdn/logical_ports |
| BGOS-695 | Вычисляемое поле `Common` в структуре `Status` в структуре ответа `LogicalPort` в sdn/logical_ports | #### sep
| BGOS-695 | Структуры запроса `ExcludeFirewallRequest`, `UnexcludeFirewallRequest`, `CreateBatchRequest` и `DeleteBatchRequest` и методы `ExcludeFirewall`, `UnexcludeFirewall`, `CreateBatch` и `DeleteBatch` в sdn/logical_ports | | Идентификатор<br>задачи | Описание |
| --- | --- |
| BGOS-832 | Опциональное поле `Sync` из структуры запроса `AddPoolRequest` в cloudbroker/sep |

View File

@@ -160,6 +160,7 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
- `PCIDevice` - управление устройствами; - `PCIDevice` - управление устройствами;
- `Prometheus` - получение статистики prometheus; - `Prometheus` - получение статистики prometheus;
- `Resmon` - получение статистики resource monitoring; - `Resmon` - получение статистики resource monitoring;
- `ResourceOptimizer` - управление инструментом оптимизации ресурсов (DRS);
- `RG` - управление ресурсными группами аккаунта; - `RG` - управление ресурсными группами аккаунта;
- `Security group` управление группами безопасности; - `Security group` управление группами безопасности;
- `SEP` - управление storage endpoint (sep); - `SEP` - управление storage endpoint (sep);
@@ -365,6 +366,7 @@ func main() {
- `pkg/cloudbroker/pcidevice` - для `PCIDevice` - `pkg/cloudbroker/pcidevice` - для `PCIDevice`
- `pkg/cloudbroker/prometheus` - для `Prometheus` - `pkg/cloudbroker/prometheus` - для `Prometheus`
- `pkg/cloudbroker/resmon` - для `Resmon` - `pkg/cloudbroker/resmon` - для `Resmon`
- `pkg/cloudbroker/resource_optimizer` - для `ResourceOptimizer`
- `pkg/cloudbroker/rg` - для `RG` - `pkg/cloudbroker/rg` - для `RG`
- `pkg/cloudbroker/secgroup` - для `Security group` - `pkg/cloudbroker/secgroup` - для `Security group`
- `pkg/cloudbroker/sep` - для `SEP` - `pkg/cloudbroker/sep` - для `SEP`
@@ -563,6 +565,7 @@ func main() {
- `.PCIDevice()` - для работы с `PCIDevice` - `.PCIDevice()` - для работы с `PCIDevice`
- `.Prometheus()` - для работы с `Prometheus` - `.Prometheus()` - для работы с `Prometheus`
- `.Resmon()` - для работы с `Resmon` - `.Resmon()` - для работы с `Resmon`
- `.ResourceOptimizer()` - для работы с `ResourceOptimizer`
- `.RG()` - для работы с `RG` - `.RG()` - для работы с `RG`
- `.SecurityGroup()` - для работы с `Security Group` - `.SecurityGroup()` - для работы с `Security Group`
- `.SEP()` - для работы с `SEP` - `.SEP()` - для работы с `SEP`

View File

@@ -74,6 +74,7 @@ type NetAttachRequest struct {
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"` SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
// Flag indicating whether security groups are enabled for this interface // Flag indicating whether security groups are enabled for this interface
// Not applicable to netType VFNIC, TRUNK, or SDN
// Required: false // Required: false
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"` EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`

View File

@@ -16,8 +16,10 @@ type SnapshotCreateRequest struct {
// Text label for snapshot. // Text label for snapshot.
// Must be unique among this compute snapshots // Must be unique among this compute snapshots
// Allowed characters: a-z, 0-9, spaces, punctuation except '<' and '>'
// Maximum length: 36 characters
// Required: true // Required: true
Label string `url:"label" json:"label" validate:"required"` Label string `url:"label" json:"label" validate:"required,max=36,excludesall=<>"`
} }
// SnapshotCreate create compute snapshot // SnapshotCreate create compute snapshot

View File

@@ -149,6 +149,9 @@ type RecordImage struct {
// Link to // Link to
LinkTo uint64 `json:"linkTo"` LinkTo uint64 `json:"linkTo"`
// Links to
LinksTo []uint64 `json:"linksTo"`
// Milestones // Milestones
Milestones uint64 `json:"milestones"` Milestones uint64 `json:"milestones"`

View File

@@ -69,6 +69,7 @@ type Interface struct {
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"` SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
// Flag indicating whether security groups are enabled for this interface // Flag indicating whether security groups are enabled for this interface
// Not applicable to netType VFNIC, TRUNK, or SDN
// Required: false // Required: false
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"` EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`

View File

@@ -16,22 +16,22 @@ type HighlyAvailableRequest struct {
} }
// HighlyAvailable makes load balancer highly available // HighlyAvailable makes load balancer highly available
func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (uint64, error) { func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
return 0, validators.ValidationErrors(validators.GetErrors(err)) return false, validators.ValidationErrors(validators.GetErrors(err))
} }
url := "/cloudapi/lb/makeHighlyAvailable" url := "/cloudapi/lb/makeHighlyAvailable"
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req) res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil { if err != nil {
return 0, err return false, err
} }
result, err := strconv.ParseUint(string(res), 10, 64) result, err := strconv.ParseBool(string(res))
if err != nil { if err != nil {
return 0, err return false, err
} }
return result, nil return result, nil

View File

@@ -34,6 +34,9 @@ type ItemLocation struct {
// Support of SDN // Support of SDN
SDNSupport bool `json:"sdn_support"` SDNSupport bool `json:"sdn_support"`
// Is Zero Access enabled
ZeroAccessEnabled bool `json:"zeroaccess_enabled"`
} }
// List of locations // List of locations

View File

@@ -57,6 +57,11 @@ type CreateInAccountRequest struct {
// Zone ID // Zone ID
// Required: false // Required: false
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
// Enable security groups for VINS
// Required: false
// Default: false
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
} }
type wrapperCreateRequestInAcc struct { type wrapperCreateRequestInAcc struct {

View File

@@ -51,6 +51,11 @@ type CreateInRGRequest struct {
// Zone ID // Zone ID
// Required: false // Required: false
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
// Enable security groups for VINS
// Required: false
// Default: false
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
} }
type wrapperCreateRequestInRG struct { type wrapperCreateRequestInRG struct {

View File

@@ -2,7 +2,7 @@ package zone
// FilterByID returns ListZones with specified ID. // FilterByID returns ListZones with specified ID.
func (list ListZones) FilterByID(id uint64) ListZones { func (list ListZones) FilterByID(id uint64) ListZones {
predicate := func(izone RecordZone) bool { predicate := func(izone ItemZone) bool {
return izone.ID == id return izone.ID == id
} }
@@ -11,7 +11,7 @@ func (list ListZones) FilterByID(id uint64) ListZones {
// FilterByName returns ListZones with specified Name. // FilterByName returns ListZones with specified Name.
func (list ListZones) FilterByName(name string) ListZones { func (list ListZones) FilterByName(name string) ListZones {
predicate := func(izone RecordZone) bool { predicate := func(izone ItemZone) bool {
return izone.Name == name return izone.Name == name
} }
@@ -20,7 +20,7 @@ func (list ListZones) FilterByName(name string) ListZones {
// FilterByStatus returns ListZones with specified Status. // FilterByStatus returns ListZones with specified Status.
func (list ListZones) FilterByStatus(status string) ListZones { func (list ListZones) FilterByStatus(status string) ListZones {
predicate := func(izone RecordZone) bool { predicate := func(izone ItemZone) bool {
return izone.Status == status return izone.Status == status
} }
@@ -28,7 +28,7 @@ func (list ListZones) FilterByStatus(status string) ListZones {
} }
// FilterFunc allows filtering ListZones based on a user-specified predicate. // FilterFunc allows filtering ListZones based on a user-specified predicate.
func (list ListZones) FilterFunc(predicate func(RecordZone) bool) ListZones { func (list ListZones) FilterFunc(predicate func(ItemZone) bool) ListZones {
var result ListZones var result ListZones
for _, item := range list.Data { for _, item := range list.Data {
@@ -42,11 +42,11 @@ func (list ListZones) FilterFunc(predicate func(RecordZone) bool) ListZones {
return result return result
} }
// FindOne returns first found RecordZone // FindOne returns first found ItemZone
// If none was found, returns an empty struct. // If none was found, returns an empty struct.
func (list ListZones) FindOne() RecordZone { func (list ListZones) FindOne() ItemZone {
if list.EntryCount == 0 { if list.EntryCount == 0 {
return RecordZone{} return ItemZone{}
} }
return list.Data[0] return list.Data[0]

View File

@@ -3,7 +3,7 @@ package zone
import "testing" import "testing"
var zones = ListZones{ var zones = ListZones{
Data: []RecordZone{ Data: []ItemZone{
{ {
ID: 2, ID: 2,
@@ -76,7 +76,7 @@ func TestFilterByStatus(t *testing.T) {
} }
func TestFilterFunc(t *testing.T) { func TestFilterFunc(t *testing.T) {
actual := zones.FilterFunc(func(ien RecordZone) bool { actual := zones.FilterFunc(func(ien ItemZone) bool {
return ien.Deletable == true return ien.Deletable == true
}) })

View File

@@ -5,7 +5,7 @@ type ListZones struct {
EntryCount uint64 `json:"entryCount"` EntryCount uint64 `json:"entryCount"`
// Data // Data
Data []RecordZone `json:"data"` Data []ItemZone `json:"data"`
} }
// Detailed information about the zone record // Detailed information about the zone record
@@ -63,4 +63,76 @@ type RecordZone struct {
// List of associated VINS IDs // List of associated VINS IDs
VinsIDs []uint64 `json:"vinsIds"` VinsIDs []uint64 `json:"vinsIds"`
// DRS
DRS bool `json:"drs"`
// DRS UID
DRSUID string `json:"drs_uid"`
// App ID
AppID string `json:"app_id"`
// Decort URL
DecortURL string `json:"decort_url"`
// DRS Name
DRSName string `json:"drs_name"`
// SSO URL
SSOURL string `json:"sso_url"`
}
// A zone item from a list
type ItemZone struct {
// App ID
AppID string `json:"app_id"`
// If true, all nodes belonging to the given zone will be marked for autostart
AutoStart bool `json:"autostart"`
// Created timestamp
CreatedTime uint64 `json:"createdTime"`
// Decort URL
DecortURL string `json:"decort_url"`
// Deletable flag
Deletable bool `json:"deletable"`
// Description
Description string `json:"description"`
// DRS
DRS bool `json:"drs"`
// DRS Name
DRSName string `json:"drs_name"`
// DRS UID
DRSUID string `json:"drs_uid"`
// GID
GID uint64 `json:"gid"`
// GUID
GUID uint64 `json:"guid"`
// ID
ID uint64 `json:"id"`
// Name
Name string `json:"name"`
// List of associated Node IDs
NodeIDs []uint64 `json:"nodeIds"`
// SSO URL
SSOURL string `json:"sso_url"`
// Status
Status string `json:"status"`
// Updated timestamp
UpdatedTime uint64 `json:"updatedTime"`
} }

View File

@@ -1535,4 +1535,4 @@ type CheckComputePlacementItem struct {
Error CheckComputePlacementError `json:"error,omitempty"` Error CheckComputePlacementError `json:"error,omitempty"`
} }
type CheckComputePlacementResult map[string]CheckComputePlacementItem type CheckComputePlacementResult map[uint64]CheckComputePlacementItem

View File

@@ -74,6 +74,7 @@ type NetAttachRequest struct {
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"` SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
// Flag indicating whether security groups are enabled for this interface // Flag indicating whether security groups are enabled for this interface
// Not applicable to netType VFNIC, TRUNK, or SDN
// Required: false // Required: false
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"` EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`

View File

@@ -16,8 +16,10 @@ type SnapshotCreateRequest struct {
// Text label for snapshot. // Text label for snapshot.
// Must be unique among this compute snapshots // Must be unique among this compute snapshots
// Allowed characters: a-z, 0-9, spaces, punctuation except '<' and '>'
// Maximum length: 36 characters
// Required: true // Required: true
Label string `url:"label" json:"label" validate:"required"` Label string `url:"label" json:"label" validate:"required,max=36,excludesall=<>"`
} }
// SnapshotCreate creates compute snapshot // SnapshotCreate creates compute snapshot

View File

@@ -37,6 +37,11 @@ type CreateRequest struct {
// List of resource groups IDs to which DPDK network will be available. Empty field means all resource groups in the system. // List of resource groups IDs to which DPDK network will be available. Empty field means all resource groups in the system.
// Required: false // Required: false
RGAccess []uint64 `url:"rgAccess,omitempty" json:"rgAccess,omitempty"` RGAccess []uint64 `url:"rgAccess,omitempty" json:"rgAccess,omitempty"`
// Enable security groups for DPDK network
// Required: false
// Default: false
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
} }
// Create creates a DPDK networks // Create creates a DPDK networks

View File

@@ -104,6 +104,11 @@ type CreateRequest struct {
// Required: false // Required: false
// Default: false // Default: false
HAMode bool `url:"highlyAvailable,omitempty" json:"highlyAvailable,omitempty"` HAMode bool `url:"highlyAvailable,omitempty" json:"highlyAvailable,omitempty"`
// Enable security groups for external network
// Required: false
// Default: false
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
} }
type wrapperCreateRequest struct { type wrapperCreateRequest struct {

View File

@@ -1,46 +0,0 @@
package grid
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// AddRequest struct for location code
type AddRequest struct {
// Grid (platform) ID
// Required: true
GID uint64 `url:"gid" json:"gid" validate:"required"`
// Name of the location
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// Location code typicly used in dns names
// Required: true
LocationCode string `url:"locationcode" json:"locationcode" validate:"required"`
}
// Add location code (e.g. DNS name of this grid)
func (g Grid) Add(ctx context.Context, req AddRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/grid/add"
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
}

View File

@@ -129,6 +129,9 @@ type ItemGridList struct {
// SDN support // SDN support
SDNSupport bool `json:"sdn_support"` SDNSupport bool `json:"sdn_support"`
// Is Zero Access enabled
ZeroAccessEnabled bool `json:"zeroaccess_enabled"`
} }
// List Grids // List Grids

View File

@@ -0,0 +1,47 @@
package image
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// CreateMultiImageRequest struct to create multi image
type CreateMultiImageRequest struct {
// Name of the multi image
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// IDs of real images
// Required: true
TargetIDs []uint64 `url:"target_ids" json:"target_ids" validate:"required"`
// Account ID
// Required: false
AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"`
}
// CreateMultiImage creates multi image
func (i Image) CreateMultiImage(ctx context.Context, req CreateMultiImageRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
return 0, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/image/create_multi_image"
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return 0, err
}
result, err := strconv.ParseUint(string(res), 10, 64)
if err != nil {
return 0, err
}
return result, nil
}

View File

@@ -39,11 +39,11 @@ type EditRequest struct {
// Does this machine supports hot resize // Does this machine supports hot resize
// Required: false // Required: false
HotResize bool `url:"hotresize,omitempty" json:"hotresize,omitempty"` HotResize interface{} `url:"hotresize,omitempty" json:"hotresize,omitempty" validate:"omitempty,isBool"`
// Does this image boot OS // Does this image boot OS
// Required: false // Required: false
Bootable bool `url:"bootable,omitempty" json:"bootable,omitempty"` Bootable interface{} `url:"bootable,omitempty" json:"bootable,omitempty" validate:"omitempty,isBool"`
} }
// Edit edits an existing image // Edit edits an existing image

View File

@@ -62,6 +62,9 @@ type RecordImage struct {
// Link to // Link to
LinkTo uint64 `json:"linkTo"` LinkTo uint64 `json:"linkTo"`
// Links to
LinksTo []uint64 `json:"linksTo"`
// Milestones // Milestones
Milestones uint64 `json:"milestones"` Milestones uint64 `json:"milestones"`
@@ -197,6 +200,9 @@ type ItemImage struct {
// Link to // Link to
LinkTo uint64 `json:"linkTo"` LinkTo uint64 `json:"linkTo"`
// Links to
LinksTo []uint64 `json:"linksTo"`
// Milestones // Milestones
Milestones uint64 `json:"milestones"` Milestones uint64 `json:"milestones"`

View File

@@ -0,0 +1,43 @@
package image
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// MultiImageAddLinksRequest struct to add links to multi image
type MultiImageAddLinksRequest struct {
// ID of the multi image
// Required: true
ImageID uint64 `url:"image_id" json:"image_id" validate:"required"`
// IDs of real images
// Required: true
TargetIDs []uint64 `url:"target_ids" json:"target_ids" validate:"required"`
}
// MultiImageAddLinks adds image links to multi image
func (i Image) MultiImageAddLinks(ctx context.Context, req MultiImageAddLinksRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/image/multi_image_add_links"
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -0,0 +1,43 @@
package image
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// MultiImageDelLinksRequest struct to delete links from multi image
type MultiImageDelLinksRequest struct {
// ID of the multi image
// Required: true
ImageID uint64 `url:"image_id" json:"image_id" validate:"required"`
// IDs of real images
// Required: true
TargetIDs []uint64 `url:"target_ids" json:"target_ids" validate:"required"`
}
// MultiImageDelLinks removes image links from multi image
func (i Image) MultiImageDelLinks(ctx context.Context, req MultiImageDelLinksRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/image/multi_image_del_links"
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -0,0 +1,46 @@
package image
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// MultiImageExportRequest struct to export multi image to a pool
type MultiImageExportRequest struct {
// ID of the multi image
// Required: true
MultiImageID uint64 `url:"multi_image_id" json:"multi_image_id" validate:"required"`
// Name of the target pool
// Required: true
PoolName string `url:"pool_name" json:"pool_name" validate:"required"`
// Target SEP ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
}
// MultiImageExport copies a physical image from multi image to the specified pool
func (i Image) MultiImageExport(ctx context.Context, req MultiImageExportRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/image/multi_image_export"
res, err := i.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
}

View File

@@ -51,6 +51,7 @@ type Interface struct {
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"` SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
// Flag indicating whether security groups are enabled for this interface // Flag indicating whether security groups are enabled for this interface
// Not applicable to netType VFNIC, TRUNK, or SDN
// Required: false // Required: false
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"` EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`

View File

@@ -45,6 +45,7 @@ type InterfaceMassCreate struct {
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"` SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
// Flag indicating whether security groups are enabled for this interface // Flag indicating whether security groups are enabled for this interface
// Not applicable to netType VFNIC, TRUNK, or SDN
// Required: false // Required: false
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"` EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`

View File

@@ -120,7 +120,7 @@ type FreeResourcesInfo struct {
RAM float64 `json:"RAM"` RAM float64 `json:"RAM"`
// VCPU // VCPU
VCPU uint64 `json:"vCPUs"` VCPU float64 `json:"vCPUs"`
} }
// Resources Info // Resources Info
@@ -155,6 +155,9 @@ type CpuInfo struct {
// PhysCount // PhysCount
PhysCount uint64 `json:"physCount"` PhysCount uint64 `json:"physCount"`
// Thread count
ThreadCount uint64 `json:"threadCount"`
// Flags // Flags
Flags []string `json:"flags"` Flags []string `json:"flags"`

View File

@@ -0,0 +1,10 @@
package cloudbroker
import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/resource_optimizer"
)
// Accessing the ResourceOptimizer method group
func (cb *CloudBroker) ResourceOptimizer() *resource_optimizer.ResourceOptimizer {
return resource_optimizer.New(cb.client)
}

View File

@@ -0,0 +1,42 @@
package resource_optimizer
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DRSAddNodesRequest struct to add nodes to DRS
type DRSAddNodesRequest struct {
// ID of the zone
// Required: true
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
// IDs of the nodes to add
// Required: true
NodeIDs []uint64 `url:"node_ids" json:"node_ids" validate:"required"`
}
// DRSAddNodes adds nodes to DRS in the specified zone
func (ro ResourceOptimizer) DRSAddNodes(ctx context.Context, req DRSAddNodesRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/resource_optimizer/drs_add_nodes"
res, err := ro.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
}

View File

@@ -0,0 +1,58 @@
package resource_optimizer
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DRSCreateRequest struct to create DRS
type DRSCreateRequest struct {
// ID of the zone
// Required: true
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
// Application ID
// Required: true
AppID string `url:"app_id" json:"app_id" validate:"required"`
// Application secret
// Required: true
AppSecret string `url:"app_secret" json:"app_secret" validate:"required"`
// Decort URL
// Required: true
DecortURL string `url:"decort_url" json:"decort_url" validate:"required"`
// SSO URL
// Required: true
SSOURL string `url:"sso_url" json:"sso_url" validate:"required"`
// DRS name
// Required: true
DRSName string `url:"drs_name" json:"drs_name" validate:"required"`
}
// DRSCreate creates a new DRS in the specified zone
func (ro ResourceOptimizer) DRSCreate(ctx context.Context, req DRSCreateRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/resource_optimizer/drs_create"
res, err := ro.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
}

View File

@@ -0,0 +1,42 @@
package resource_optimizer
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DRSDelNodesRequest struct to delete nodes from DRS
type DRSDelNodesRequest struct {
// ID of the zone
// Required: true
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
// IDs of the nodes to delete
// Required: true
NodeIDs []uint64 `url:"node_ids" json:"node_ids" validate:"required"`
}
// DRSDelNodes removes nodes from DRS in the specified zone
func (ro ResourceOptimizer) DRSDelNodes(ctx context.Context, req DRSDelNodesRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/resource_optimizer/drs_del_nodes"
res, err := ro.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
}

View File

@@ -0,0 +1,38 @@
package resource_optimizer
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DRSRemoveRequest struct to remove DRS
type DRSRemoveRequest struct {
// ID of the zone
// Required: true
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
}
// DRSRemove removes DRS from the specified zone
func (ro ResourceOptimizer) DRSRemove(ctx context.Context, req DRSRemoveRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/resource_optimizer/drs_remove"
res, err := ro.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
}

View File

@@ -0,0 +1,38 @@
package resource_optimizer
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DRSStartRequest struct to start DRS
type DRSStartRequest struct {
// ID of the zone
// Required: true
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
}
// DRSStart starts DRS in the specified zone
func (ro ResourceOptimizer) DRSStart(ctx context.Context, req DRSStartRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/resource_optimizer/drs_start"
res, err := ro.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
}

View File

@@ -0,0 +1,38 @@
package resource_optimizer
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DRSStopRequest struct to stop DRS
type DRSStopRequest struct {
// ID of the zone
// Required: true
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
}
// DRSStop stops DRS in the specified zone
func (ro ResourceOptimizer) DRSStop(ctx context.Context, req DRSStopRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/resource_optimizer/drs_stop"
res, err := ro.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
}

View File

@@ -0,0 +1,58 @@
package resource_optimizer
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DRSUpdateRequest struct to update DRS
type DRSUpdateRequest struct {
// ID of the zone
// Required: true
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
// Application ID
// Required: false
AppID string `url:"app_id,omitempty" json:"app_id,omitempty"`
// Application secret
// Required: false
AppSecret string `url:"app_secret,omitempty" json:"app_secret,omitempty"`
// Decort URL
// Required: false
DecortURL string `url:"decort_url,omitempty" json:"decort_url,omitempty"`
// SSO URL
// Required: false
SSOURL string `url:"sso_url,omitempty" json:"sso_url,omitempty"`
// DRS name
// Required: false
DRSName string `url:"drs_name,omitempty" json:"drs_name,omitempty"`
}
// DRSUpdate updates DRS configuration in the specified zone
func (ro ResourceOptimizer) DRSUpdate(ctx context.Context, req DRSUpdateRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/resource_optimizer/drs_update"
res, err := ro.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
}

View File

@@ -0,0 +1,16 @@
// API Actor API for managing resource optimizer
package resource_optimizer
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
// Structure for creating request to resource_optimizer
type ResourceOptimizer struct {
client interfaces.Caller
}
// Builder for resource_optimizer endpoints
func New(client interfaces.Caller) *ResourceOptimizer {
return &ResourceOptimizer{
client: client,
}
}

View File

@@ -66,7 +66,7 @@ type ItemResourceConsumption struct {
ResourceLimits ResourceLimits `json:"resourceLimits"` ResourceLimits ResourceLimits `json:"resourceLimits"`
// Resource group ID // Resource group ID
RGID uint64 `json:"rgid"` RGID uint64 `json:"id"`
} }
type ListResourceConsumption struct { type ListResourceConsumption struct {

View File

@@ -3,6 +3,8 @@ package sep
import ( import (
"context" "context"
"net/http" "net/http"
"strconv"
"strings"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
@@ -13,32 +15,66 @@ type AddPoolRequest struct {
// Required: true // Required: true
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"` SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// Method Async/Sync
// Default: true
// Required: false
Sync bool `url:"sync" json:"sync"`
// Pool structure which contains fields such as "name", "usage_limit", "types", "system", "accessAccountIds", "accessResGroupIds". Added fields for other pool types: Des, Ovs - "uris" list of "ip, port". // Pool structure which contains fields such as "name", "usage_limit", "types", "system", "accessAccountIds", "accessResGroupIds". Added fields for other pool types: Des, Ovs - "uris" list of "ip, port".
// Dorado, Tatlin no additional fields required. Hitachi - "id", "snapshotable", "snapshot_pool_id", "minLdevId", "maxLdevId", "clone_technology". Shared - "description", "wwns", "allocate_type", "stripes", "metadata_size", "metadatatalun". Local - "description", "node_consumer", "block_disk". // Dorado, Tatlin no additional fields required. Hitachi - "id", "snapshotable", "snapshot_pool_id", "minLdevId", "maxLdevId", "clone_technology". Shared - "description", "wwns", "allocate_type", "stripes", "metadata_size", "metadatatalun". Local - "description", "node_consumer", "block_disk".
// Required: true // Required: true
Pool string `url:"pool" json:"pool" validate:"required"` Pool string `url:"pool" json:"pool" validate:"required"`
} }
// AddPool adds pool to SEP type wrapperAddPoolRequest struct {
func (s SEP) AddPool(ctx context.Context, req AddPoolRequest) (string, error) { AddPoolRequest
AsyncMode bool `url:"asyncMode"`
}
// AddPool adds pool to SEP in sync mode.
// It returns result of operation and error.
func (s SEP) AddPool(ctx context.Context, req AddPoolRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperAddPoolRequest{
AddPoolRequest: req,
AsyncMode: false,
}
url := "/cloudbroker/sep/addPool"
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}
// AddPoolAsync adds pool to SEP in async mode.
// It returns guid of task and error.
func (s SEP) AddPoolAsync(ctx context.Context, req AddPoolRequest) (string, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err)) return "", validators.ValidationErrors(validators.GetErrors(err))
} }
reqWrapped := wrapperAddPoolRequest{
AddPoolRequest: req,
AsyncMode: true,
}
url := "/cloudbroker/sep/addPool" url := "/cloudbroker/sep/addPool"
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req) res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil { if err != nil {
return "", err return "", err
} }
result := string(res) result := strings.ReplaceAll(string(res), "\"", "")
return result, nil return result, nil
} }

View File

@@ -2,8 +2,8 @@ package sep
import ( import (
"context" "context"
"encoding/json"
"net/http" "net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
@@ -34,23 +34,25 @@ type ConfigFieldEditRequest struct {
} }
// ConfigFieldEdit edits SEP config field value // ConfigFieldEdit edits SEP config field value
func (s SEP) ConfigFieldEdit(ctx context.Context, req ConfigFieldEditRequest) (bool, error) { func (s SEP) ConfigFieldEdit(ctx context.Context, req ConfigFieldEditRequest) (*RecordConfigFieldEdit, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err)) return nil, validators.ValidationErrors(validators.GetErrors(err))
} }
url := "/cloudbroker/sep/configFieldEdit" url := "/cloudbroker/sep/configFieldEdit"
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req) res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil { if err != nil {
return false, err return nil, err
} }
result, err := strconv.ParseBool(string(res)) info := RecordConfigFieldEdit{}
err = json.Unmarshal(res, &info)
if err != nil { if err != nil {
return false, err return nil, err
} }
return result, nil return &info, nil
} }

View File

@@ -2,8 +2,8 @@ package sep
import ( import (
"context" "context"
"encoding/json"
"net/http" "net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
@@ -25,22 +25,24 @@ type DelConsumerNodesRequest struct {
} }
// DelConsumerNodes excludes consumer nodes from SEP parameters // DelConsumerNodes excludes consumer nodes from SEP parameters
func (s SEP) DelConsumerNodes(ctx context.Context, req DelConsumerNodesRequest) (bool, error) { func (s SEP) DelConsumerNodes(ctx context.Context, req DelConsumerNodesRequest) (interface{}, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err)) return nil, validators.ValidationErrors(validators.GetErrors(err))
} }
url := "/cloudbroker/sep/delConsumerNodes" url := "/cloudbroker/sep/delConsumerNodes"
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req) res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil { if err != nil {
return false, err return nil, err
} }
result, err := strconv.ParseBool(string(res)) var result interface{}
err = json.Unmarshal(res, &result)
if err != nil { if err != nil {
return false, err return nil, err
} }
return result, nil return result, nil

View File

@@ -1,5 +1,7 @@
package sep package sep
import "encoding/json"
// Total resource information // Total resource information
type Total struct { type Total struct {
// Capacity limit // Capacity limit
@@ -185,3 +187,93 @@ type ListAvailableSEP struct {
// Data // Data
Data []SEPData `json:"data"` Data []SEPData `json:"data"`
} }
// Disk clean settings
type DiskCleanSettings struct {
// Block size
BlockSize string `json:"blocksize"`
// Write bytes per second
WBPS uint64 `json:"wbps"`
// Write I/O operations per second
WIOPS uint64 `json:"wiops"`
}
// Pool configuration
type PoolConfig struct {
// Disk clean
DiskClean *string `json:"disk_clean"`
// Disk clean settings
DiskCleanSettings DiskCleanSettings `json:"disk_clean_settings"`
// Pool name
Name string `json:"name"`
// Usage limit
UsageLimit uint64 `json:"usage_limit"`
// Additional properties
AdditionalProperties map[string]interface{} `json:"-"`
}
func (p *PoolConfig) UnmarshalJSON(data []byte) error {
type tmpAlias PoolConfig
if err := json.Unmarshal(data, (*tmpAlias)(p)); err != nil {
return err
}
all := make(map[string]interface{})
if err := json.Unmarshal(data, &all); err != nil {
return err
}
delete(all, "disk_clean")
delete(all, "disk_clean_settings")
delete(all, "name")
delete(all, "usage_limit")
if len(all) > 0 {
p.AdditionalProperties = all
}
return nil
}
// Sep configuration information
type RecordConfigFieldEdit struct {
// Format
Format string `json:"format"`
// Pools
Pools []PoolConfig `json:"pools"`
// Protocol
Protocol string `json:"protocol"`
// Additional properties
AdditionalProperties map[string]interface{} `json:"-"`
}
func (r *RecordConfigFieldEdit) UnmarshalJSON(data []byte) error {
type tmpAlias RecordConfigFieldEdit
if err := json.Unmarshal(data, (*tmpAlias)(r)); err != nil {
return err
}
all := make(map[string]interface{})
if err := json.Unmarshal(data, &all); err != nil {
return err
}
delete(all, "format")
delete(all, "pools")
delete(all, "protocol")
if len(all) > 0 {
r.AdditionalProperties = all
}
return nil
}

View File

@@ -57,6 +57,11 @@ type CreateInAccountRequest struct {
// Zone ID // Zone ID
// Required: false // Required: false
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
// Enable security groups for VINS
// Required: false
// Default: false
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
} }
type wrapperCreateRequestInAcc struct { type wrapperCreateRequestInAcc struct {

View File

@@ -51,6 +51,11 @@ type CreateInRGRequest struct {
// Zone ID // Zone ID
// Required: false // Required: false
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
// Enable security groups for VINS
// Required: false
// Default: false
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
} }
type wrapperCreateRequestInRG struct { type wrapperCreateRequestInRG struct {

View File

@@ -21,6 +21,10 @@ type CreateRequest struct {
// If true, all nodes belonging to the given zone will be marked for autostart // If true, all nodes belonging to the given zone will be marked for autostart
// Required: false // Required: false
AutoStart interface{} `url:"autostart,omitempty" json:"autostart,omitempty" validate:"omitempty,isBool"` AutoStart interface{} `url:"autostart,omitempty" json:"autostart,omitempty" validate:"omitempty,isBool"`
// Enables Distributed Resource Scheduler (DRS) functionality for the zone
// Required: false
DRS interface{} `url:"drs,omitempty" json:"drs,omitempty" validate:"omitempty,isBool"`
} }
// Create creates zone object // Create creates zone object

View File

@@ -2,7 +2,7 @@ package zone
// FilterByID returns ListZones with specified ID. // FilterByID returns ListZones with specified ID.
func (list ListZones) FilterByID(id uint64) ListZones { func (list ListZones) FilterByID(id uint64) ListZones {
predicate := func(izone RecordZone) bool { predicate := func(izone ItemZone) bool {
return izone.ID == id return izone.ID == id
} }
@@ -11,7 +11,7 @@ func (list ListZones) FilterByID(id uint64) ListZones {
// FilterByName returns ListZones with specified Name. // FilterByName returns ListZones with specified Name.
func (list ListZones) FilterByName(name string) ListZones { func (list ListZones) FilterByName(name string) ListZones {
predicate := func(izone RecordZone) bool { predicate := func(izone ItemZone) bool {
return izone.Name == name return izone.Name == name
} }
@@ -20,7 +20,7 @@ func (list ListZones) FilterByName(name string) ListZones {
// FilterByStatus returns ListZones with specified Status. // FilterByStatus returns ListZones with specified Status.
func (list ListZones) FilterByStatus(status string) ListZones { func (list ListZones) FilterByStatus(status string) ListZones {
predicate := func(izone RecordZone) bool { predicate := func(izone ItemZone) bool {
return izone.Status == status return izone.Status == status
} }
@@ -28,7 +28,7 @@ func (list ListZones) FilterByStatus(status string) ListZones {
} }
// FilterFunc allows filtering ListZones based on a user-specified predicate. // FilterFunc allows filtering ListZones based on a user-specified predicate.
func (list ListZones) FilterFunc(predicate func(RecordZone) bool) ListZones { func (list ListZones) FilterFunc(predicate func(ItemZone) bool) ListZones {
var result ListZones var result ListZones
for _, item := range list.Data { for _, item := range list.Data {
@@ -42,11 +42,11 @@ func (list ListZones) FilterFunc(predicate func(RecordZone) bool) ListZones {
return result return result
} }
// FindOne returns first found RecordZone // FindOne returns first found ItemZone
// If none was found, returns an empty struct. // If none was found, returns an empty struct.
func (list ListZones) FindOne() RecordZone { func (list ListZones) FindOne() ItemZone {
if list.EntryCount == 0 { if list.EntryCount == 0 {
return RecordZone{} return ItemZone{}
} }
return list.Data[0] return list.Data[0]

View File

@@ -3,7 +3,7 @@ package zone
import "testing" import "testing"
var zones = ListZones{ var zones = ListZones{
Data: []RecordZone{ Data: []ItemZone{
{ {
ID: 2, ID: 2,
@@ -76,7 +76,7 @@ func TestFilterByStatus(t *testing.T) {
} }
func TestFilterFunc(t *testing.T) { func TestFilterFunc(t *testing.T) {
actual := zones.FilterFunc(func(ien RecordZone) bool { actual := zones.FilterFunc(func(ien ItemZone) bool {
return ien.Deletable == true return ien.Deletable == true
}) })

View File

@@ -5,7 +5,7 @@ type ListZones struct {
EntryCount uint64 `json:"entryCount"` EntryCount uint64 `json:"entryCount"`
// Data // Data
Data []RecordZone `json:"data"` Data []ItemZone `json:"data"`
} }
// Detailed information about the zone record // Detailed information about the zone record
@@ -63,4 +63,76 @@ type RecordZone struct {
// List of associated VINS IDs // List of associated VINS IDs
VinsIDs []uint64 `json:"vinsIds"` VinsIDs []uint64 `json:"vinsIds"`
// DRS
DRS bool `json:"drs"`
// DRS UID
DRSUID string `json:"drs_uid"`
// App ID
AppID string `json:"app_id"`
// Decort URL
DecortURL string `json:"decort_url"`
// DRS Name
DRSName string `json:"drs_name"`
// SSO URL
SSOURL string `json:"sso_url"`
}
// A zone item from a list
type ItemZone struct {
// App ID
AppID string `json:"app_id"`
// If true, all nodes belonging to the given zone will be marked for autostart
AutoStart bool `json:"autostart"`
// Created timestamp
CreatedTime uint64 `json:"createdTime"`
// Decort URL
DecortURL string `json:"decort_url"`
// Deletable flag
Deletable bool `json:"deletable"`
// Description
Description string `json:"description"`
// DRS
DRS bool `json:"drs"`
// DRS Name
DRSName string `json:"drs_name"`
// DRS UID
DRSUID string `json:"drs_uid"`
// GID
GID uint64 `json:"gid"`
// GUID
GUID uint64 `json:"guid"`
// ID
ID uint64 `json:"id"`
// Name
Name string `json:"name"`
// List of associated Node IDs
NodeIDs []uint64 `json:"nodeIds"`
// SSO URL
SSOURL string `json:"sso_url"`
// Status
Status string `json:"status"`
// Updated timestamp
UpdatedTime uint64 `json:"updatedTime"`
} }

View File

@@ -26,17 +26,17 @@ func NewMigrator(cfg *Config, c decortsdk.ClientInterface) Migrator {
} }
} }
func (m *migrator) Migrate(ctxOrigin context.Context, dxVMID, stackID uint64) (bool, error) { func (m *migrator) Migrate(ctxOrigin context.Context, dxVMID, nodeID uint64) (bool, error) {
req := compute.MigrateRequest{ req := compute.MigrateRequest{
ComputeID: dxVMID, ComputeID: dxVMID,
TargetStackID: stackID, TargetNodeID: nodeID,
Force: false, Force: false,
} }
ctx, cancel := context.WithTimeout(ctxOrigin, m.cfg.QueryTimeout) ctx, cancel := context.WithTimeout(ctxOrigin, m.cfg.QueryTimeout)
ok, err := m.client.CloudBroker().Compute().Migrate(ctx, req) ok, err := m.client.CloudBroker().Compute().Migrate(ctx, req)
cancel() cancel()
if err != nil { if err != nil {
return false, errors.Join(err, fmt.Errorf("Migrate VM %d to Node %d", dxVMID, stackID)) return false, errors.Join(err, fmt.Errorf("Migrate VM %d to Node %d", dxVMID, nodeID))
} }
return ok, nil return ok, nil
} }

View File

@@ -60,17 +60,17 @@ func TestMigrator(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
dxVMID := uint64(100500) dxVMID := uint64(100500)
stackID := uint64(100501) nodeID := uint64(100501)
// Записываем поведение клиента // Записываем поведение клиента
mockCaller.EXPECT().DecortApiCall(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Eq(compute.AsyncWrapperMigrateRequest{ mockCaller.EXPECT().DecortApiCall(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Eq(compute.AsyncWrapperMigrateRequest{
MigrateRequest: compute.MigrateRequest{ MigrateRequest: compute.MigrateRequest{
ComputeID: dxVMID, ComputeID: dxVMID,
TargetStackID: stackID, TargetNodeID: nodeID,
}, },
SyncMode: true})).Return(b, nil).AnyTimes() SyncMode: true})).Return(b, nil).AnyTimes()
ok, err := migrator.Migrate(context.Background(), dxVMID, stackID) ok, err := migrator.Migrate(context.Background(), dxVMID, nodeID)
assert.NoError(t, err) assert.NoError(t, err)
assert.True(t, ok) assert.True(t, ok)
} }

View File

@@ -57,6 +57,7 @@ import (
node_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node" node_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node"
pcidevice_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/pcidevice" pcidevice_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/pcidevice"
prometheus_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/prometheus" prometheus_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/prometheus"
resource_optimizer_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/resource_optimizer"
rg_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg" rg_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
secgroup_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/secgroup" secgroup_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/secgroup"
sep_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep" sep_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
@@ -748,7 +749,6 @@ func getRequestsMapCloudbroker() map[string]interface{} {
"/restmachine/cloudbroker/flipgroup/list": flipgroup_cb.ListRequest{}, "/restmachine/cloudbroker/flipgroup/list": flipgroup_cb.ListRequest{},
// grid // grid
"/restmachine/cloudbroker/grid/add": grid_cb.AddRequest{},
"/restmachine/cloudbroker/grid/addCustomBackupPath": grid_cb.AddCustomBackupPathRequest{}, "/restmachine/cloudbroker/grid/addCustomBackupPath": grid_cb.AddCustomBackupPathRequest{},
"/restmachine/cloudbroker/grid/changeSettings": grid_cb.ChangeSettingsRequest{}, "/restmachine/cloudbroker/grid/changeSettings": grid_cb.ChangeSettingsRequest{},
"/restmachine/cloudbroker/grid/executeMaintenanceScript": grid_cb.ExecuteMaintenanceScriptRequest{}, "/restmachine/cloudbroker/grid/executeMaintenanceScript": grid_cb.ExecuteMaintenanceScriptRequest{},
@@ -795,6 +795,10 @@ func getRequestsMapCloudbroker() map[string]interface{} {
"/restmachine/cloudbroker/image/rename": image_cb.RenameRequest{}, "/restmachine/cloudbroker/image/rename": image_cb.RenameRequest{},
"/restmachine/cloudbroker/image/revokeAccess": image_cb.RevokeAccessRequest{}, "/restmachine/cloudbroker/image/revokeAccess": image_cb.RevokeAccessRequest{},
"/restmachine/cloudbroker/image/share": image_cb.ShareRequest{}, "/restmachine/cloudbroker/image/share": image_cb.ShareRequest{},
"/restmachine/cloudbroker/image/create_multi_image": image_cb.CreateMultiImageRequest{},
"/restmachine/cloudbroker/image/multi_image_add_links": image_cb.MultiImageAddLinksRequest{},
"/restmachine/cloudbroker/image/multi_image_del_links": image_cb.MultiImageDelLinksRequest{},
"/restmachine/cloudbroker/image/multi_image_export": image_cb.MultiImageExportRequest{},
// k8ci // k8ci
"/restmachine/cloudbroker/k8ci/accessAdd": k8ci_cb.AccessAddRequest{}, "/restmachine/cloudbroker/k8ci/accessAdd": k8ci_cb.AccessAddRequest{},
@@ -919,6 +923,15 @@ func getRequestsMapCloudbroker() map[string]interface{} {
"/restmachine/cloudbroker/prometheus/computeMemoryUsage": prometheus_cb.ComputeMemoryUsageRequest{}, "/restmachine/cloudbroker/prometheus/computeMemoryUsage": prometheus_cb.ComputeMemoryUsageRequest{},
"/restmachine/cloudbroker/prometheus/computeMemoryUnused": prometheus_cb.ComputeMemoryUnusedRequest{}, "/restmachine/cloudbroker/prometheus/computeMemoryUnused": prometheus_cb.ComputeMemoryUnusedRequest{},
// resource_optimizer
"/restmachine/cloudbroker/resource_optimizer/drs_add_nodes": resource_optimizer_cb.DRSAddNodesRequest{},
"/restmachine/cloudbroker/resource_optimizer/drs_create": resource_optimizer_cb.DRSCreateRequest{},
"/restmachine/cloudbroker/resource_optimizer/drs_del_nodes": resource_optimizer_cb.DRSDelNodesRequest{},
"/restmachine/cloudbroker/resource_optimizer/drs_remove": resource_optimizer_cb.DRSRemoveRequest{},
"/restmachine/cloudbroker/resource_optimizer/drs_start": resource_optimizer_cb.DRSStartRequest{},
"/restmachine/cloudbroker/resource_optimizer/drs_stop": resource_optimizer_cb.DRSStopRequest{},
"/restmachine/cloudbroker/resource_optimizer/drs_update": resource_optimizer_cb.DRSUpdateRequest{},
// rg // rg
"/restmachine/cloudbroker/rg/accessGrant": rg_cb.AccessGrantRequest{}, "/restmachine/cloudbroker/rg/accessGrant": rg_cb.AccessGrantRequest{},
"/restmachine/cloudbroker/rg/accessRevoke": rg_cb.AccessRevokeRequest{}, "/restmachine/cloudbroker/rg/accessRevoke": rg_cb.AccessRevokeRequest{},