Compare commits

..

2 Commits

Author SHA1 Message Date
dayterr
5cdae8520f v1.14.7 2026-04-10 16:38:00 +03:00
30e464e4d2 v1.14.6 2026-04-03 16:26:42 +03:00
36 changed files with 664 additions and 117 deletions

View File

@@ -1,4 +1,4 @@
## Version 1.14.5 ## Version 1.14.7
Методы `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,41 +9,12 @@
### Добавлено ### Добавлено
#### compute #### SDN Hypervisors
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-360 | Валидация поля `Label` в структуре запроса `SnapshotCreateRequest` в cloudapi/compute и cloudbroker/compute | | BGOS-518 | Группа методов Hypervisors |
#### image #### SDN Version
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-820 | Обязательное поле `SEPID` в структуру запроса `MultiImageExportRequest` в cloudbroker/image | | BGOS-838 | Группа методов Version |
#### locations
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BGOS-823 | Вычисляемое поле `ZeroAccessEnabled` в структуру ответа `ItemLocation` в cloudapi/locations |
#### resource_optimizer
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BGOS-818 | Группа методов `cloudbroker/resource_optimizer` для управления инструментом оптимизации ресурсов (DRS) |
### zone
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BGOS-819 | Вычисляемые поля `DRS`, `DRSUID`, `AppID`, `DecortURL`, `DRSName` и `SSOURL` в структуру ответа `RecordZone` в cloudapi/zone и в cloudbroker/zone |
| BGOS-819 | Структура ответа `ItemZone` в cloudapi/zone и в cloudbroker/zone |
| BGOS-819 | Опциональное поле `DRS` в структуру запроса `CreateRequest` в cloudbroker/zone |
### Изменено
#### image
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BGOS-822 | Тип полей `HotResize` и `Bootable` в структуре запроса `EditRequest` с bool на interface в cloudbroker/image |
#### node
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BGOS-821 | Тип вычисляемого поля `VCPU` с `uint64` на `float64` в структуре ответа `FreeResourcesInfo` в cloudbroker/node |

View File

@@ -182,12 +182,14 @@ go get -u repository.basistech.ru/BASIS/decort-golang-sdk
- `Address pool` - управление пулами адресов; - `Address pool` - управление пулами адресов;
- `DefaultSecurityPolicies` - управление политиками хранения по умолчанию; - `DefaultSecurityPolicies` - управление политиками хранения по умолчанию;
- `ExtNet` - управление виртуальными сетями, отвечающими за внешний доступ; - `ExtNet` - управление виртуальными сетями, отвечающими за внешний доступ;
- `Hypervisors` - управление гипервизорами;
- `FloatingIPs` - управление плавающими IP-адресами; - `FloatingIPs` - управление плавающими IP-адресами;
- `Logical ports` - управление логическими портами; - `Logical ports` - управление логическими портами;
- `NetworkObjectGroups` - управление группами объектов сети; - `NetworkObjectGroups` - управление группами объектов сети;
- `Routers` - управление роутерами; - `Routers` - управление роутерами;
- `SecurityPolicies` - управление политиками хранения; - `SecurityPolicies` - управление политиками хранения;
- `Segments` - управление сегментами; - `Segments` - управление сегментами;
- `Version` - получение информации о версии SDN;
## Работа с библиотекой ## Работа с библиотекой
@@ -383,12 +385,14 @@ func main() {
- `pkg/sdn/adrspools` - для `Address pool` - `pkg/sdn/adrspools` - для `Address pool`
- `pkg/sdn/defsecpolicies` - для `DefaultSecurityPolicies` - `pkg/sdn/defsecpolicies` - для `DefaultSecurityPolicies`
- `pkg/sdn/external_networks` - для `ExtNet` - `pkg/sdn/external_networks` - для `ExtNet`
- `pkg/sdn/hypervisors` - для `Hypervisors`
- `pkg/sdn/flips` - для `FloatingIPs` - `pkg/sdn/flips` - для `FloatingIPs`
- `pkg/sdn/logicalports` - для `Logical ports` - `pkg/sdn/logicalports` - для `Logical ports`
- `pkg/sdn/netobjgroups` - для `NetworkObjectGroups` - `pkg/sdn/netobjgroups` - для `NetworkObjectGroups`
- `pkg/sdn/routers` - для `Routers` - `pkg/sdn/routers` - для `Routers`
- `pkg/sdn/secpolicies` - для `SecurityPolicies` - `pkg/sdn/secpolicies` - для `SecurityPolicies`
- `pkg/sdn/segments` - для `Segments` - `pkg/sdn/segments` - для `Segments`
- `pkg/sdn/version` - для `Version`
Все поля структуры имеют описание, в которых содержится: Все поля структуры имеют описание, в которых содержится:
@@ -584,12 +588,14 @@ func main() {
- `.AddressPool()` - для работы с `Addres pool` - `.AddressPool()` - для работы с `Addres pool`
- `.DefaultSecurityPolicies()` - для работы с `DefaultSecurityPolicies` - `.DefaultSecurityPolicies()` - для работы с `DefaultSecurityPolicies`
- `.ExtNet()` - для работы с `ExtNet` - `.ExtNet()` - для работы с `ExtNet`
- `.Hypervisors()` - для работы с `Hypervisors`
- `.FloatingIPs()` - для работы с `FloatingIPs` - `.FloatingIPs()` - для работы с `FloatingIPs`
- `.LogicalPorts()` - для работы с `Logical ports` - `.LogicalPorts()` - для работы с `Logical ports`
- `.NetworkObjectGroups()` - для работы с `NetworkObjectGroups` - `.NetworkObjectGroups()` - для работы с `NetworkObjectGroups`
- `.Routers()` - для работы с `Routers` - `.Routers()` - для работы с `Routers`
- `.SecurityPolicies()` - для работы с `SecurityPolicies` - `.SecurityPolicies()` - для работы с `SecurityPolicies`
- `.Segments()` - для работы с `Segments` - `.Segments()` - для работы с `Segments`
- `.Version()` - для работы с `Version`
3. Вызвать метод, отвечающий за выполнение запроса и передать в него: 3. Вызвать метод, отвечающий за выполнение запроса и передать в него:

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

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

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

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

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

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

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

10
pkg/sdn/hypervisors.go Normal file
View File

@@ -0,0 +1,10 @@
package sdn
import (
hv "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/hypervisors"
)
// Accessing the SDN method group
func (sdn *SDN) Hypervisors() *hv.Hypervisors {
return hv.New(sdn.client)
}

View File

@@ -0,0 +1,30 @@
package hypervisors
import (
"context"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// ConnectNodeRequest to connect a node
type ConnectNodeRequest struct {
// Node to connect
// Required: true
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
}
func (hv Hypervisors) ConnectNode(ctx context.Context, req ConnectNodeRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/sdn/hypervisor/connect_node"
result, err := hv.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return "", err
}
return string(result), nil
}

View File

@@ -0,0 +1,43 @@
package hypervisors
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DeleteRequest to delete a hypervisor
type DeleteRequest struct {
// Name of a hypervisor
// Required: true
Name string `url:"name" json:"name" validate:"required"`
}
// Delete a hypervisor
func (hv Hypervisors) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/sdn/hypervisor/delete"
res, err := hv.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
if err != nil {
return false, err
}
if string(res) == "" {
return true, nil
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -0,0 +1,50 @@
package hypervisors
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// GetRequest struct to get information about hypervisor
type GetRequest struct {
// Name
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// Port info (available options: detailed, general)
// Required: false
PortInfo string `url:"port_info,omitempty" json:"port_info,omitempty"`
}
// Get gets current configuration of a hypervisor as a RecordHypervisor
func (hv Hypervisors) Get(ctx context.Context, req GetRequest) (*RecordHypervisor, error) {
res, err := hv.GetRaw(ctx, req)
if err != nil {
return nil, err
}
info := RecordHypervisor{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
// GetRaw gets information about a hypervisor as an array of bytes
func (hv Hypervisors) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/sdn/hypervisor/get"
res, err := hv.client.DecortApiCall(ctx, http.MethodGet, url, req)
return res, err
}

View File

@@ -0,0 +1,17 @@
package hypervisors
import (
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
)
// Structure for creating request to hypervisors
type Hypervisors struct {
client interfaces.Caller
}
// Builder for hypervisors endpoints
func New(client interfaces.Caller) *Hypervisors {
return &Hypervisors{
client,
}
}

View File

@@ -0,0 +1,90 @@
package hypervisors
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// ListRequest struct to get a list of hypervisors
type ListRequest struct {
// Page
// Required: false
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
// Per page
// Required: false
PerPage uint64 `url:"per_page,omitempty" json:"per_page,omitempty"`
// Sort by (available options: name, hostname, last_sync, display_name, ip, created_at, updated_at)
// Required: false
SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"`
// Sort order (available options: asc, desc)
// Required: false
SortOrder string `url:"sort_order,omitempty" json:"sort_order,omitempty"`
// Port info (available options: detailed, general)
// Required: false
PortInfo string `url:"port_info,omitempty" json:"port_info,omitempty"`
// Hostname
// Required: false
Hostname string `url:"hostname,omitempty" json:"hostname,omitempty"`
// Display name
// Required: false
DisplayName string `url:"display_name,omitempty" json:"display_name,omitempty"`
// IP
// Required: false
IP string `url:"ip,omitempty" json:"ip,omitempty"`
// Created from
// Required: false
CreatedFrom string `url:"created_from,omitempty" json:"created_from,omitempty"`
// Created to
// Required: false
CreatedTo string `url:"created_to,omitempty" json:"created_to,omitempty"`
// Updated from
// Required: false
UpdatedFrom string `url:"updated_from,omitempty" json:"updated_from,omitempty"`
// Updated to
// Required: false
UpdatedTo string `url:"updated_to,omitempty" json:"updated_to,omitempty"`
}
// List of hypervisors
func (hv Hypervisors) List(ctx context.Context, req ListRequest) (HypervisorsList, error) {
res, err := hv.ListRaw(ctx, req)
if err != nil {
return nil, err
}
hvs := HypervisorsList{}
err = json.Unmarshal(res, &hvs)
if err != nil {
return nil, err
}
return hvs, nil
}
// ListRaw gets a list of all hypervisors as an array of bytes
func (hv Hypervisors) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
if err := validators.ValidateRequest(req); err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/sdn/hypervisor/list"
res, err := hv.client.DecortApiCall(ctx, http.MethodGet, url, req)
return res, err
}

View File

@@ -0,0 +1,31 @@
package hypervisors
// Main information about hypervisor
type RecordHypervisor struct {
// Created at
CreatedAt string `json:"created_at"`
// Display name
DisplayName string `json:"display_name"`
// Hostname
Hostname string `json:"hostname"`
// IP
IP string `json:"ip"`
// Synced at
SyncedAt string `json:"synced_at"`
// Name
Name string `json:"name"`
// Ports
Ports []string `json:"ports"`
// Status
Status string `json:"status"`
}
// List of hypervisors
type HypervisorsList []RecordHypervisor

View File

@@ -0,0 +1,50 @@
package hypervisors
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// UpdateDisplayNameRequest struct to update display name for a hypervisor
type UpdateDisplayNameRequest struct {
// Current name of the hypervisor
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// New display name to set
// Required: true
DisplayName string `url:"display_name" json:"display_name" validate:"required"`
}
// UpdateDisplayName updates display name for a hypervisor
func (hv Hypervisors) UpdateDisplayName(ctx context.Context, req UpdateDisplayNameRequest) (*RecordHypervisor, error) {
res, err := hv.UpdateDisplayNameRaw(ctx, req)
if err != nil {
return nil, err
}
info := RecordHypervisor{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
// UpdateDisplayNameRaw update display name for a hypervisor and get its information as an array of bytes
func (hv Hypervisors) UpdateDisplayNameRaw(ctx context.Context, req UpdateDisplayNameRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/sdn/hypervisor/update_display_name"
res, err := hv.client.DecortApiCall(ctx, http.MethodPut, url, req)
return res, err
}

10
pkg/sdn/version.go Normal file
View File

@@ -0,0 +1,10 @@
package sdn
import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/version"
)
// Accessing the SDN method group
func (sdn *SDN) Version() *version.Version {
return version.New(sdn.client)
}

33
pkg/sdn/version/get.go Normal file
View File

@@ -0,0 +1,33 @@
package version
import (
"context"
"encoding/json"
"net/http"
)
// Get gets SDN version info as a RecordVersion struct
func (v Version) Get(ctx context.Context) (*RecordVersion, error) {
res, err := v.GetRaw(ctx)
if err != nil {
return nil, err
}
info := RecordVersion{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
// GetRaw gets SDN version info as an array of bytes
func (v Version) GetRaw(ctx context.Context) ([]byte, error) {
url := "/sdn/version/get"
res, err := v.client.DecortApiCall(ctx, http.MethodGet, url, nil)
return res, err
}

25
pkg/sdn/version/models.go Normal file
View File

@@ -0,0 +1,25 @@
package version
// Version info of the SDN platform
type RecordVersion struct {
// Core component version info
Core ComponentVersion `json:"core"`
// Director component version info
Director ComponentVersion `json:"director"`
}
// Version info of a single component
type ComponentVersion struct {
// Branch name
Branch string `json:"branch"`
// Build time
BuildTime string `json:"build_time"`
// Commit hash
Commit string `json:"commit"`
// Version string
Version string `json:"version"`
}

View File

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

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

@@ -27,6 +27,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/acsgroups" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/acsgroups"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/adrspools" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/adrspools"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/defsecpolicies" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/defsecpolicies"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/hypervisors"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/routers" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/routers"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/secpolicies" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/secpolicies"
@@ -59,6 +60,7 @@ import (
extnet_sdn "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/extnet" extnet_sdn "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/extnet"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/flips" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/flips"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/netobjgroups" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/netobjgroups"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/version"
) )
// TestGetListCloudAPI tests platforms responses vs. json tags of golang structures in cloudapi get/list methods // TestGetListCloudAPI tests platforms responses vs. json tags of golang structures in cloudapi get/list methods
@@ -1025,6 +1027,26 @@ func TestGetListSDNAPI(t *testing.T) {
t.Errorf("Can not test segments get because list is empty") t.Errorf("Can not test segments get because list is empty")
} }
// Hypervisors
// List
bytes, err = client.SDN().Hypervisors().ListRaw(context.Background(), hypervisors.ListRequest{})
if err != nil {
t.Error(err)
}
getResult("Hypervisors list", bytes, hypervisors.HypervisorsList{}, t)
// Get
listHypervisors, _ := client.SDN().Hypervisors().List(context.Background(), hypervisors.ListRequest{})
if len(listHypervisors) > 0 {
id := listHypervisors[0].Name
bytes, err = client.SDN().Hypervisors().GetRaw(context.Background(), hypervisors.GetRequest{Name: id})
if err != nil {
t.Error(err)
}
getResult("Hypervisors get", bytes, hypervisors.RecordHypervisor{}, t)
} else {
t.Errorf("Can not test Hypervisors get because listHypervisors list is empty")
}
// FloatingIPs // FloatingIPs
// List // List
bytes, err = client.SDN().FloatingIPs().ListRaw(context.Background(), flips.ListRequest{}) bytes, err = client.SDN().FloatingIPs().ListRaw(context.Background(), flips.ListRequest{})
@@ -1084,6 +1106,13 @@ func TestGetListSDNAPI(t *testing.T) {
} else { } else {
t.Errorf("Can not test routers get because routerList list is empty") t.Errorf("Can not test routers get because routerList list is empty")
} }
// Version
bytes, err = client.SDN().Version().GetRaw(context.Background())
if err != nil {
t.Error(err)
}
getResult("Version get", bytes, version.RecordVersion{}, t)
} }
// TestRequestsCloudAPI tests platform requests vs. golang request structures in sdk for cloudapi requests // TestRequestsCloudAPI tests platform requests vs. golang request structures in sdk for cloudapi requests

View File

@@ -72,6 +72,7 @@ import (
extnet_sdn "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/extnet" extnet_sdn "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/extnet"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/flips" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/flips"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/hypervisors"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/netobjgroups" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/netobjgroups"
) )
@@ -749,7 +750,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{},
@@ -1168,6 +1168,13 @@ func getRequestsMapSDN() map[string]interface{} {
"/restmachine/sdn/floating_ip/list": flips.ListRequest{}, "/restmachine/sdn/floating_ip/list": flips.ListRequest{},
"/restmachine/sdn/floating_ip/update": flips.UpdateRequest{}, "/restmachine/sdn/floating_ip/update": flips.UpdateRequest{},
// hypervisors
"/restmachine/sdn/hypervisor/connect_node": hypervisors.ConnectNodeRequest{},
"/restmachine/sdn/hypervisor/delete": hypervisors.DeleteRequest{},
"/restmachine/sdn/hypervisor/get": hypervisors.GetRequest{},
"/restmachine/sdn/hypervisor/list": hypervisors.ListRequest{},
"/restmachine/sdn/hypervisor/update_display_name": hypervisors.UpdateDisplayNameRequest{},
// network object groups // network object groups
"/restmachine/sdn/network_object_group/attach_external_network_ports": netobjgroups.AttachExtNetPortsRequest{}, "/restmachine/sdn/network_object_group/attach_external_network_ports": netobjgroups.AttachExtNetPortsRequest{},
"/restmachine/sdn/network_object_group/attach_logical_ports": netobjgroups.AttachLogicalPortsRequest{}, "/restmachine/sdn/network_object_group/attach_logical_ports": netobjgroups.AttachLogicalPortsRequest{},
@@ -1211,5 +1218,8 @@ func getRequestsMapSDN() map[string]interface{} {
"/restmachine/sdn/router/list": routers.ListRequest{}, "/restmachine/sdn/router/list": routers.ListRequest{},
"/restmachine/sdn/router/policies/list": policies.ListRequest{}, "/restmachine/sdn/router/policies/list": policies.ListRequest{},
"/restmachine/sdn/router/update": routers.UpdateRequest{}, "/restmachine/sdn/router/update": routers.UpdateRequest{},
// version
"/restmachine/sdn/version/get": nil,
} }
} }