Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9258a1574b | |||
|
|
444a33dc7e | ||
| 17017b6d5d | |||
|
|
c701001bb6 | ||
|
|
c2c810504d | ||
|
|
b834e5d074 | ||
| e1f0d354af | |||
|
|
d149ba19fd |
67
CHANGELOG.md
67
CHANGELOG.md
@@ -1,7 +1,6 @@
|
|||||||
## Version 1.13.6
|
## Version 1.14.5
|
||||||
|
|
||||||
Методы `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 с соответствующими фильтрами
|
||||||
Метод `ListNodes` в cloudbroker/image стал deprecated и в следующих версиях будет удалён
|
|
||||||
Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и в следующих версиях будут удалены
|
Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и в следующих версиях будут удалены
|
||||||
Методы `ComputeCISet`, `ComputeCIUnset`, `GetAudits` в cloudbroker/compute и `GetAudits` в cloudapi/compute стали deprecated и будут удалены в следующих версиях
|
Методы `ComputeCISet`, `ComputeCIUnset`, `GetAudits` в cloudbroker/compute и `GetAudits` в cloudapi/compute стали deprecated и будут удалены в следующих версиях
|
||||||
Методы `ComputeCISet`, `ComputeCIUnset` в cloudbroker/image стали deprecated и будут удалены в следующих версиях
|
Методы `ComputeCISet`, `ComputeCIUnset` в cloudbroker/image стали deprecated и будут удалены в следующих версиях
|
||||||
@@ -13,46 +12,38 @@
|
|||||||
#### compute
|
#### compute
|
||||||
| Идентификатор<br>задачи | Описание |
|
| Идентификатор<br>задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BGOS-751 | Опциональные поля `SDNSegmentID`, `SDNObjectGroupID`, `SDNLogicalPortDisplayName`, `SDNLogicalPortDescription` в структуры запроса в `Interface` в cloudapi/compute и в `Interface`, `InterfaceMassCreate` в cloudbroker/compute |
|
| BGOS-360 | Валидация поля `Label` в структуре запроса `SnapshotCreateRequest` в cloudapi/compute и cloudbroker/compute |
|
||||||
| BGOS-752 | Опциональные поля `SDNSegmentID`, `SDNObjectGroupID`, `SDNLogicalPortDisplayName`, `SDNLogicalPortDescription` в структуру запроса `NetAttachRequest` в cloudapi/compute и в cloudbroker/compute |
|
|
||||||
|
|
||||||
#### disks
|
#### image
|
||||||
| Идентификатор<br>задачи | Описание |
|
| Идентификатор<br>задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BGOS-735 | Вычисляемое поле `Cache` в структуры ответа `ItemDiskUnattached` в cloudapi/disks и в cloudbroker/disks |
|
| BGOS-820 | Обязательное поле `SEPID` в структуру запроса `MultiImageExportRequest` в cloudbroker/image |
|
||||||
|
|
||||||
|
#### 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
|
#### node
|
||||||
| Идентификатор<br>задачи | Описание |
|
| Идентификатор<br>задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BGOS-738 | Структура запроса `AutoStartRequest`, метод `AutoStart` в cloudbroker/node |
|
| BGOS-821 | Тип вычисляемого поля `VCPU` с `uint64` на `float64` в структуре ответа `FreeResourcesInfo` в cloudbroker/node |
|
||||||
| BGOS-738 | Опциональное поле `AutoStart` в структуру запроса `MaintenanceRequest` в cloudbroker/node |
|
|
||||||
| BGOS-738 | Вычисляемые поля `AutoStart`, `AutoStartCount` в структуры ответов `ItemNode` и `RecordNode` в cloudbroker/node |
|
|
||||||
| BGOS-746 | Вычисляемое поле `MemAllocationRatio` в структуру ответа `RecordNode` в cloudbroker/node |
|
|
||||||
|
|
||||||
#### zone
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-737 | Опциональное поле `AutoStart` в структуру запроса `UpdateRequest` в cloudbroker/zone |
|
|
||||||
| BGOS-737 | Вычисляемое поле `AutoStart` в структуры ответа `RecordZone` в cloudapi/zone и в cloudbroker/zone |
|
|
||||||
| BGOS-748 | Опциональное поле `AutoStart` в структуру запроса `CreateRequest` в cloudbroker/zone |
|
|
||||||
| BGOS-743 | Структура запроса `NodeAutoStartRequest`, метод `NodeAutoStart` в cloudbroker/zone |
|
|
||||||
|
|
||||||
### Изменено
|
|
||||||
|
|
||||||
#### sep
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-740 | Тип поля `Force` с обязательного на опциональный в структуре запроса `DelConsumerNodesRequest` в cloudbroker/sep |
|
|
||||||
|
|
||||||
### Удалено
|
|
||||||
|
|
||||||
#### bservice
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-739 | Обязательное поле `Driver` в структурах запроса `GroupAddRequest` в cloudapi/bservice и в cloudbroker/bservice |
|
|
||||||
|
|
||||||
#### flipgroup
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-742 | Опциональное поле `RGID` из структуры запроса `ListRequest` в cloudapi/flipgroup и в cloudbroker/flipgroup |
|
|
||||||
| BGOS-742 | Вычисляемые поля `RGName` и `RGID` из структуры ответа `RecordFLIPGroup` в cloudapi/flipgroup и в cloudbroker/flipgroup |
|
|
||||||
14
README.md
14
README.md
@@ -18,6 +18,7 @@ Decort SDK - это библиотека, написанная на языке G
|
|||||||
- Версия 1.11.х Decort-SDK соответствует 4.3.0 версии платформы
|
- Версия 1.11.х Decort-SDK соответствует 4.3.0 версии платформы
|
||||||
- Версия 1.12.х Decort-SDK соответствует 4.4.0 версии платформы
|
- Версия 1.12.х Decort-SDK соответствует 4.4.0 версии платформы
|
||||||
- Версия 1.13.х Decort-SDK соответствует 4.5.0 версии платформы
|
- Версия 1.13.х Decort-SDK соответствует 4.5.0 версии платформы
|
||||||
|
- Версия 1.14.х Decort-SDK соответствует 4.6.0 версии платформы
|
||||||
|
|
||||||
## Оглавление
|
## Оглавление
|
||||||
|
|
||||||
@@ -159,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);
|
||||||
@@ -364,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`
|
||||||
@@ -466,16 +469,6 @@ type CreateRequest struct {
|
|||||||
// Node ID
|
// Node ID
|
||||||
// Required: false
|
// Required: false
|
||||||
NodeID uint64 `url:"nodeId,omitempty" json:"nodeId,omitempty"`
|
NodeID uint64 `url:"nodeId,omitempty" json:"nodeId,omitempty"`
|
||||||
|
|
||||||
// System name
|
|
||||||
// Required: false
|
|
||||||
IS string `url:"IS,omitempty" json:"IS,omitempty"`
|
|
||||||
|
|
||||||
// Compute purpose
|
|
||||||
// Required: false
|
|
||||||
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -572,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`
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ var FileName = map[string]string{
|
|||||||
var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"}
|
var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"}
|
||||||
|
|
||||||
var VersionMap = map[string]string{
|
var VersionMap = map[string]string{
|
||||||
|
"4.6.0": "-",
|
||||||
"4.5.0": "-",
|
"4.5.0": "-",
|
||||||
"4.4.0": "-",
|
"4.4.0": "-",
|
||||||
"4.3.0": "-",
|
"4.3.0": "-",
|
||||||
|
|||||||
@@ -86,13 +86,6 @@ func computeModeValidator(fe validator.FieldLevel) bool {
|
|||||||
return IsInSlice(fieldValue, computeModeValues)
|
return IsInSlice(fieldValue, computeModeValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
// computeDiskTypeValidator is used to validate DiskType field.
|
|
||||||
func computeDiskTypeValidator(fe validator.FieldLevel) bool {
|
|
||||||
fieldValue := fe.Field().String()
|
|
||||||
|
|
||||||
return IsInSlice(fieldValue, computeDiskTypeValues)
|
|
||||||
}
|
|
||||||
|
|
||||||
// computeNetTypeValidator is used to validate NetType field.
|
// computeNetTypeValidator is used to validate NetType field.
|
||||||
func computeNetTypeValidator(fe validator.FieldLevel) bool {
|
func computeNetTypeValidator(fe validator.FieldLevel) bool {
|
||||||
fieldValue := fe.Field().String()
|
fieldValue := fe.Field().String()
|
||||||
@@ -151,13 +144,6 @@ func computeDataDisksValidator(fe validator.FieldLevel) bool {
|
|||||||
return IsInSlice(fieldValue, computeDataDisksValues)
|
return IsInSlice(fieldValue, computeDataDisksValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
// diskTypeValidator is used to validate Type field.
|
|
||||||
func diskTypeValidator(fe validator.FieldLevel) bool {
|
|
||||||
fieldValue := fe.Field().String()
|
|
||||||
|
|
||||||
return IsInSlice(fieldValue, diskTypeValues)
|
|
||||||
}
|
|
||||||
|
|
||||||
// flipgroupClientTypeValidator is used to validate ClientType field.
|
// flipgroupClientTypeValidator is used to validate ClientType field.
|
||||||
func flipgroupClientTypeValidator(fe validator.FieldLevel) bool {
|
func flipgroupClientTypeValidator(fe validator.FieldLevel) bool {
|
||||||
fieldValue := fe.Field().String()
|
fieldValue := fe.Field().String()
|
||||||
|
|||||||
@@ -86,12 +86,6 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
fe.Field(),
|
fe.Field(),
|
||||||
joinValues(computeModeValues))
|
joinValues(computeModeValues))
|
||||||
|
|
||||||
case "computeDiskType":
|
|
||||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
|
||||||
prefix,
|
|
||||||
fe.Field(),
|
|
||||||
joinValues(computeDiskTypeValues))
|
|
||||||
|
|
||||||
case "mtu":
|
case "mtu":
|
||||||
return fmt.Sprint(prefix, fe.Field(), "must be ", mtuMin, "-", mtuMax)
|
return fmt.Sprint(prefix, fe.Field(), "must be ", mtuMin, "-", mtuMax)
|
||||||
|
|
||||||
@@ -122,13 +116,6 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
fe.Field(),
|
fe.Field(),
|
||||||
joinValues(computeDataDisksValues))
|
joinValues(computeDataDisksValues))
|
||||||
|
|
||||||
// Disk Validators
|
|
||||||
case "diskType":
|
|
||||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
|
||||||
prefix,
|
|
||||||
fe.Field(),
|
|
||||||
joinValues(diskTypeValues))
|
|
||||||
|
|
||||||
// Flipgroup Validators
|
// Flipgroup Validators
|
||||||
case "flipgroupClientType":
|
case "flipgroupClientType":
|
||||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
|||||||
@@ -86,11 +86,6 @@ func registerAllValidators(validate *validator.Validate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = validate.RegisterValidation("computeDiskType", computeDiskTypeValidator)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = validate.RegisterValidation("computeNetType", computeNetTypeValidator)
|
err = validate.RegisterValidation("computeNetType", computeNetTypeValidator)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -111,11 +106,6 @@ func registerAllValidators(validate *validator.Validate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = validate.RegisterValidation("diskType", diskTypeValidator)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = validate.RegisterValidation("flipgroupClientType", flipgroupClientTypeValidator)
|
err = validate.RegisterValidation("flipgroupClientType", flipgroupClientTypeValidator)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -14,14 +14,11 @@ var (
|
|||||||
computeTopologyValues = []string{"compute", "node"}
|
computeTopologyValues = []string{"compute", "node"}
|
||||||
computePolicyValues = []string{"RECOMMENDED", "REQUIRED"}
|
computePolicyValues = []string{"RECOMMENDED", "REQUIRED"}
|
||||||
computeModeValues = []string{"EQ", "EN", "ANY"}
|
computeModeValues = []string{"EQ", "EN", "ANY"}
|
||||||
computeDiskTypeValues = []string{"D", "B"}
|
|
||||||
computeNetTypeValues = []string{"EXTNET", "VINS"}
|
computeNetTypeValues = []string{"EXTNET", "VINS"}
|
||||||
computex86NetTypeValues = []string{"EXTNET", "VINS", "VFNIC", "DPDK", "SDN", "EMPTY", "TRUNK"}
|
computex86NetTypeValues = []string{"EXTNET", "VINS", "VFNIC", "DPDK", "SDN", "EMPTY", "TRUNK"}
|
||||||
computeOrderValues = []string{"cdrom", "network", "hd"}
|
computeOrderValues = []string{"cdrom", "network", "hd"}
|
||||||
computeDataDisksValues = []string{"KEEP", "DETACH", "DESTROY"}
|
computeDataDisksValues = []string{"KEEP", "DETACH", "DESTROY"}
|
||||||
|
|
||||||
diskTypeValues = []string{"B", "T", "D"}
|
|
||||||
|
|
||||||
flipgroupClientTypeValues = []string{"compute", "vins"}
|
flipgroupClientTypeValues = []string{"compute", "vins"}
|
||||||
|
|
||||||
massCreateNetTypeValues = []string{"EXTNET", "VINS", "TRUNK"}
|
massCreateNetTypeValues = []string{"EXTNET", "VINS", "TRUNK"}
|
||||||
@@ -86,7 +83,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
mtuMin = 1
|
mtuMin = 1500
|
||||||
mtuMax = 9216
|
mtuMax = 9216
|
||||||
|
|
||||||
trunkTagsMin = 1
|
trunkTagsMin = 1
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ type ItemAccount struct {
|
|||||||
// Deleted time
|
// Deleted time
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
|
// Deleted by
|
||||||
|
DeletedBy string `json:"deletedBy"`
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
Description string `json:"desc"`
|
Description string `json:"desc"`
|
||||||
|
|
||||||
@@ -107,6 +110,9 @@ type ItemAccount struct {
|
|||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Updated by
|
||||||
|
UpdatedBy string `json:"updatedBy"`
|
||||||
|
|
||||||
// Updated time
|
// Updated time
|
||||||
UpdatedTime uint64 `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
@@ -299,6 +305,9 @@ type RecordAccount struct {
|
|||||||
// UniqPools
|
// UniqPools
|
||||||
UniqPools []interface{} `json:"uniqPools"`
|
UniqPools []interface{} `json:"uniqPools"`
|
||||||
|
|
||||||
|
// Updated By
|
||||||
|
UpdatedBy string `json:"updatedBy"`
|
||||||
|
|
||||||
// Updated time
|
// Updated time
|
||||||
UpdatedTime uint64 `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
@@ -20,23 +19,18 @@ type AbortSharedSnapshotMergeRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AbortSharedSnapshotMerge shared snapshots merge abort
|
// AbortSharedSnapshotMerge shared snapshots merge abort
|
||||||
func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (bool, error) {
|
func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/compute/abort_shared_snapshot_merge"
|
url := "/cloudapi/compute/abort_shared_snapshot_merge"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
return string(res), nil
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package compute
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
@@ -17,22 +17,24 @@ type CloneAbortRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CloneAbort aborts a compute clone
|
// CloneAbort aborts a compute clone
|
||||||
func (c Compute) CloneAbort(ctx context.Context, req CloneAbortRequest) (bool, error) {
|
func (c Compute) CloneAbort(ctx context.Context, req CloneAbortRequest) (ListCloneAbort, 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 := "/cloudapi/compute/clone_abort"
|
url := "/cloudapi/compute/clone_abort"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
var result ListCloneAbort
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -26,13 +26,6 @@ type DiskAddRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||||
|
|
||||||
// Type of the disk
|
|
||||||
// Should be one of:
|
|
||||||
// - D
|
|
||||||
// - B
|
|
||||||
// Required: false
|
|
||||||
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty" validate:"omitempty,computeDiskType"`
|
|
||||||
|
|
||||||
// Storage endpoint provider ID
|
// Storage endpoint provider ID
|
||||||
// By default the same with boot disk
|
// By default the same with boot disk
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -58,10 +51,6 @@ type DiskAddRequest struct {
|
|||||||
// Desired bus number (hex string, e.g. "0x03")
|
// Desired bus number (hex string, e.g. "0x03")
|
||||||
// Required: false
|
// Required: false
|
||||||
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
|
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
|
||||||
|
|
||||||
// Disk cache mode
|
|
||||||
// Required: false
|
|
||||||
Cache string `url:"cache,omitempty" json:"cache,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskAdd creates new disk and attach to compute
|
// DiskAdd creates new disk and attach to compute
|
||||||
|
|||||||
@@ -18,10 +18,6 @@ type DiskAttachRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
|
||||||
// Type of the disk B;D
|
|
||||||
// Required: false
|
|
||||||
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty" validate:"omitempty,computeDiskType"`
|
|
||||||
|
|
||||||
// Desired PCI slot (hex string, e.g. "0x1A")
|
// Desired PCI slot (hex string, e.g. "0x1A")
|
||||||
// Required: false
|
// Required: false
|
||||||
PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"`
|
PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"`
|
||||||
|
|||||||
@@ -545,6 +545,9 @@ type RecordCompute struct {
|
|||||||
// VNC password
|
// VNC password
|
||||||
VNCPassword string `json:"vncPasswd"`
|
VNCPassword string `json:"vncPasswd"`
|
||||||
|
|
||||||
|
// Weight
|
||||||
|
Weight uint64 `json:"weight"`
|
||||||
|
|
||||||
// Zone ID
|
// Zone ID
|
||||||
// Required: false
|
// Required: false
|
||||||
ZoneID uint64 `json:"zoneId"`
|
ZoneID uint64 `json:"zoneId"`
|
||||||
@@ -789,6 +792,12 @@ type ItemComputeDisk struct {
|
|||||||
// Account ID
|
// Account ID
|
||||||
AccountID uint64 `json:"accountId"`
|
AccountID uint64 `json:"accountId"`
|
||||||
|
|
||||||
|
// BLK Discard
|
||||||
|
BLKDiscard bool `json:"blkdiscard"`
|
||||||
|
|
||||||
|
// Block Size
|
||||||
|
BlockSize string `json:"block_size"`
|
||||||
|
|
||||||
// Boot partition
|
// Boot partition
|
||||||
BootPartition uint64 `json:"bootPartition"`
|
BootPartition uint64 `json:"bootPartition"`
|
||||||
|
|
||||||
@@ -834,6 +843,9 @@ type ItemComputeDisk struct {
|
|||||||
// Image ID
|
// Image ID
|
||||||
ImageID uint64 `json:"imageId"`
|
ImageID uint64 `json:"imageId"`
|
||||||
|
|
||||||
|
// Independent
|
||||||
|
Independent bool `json:"independent"`
|
||||||
|
|
||||||
// List image IDs
|
// List image IDs
|
||||||
Images []uint64 `json:"images"`
|
Images []uint64 `json:"images"`
|
||||||
|
|
||||||
@@ -870,6 +882,9 @@ type ItemComputeDisk struct {
|
|||||||
// Present to
|
// Present to
|
||||||
PresentTo map[string]uint64 `json:"presentTo"`
|
PresentTo map[string]uint64 `json:"presentTo"`
|
||||||
|
|
||||||
|
// Provision
|
||||||
|
Provision string `json:"provision"`
|
||||||
|
|
||||||
// Purge time
|
// Purge time
|
||||||
PurgeTime uint64 `json:"purgeTime"`
|
PurgeTime uint64 `json:"purgeTime"`
|
||||||
|
|
||||||
@@ -1229,6 +1244,9 @@ type ItemCompute struct {
|
|||||||
// VINS connected
|
// VINS connected
|
||||||
VINSConnected uint64 `json:"vinsConnected"`
|
VINSConnected uint64 `json:"vinsConnected"`
|
||||||
|
|
||||||
|
// Weight
|
||||||
|
Weight uint64 `json:"weight"`
|
||||||
|
|
||||||
// Zone ID
|
// Zone ID
|
||||||
ZoneID uint64 `json:"zoneId"`
|
ZoneID uint64 `json:"zoneId"`
|
||||||
}
|
}
|
||||||
@@ -1370,6 +1388,21 @@ type RecordCloneStatus struct {
|
|||||||
Status CloneStatus `json:"status"`
|
Status CloneStatus `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Information about aborted clone disk
|
||||||
|
type RecordCloneAbort struct {
|
||||||
|
// Disk ID
|
||||||
|
DiskID uint64 `json:"disk_id"`
|
||||||
|
|
||||||
|
// Aborted
|
||||||
|
Aborted bool `json:"aborted"`
|
||||||
|
|
||||||
|
// Blockcopy abort job ID
|
||||||
|
BlockcopyAbortJobID string `json:"blockcopy_abort_job_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of aborted clone disks
|
||||||
|
type ListCloneAbort []RecordCloneAbort
|
||||||
|
|
||||||
type CloneStatus struct {
|
type CloneStatus struct {
|
||||||
// Type
|
// Type
|
||||||
Type int `json:"type"`
|
Type int `json:"type"`
|
||||||
|
|||||||
@@ -39,9 +39,8 @@ type NetAttachRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
MACAddr string `url:"mac_addr,omitempty" json:"mac_addr,omitempty"`
|
MACAddr string `url:"mac_addr,omitempty" json:"mac_addr,omitempty"`
|
||||||
|
|
||||||
// Used only for EXTNET and DPDK
|
// Used for EXTNET, TRUNK and DPDK
|
||||||
// For DPDK must be 1-9216
|
// Must be 1500-9216
|
||||||
// For EXTNET must be 1500-9216
|
|
||||||
// Required: false
|
// Required: false
|
||||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -37,10 +37,6 @@ type CreateRequest struct {
|
|||||||
// Pool name to create disk
|
// Pool name to create disk
|
||||||
// Required: false
|
// Required: false
|
||||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||||
|
|
||||||
// Cache mode of disk
|
|
||||||
// Required: false
|
|
||||||
Cache string `url:"cache,omitempty" json:"cache,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create creates a disk
|
// Create creates a disk
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ var disks = ListDisks{
|
|||||||
Snapshots: []ItemSnapshot{},
|
Snapshots: []ItemSnapshot{},
|
||||||
Status: "ASSIGNED",
|
Status: "ASSIGNED",
|
||||||
TechStatus: techStatusAllocated,
|
TechStatus: techStatusAllocated,
|
||||||
Type: "B",
|
|
||||||
VMID: 48500,
|
VMID: 48500,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -92,7 +91,6 @@ var disks = ListDisks{
|
|||||||
Snapshots: []ItemSnapshot{},
|
Snapshots: []ItemSnapshot{},
|
||||||
Status: "ASSIGNED",
|
Status: "ASSIGNED",
|
||||||
TechStatus: techStatusAllocated,
|
TechStatus: techStatusAllocated,
|
||||||
Type: "B",
|
|
||||||
VMID: 48502,
|
VMID: 48502,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -224,7 +222,6 @@ var searchDisks = ListSearchDisks{
|
|||||||
Snapshots: []ItemSnapshot{},
|
Snapshots: []ItemSnapshot{},
|
||||||
Status: "ASSIGNED",
|
Status: "ASSIGNED",
|
||||||
TechStatus: techStatusAllocated,
|
TechStatus: techStatusAllocated,
|
||||||
Type: "B",
|
|
||||||
VMID: 48500,
|
VMID: 48500,
|
||||||
},
|
},
|
||||||
ItemDisk{
|
ItemDisk{
|
||||||
@@ -268,7 +265,6 @@ var searchDisks = ListSearchDisks{
|
|||||||
Snapshots: []ItemSnapshot{},
|
Snapshots: []ItemSnapshot{},
|
||||||
Status: "ASSIGNED",
|
Status: "ASSIGNED",
|
||||||
TechStatus: techStatusAllocated,
|
TechStatus: techStatusAllocated,
|
||||||
Type: "B",
|
|
||||||
VMID: 48502,
|
VMID: 48502,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -360,7 +356,6 @@ func TestListSearchDisks_SortByCreatedTime(t *testing.T) {
|
|||||||
var unattachedDisks = ListDisksUnattached{
|
var unattachedDisks = ListDisksUnattached{
|
||||||
Data: []ItemDiskUnattached{
|
Data: []ItemDiskUnattached{
|
||||||
{
|
{
|
||||||
CKey: "",
|
|
||||||
Meta: []interface{}{
|
Meta: []interface{}{
|
||||||
"cloudbroker",
|
"cloudbroker",
|
||||||
"disk",
|
"disk",
|
||||||
@@ -408,11 +403,9 @@ var unattachedDisks = ListDisksUnattached{
|
|||||||
Snapshots: nil,
|
Snapshots: nil,
|
||||||
Status: "CREATED",
|
Status: "CREATED",
|
||||||
TechStatus: techStatusAllocated,
|
TechStatus: techStatusAllocated,
|
||||||
Type: "D",
|
|
||||||
VMID: 0,
|
VMID: 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
CKey: "",
|
|
||||||
Meta: []interface{}{
|
Meta: []interface{}{
|
||||||
"cloudbroker",
|
"cloudbroker",
|
||||||
"disk",
|
"disk",
|
||||||
@@ -463,7 +456,6 @@ var unattachedDisks = ListDisksUnattached{
|
|||||||
Snapshots: nil,
|
Snapshots: nil,
|
||||||
Status: "CREATED",
|
Status: "CREATED",
|
||||||
TechStatus: techStatusAllocated,
|
TechStatus: techStatusAllocated,
|
||||||
Type: "B",
|
|
||||||
VMID: 0,
|
VMID: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -38,10 +38,6 @@ type ListRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|
||||||
// Type of the disks
|
|
||||||
// Required: false
|
|
||||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
|
||||||
|
|
||||||
// Find by sep ID
|
// Find by sep ID
|
||||||
// Required: false
|
// Required: false
|
||||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||||
@@ -65,6 +61,14 @@ type ListRequest struct {
|
|||||||
// Page size
|
// Page size
|
||||||
// Required: false
|
// Required: false
|
||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
|
|
||||||
|
// ID of the resource group
|
||||||
|
// Required: false
|
||||||
|
RGID uint64 `url:"rg_id,omitempty" json:"rg_id,omitempty"`
|
||||||
|
|
||||||
|
// ID of the compute
|
||||||
|
// Required: false
|
||||||
|
ComputeID uint64 `url:"compute_id,omitempty" json:"compute_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of the created disks belonging to an account as a ListDisks struct
|
// List gets list of the created disks belonging to an account as a ListDisks struct
|
||||||
|
|||||||
@@ -34,10 +34,6 @@ type ListDeletedRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|
||||||
// Type of the disks
|
|
||||||
// Required: false
|
|
||||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
|
||||||
|
|
||||||
// Sort by one of supported fields, format +|-(field)
|
// Sort by one of supported fields, format +|-(field)
|
||||||
// Required: false
|
// Required: false
|
||||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
package disks
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ListTypesRequest struct to get list types of disks
|
|
||||||
type ListTypesRequest struct {
|
|
||||||
// Show detailed disk types by seps
|
|
||||||
// Required: true
|
|
||||||
Detailed bool `url:"detailed" json:"detailed"`
|
|
||||||
|
|
||||||
// Sort by one of supported fields, format +|-(field)
|
|
||||||
// Required: false
|
|
||||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
|
||||||
|
|
||||||
// Page number
|
|
||||||
// Required: false
|
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
|
||||||
|
|
||||||
// Page size
|
|
||||||
// Required: false
|
|
||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListTypes gets list defined disk types
|
|
||||||
func (d Disks) ListTypes(ctx context.Context, req ListTypesRequest) (*ListTypes, error) {
|
|
||||||
|
|
||||||
if err := validators.ValidateRequest(req); err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/disks/listTypes"
|
|
||||||
|
|
||||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
list := ListTypes{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &list, nil
|
|
||||||
}
|
|
||||||
@@ -26,10 +26,6 @@ type ListUnattachedRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
// Type of the disks
|
|
||||||
// Required: false
|
|
||||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
|
||||||
|
|
||||||
// ID of the account
|
// ID of the account
|
||||||
// Required: false
|
// Required: false
|
||||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ type ItemDisk struct {
|
|||||||
// Account name
|
// Account name
|
||||||
AccountName string `json:"accountName"`
|
AccountName string `json:"accountName"`
|
||||||
|
|
||||||
|
// BLK Discard
|
||||||
|
BLKDiscard bool `json:"blkdiscard"`
|
||||||
|
|
||||||
|
// Block size of disk
|
||||||
|
BlockSize string `json:"block_size"`
|
||||||
|
|
||||||
// Computes
|
// Computes
|
||||||
Computes map[string]string `json:"computes"`
|
Computes map[string]string `json:"computes"`
|
||||||
|
|
||||||
@@ -44,6 +50,9 @@ type ItemDisk struct {
|
|||||||
// Image ID
|
// Image ID
|
||||||
ImageID uint64 `json:"imageId"`
|
ImageID uint64 `json:"imageId"`
|
||||||
|
|
||||||
|
// Independent
|
||||||
|
Independent bool `json:"independent"`
|
||||||
|
|
||||||
// List of image IDs
|
// List of image IDs
|
||||||
Images []uint64 `json:"images"`
|
Images []uint64 `json:"images"`
|
||||||
|
|
||||||
@@ -80,6 +89,9 @@ type ItemDisk struct {
|
|||||||
// Present to
|
// Present to
|
||||||
PresentTo map[string]uint64 `json:"presentTo"`
|
PresentTo map[string]uint64 `json:"presentTo"`
|
||||||
|
|
||||||
|
// Provision
|
||||||
|
Provision string `json:"provision"`
|
||||||
|
|
||||||
// Purge time
|
// Purge time
|
||||||
PurgeTime uint64 `json:"purgeTime"`
|
PurgeTime uint64 `json:"purgeTime"`
|
||||||
|
|
||||||
@@ -128,9 +140,6 @@ type ItemDisk struct {
|
|||||||
// Need to clean before destroy
|
// Need to clean before destroy
|
||||||
ToClean bool `json:"to_clean"`
|
ToClean bool `json:"to_clean"`
|
||||||
|
|
||||||
// Type
|
|
||||||
Type string `json:"type"`
|
|
||||||
|
|
||||||
// Virtual machine ID
|
// Virtual machine ID
|
||||||
VMID uint64 `json:"vmid"`
|
VMID uint64 `json:"vmid"`
|
||||||
|
|
||||||
@@ -145,9 +154,6 @@ type ItemDisk struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ItemDiskUnattached struct {
|
type ItemDiskUnattached struct {
|
||||||
// CKey
|
|
||||||
CKey string `json:"_ckey"`
|
|
||||||
|
|
||||||
// Meta
|
// Meta
|
||||||
Meta []interface{} `json:"_meta"`
|
Meta []interface{} `json:"_meta"`
|
||||||
|
|
||||||
@@ -160,6 +166,12 @@ type ItemDiskUnattached struct {
|
|||||||
// Access Control List
|
// Access Control List
|
||||||
ACL map[string]interface{} `json:"acl"`
|
ACL map[string]interface{} `json:"acl"`
|
||||||
|
|
||||||
|
// BLK Discard
|
||||||
|
BLKDiscard bool `json:"blkdiscard"`
|
||||||
|
|
||||||
|
// Block size of disk
|
||||||
|
BlockSize string `json:"block_size"`
|
||||||
|
|
||||||
// Boot Partition
|
// Boot Partition
|
||||||
BootPartition uint64 `json:"bootPartition"`
|
BootPartition uint64 `json:"bootPartition"`
|
||||||
|
|
||||||
@@ -232,6 +244,9 @@ type ItemDiskUnattached struct {
|
|||||||
// Present to
|
// Present to
|
||||||
PresentTo map[string]uint64 `json:"presentTo"`
|
PresentTo map[string]uint64 `json:"presentTo"`
|
||||||
|
|
||||||
|
// Provision
|
||||||
|
Provision string `json:"provision"`
|
||||||
|
|
||||||
// Purge attempts
|
// Purge attempts
|
||||||
PurgeAttempts uint64 `json:"purgeAttempts"`
|
PurgeAttempts uint64 `json:"purgeAttempts"`
|
||||||
|
|
||||||
@@ -274,8 +289,11 @@ type ItemDiskUnattached struct {
|
|||||||
// Tech status
|
// Tech status
|
||||||
TechStatus string `json:"techStatus"`
|
TechStatus string `json:"techStatus"`
|
||||||
|
|
||||||
// Type
|
// Need to clean before destroy
|
||||||
Type string `json:"type"`
|
ToClean bool `json:"to_clean"`
|
||||||
|
|
||||||
|
// ID of the Storage Policy
|
||||||
|
StoragePolicyID uint64 `json:"storage_policy_id"`
|
||||||
|
|
||||||
// Virtual machine ID
|
// Virtual machine ID
|
||||||
VMID uint64 `json:"vmid"`
|
VMID uint64 `json:"vmid"`
|
||||||
@@ -381,6 +399,12 @@ type RecordDisk struct {
|
|||||||
// Account name
|
// Account name
|
||||||
AccountName string `json:"accountName"`
|
AccountName string `json:"accountName"`
|
||||||
|
|
||||||
|
// BLK Discard
|
||||||
|
BLKDiscard bool `json:"blkdiscard"`
|
||||||
|
|
||||||
|
// Block size of disk
|
||||||
|
BlockSize string `json:"block_size"`
|
||||||
|
|
||||||
// Computes
|
// Computes
|
||||||
Computes map[string]string `json:"computes"`
|
Computes map[string]string `json:"computes"`
|
||||||
|
|
||||||
@@ -414,6 +438,9 @@ type RecordDisk struct {
|
|||||||
// Image ID
|
// Image ID
|
||||||
ImageID uint64 `json:"imageId"`
|
ImageID uint64 `json:"imageId"`
|
||||||
|
|
||||||
|
// Independent
|
||||||
|
Independent bool `json:"independent"`
|
||||||
|
|
||||||
// List of image IDs
|
// List of image IDs
|
||||||
Images []uint64 `json:"images"`
|
Images []uint64 `json:"images"`
|
||||||
|
|
||||||
@@ -450,6 +477,9 @@ type RecordDisk struct {
|
|||||||
// Present to
|
// Present to
|
||||||
PresentTo map[string]uint64 `json:"presentTo"`
|
PresentTo map[string]uint64 `json:"presentTo"`
|
||||||
|
|
||||||
|
// Provision
|
||||||
|
Provision string `json:"provision"`
|
||||||
|
|
||||||
// Purge time
|
// Purge time
|
||||||
PurgeTime uint64 `json:"purgeTime"`
|
PurgeTime uint64 `json:"purgeTime"`
|
||||||
|
|
||||||
@@ -498,9 +528,6 @@ type RecordDisk struct {
|
|||||||
// Need to clean before destroy
|
// Need to clean before destroy
|
||||||
ToClean bool `json:"to_clean"`
|
ToClean bool `json:"to_clean"`
|
||||||
|
|
||||||
// Type
|
|
||||||
Type string `json:"type"`
|
|
||||||
|
|
||||||
// Virtual machine ID
|
// Virtual machine ID
|
||||||
VMID uint64 `json:"vmid"`
|
VMID uint64 `json:"vmid"`
|
||||||
|
|
||||||
@@ -533,11 +560,3 @@ type ItemReplication struct {
|
|||||||
// VolumeID
|
// VolumeID
|
||||||
VolumeID string `json:"volumeId"`
|
VolumeID string `json:"volumeId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListTypes struct {
|
|
||||||
// Data
|
|
||||||
Data []interface{} `json:"data"`
|
|
||||||
|
|
||||||
// Entry count
|
|
||||||
EntryCount uint64 `json:"entryCount"`
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -92,9 +92,6 @@ type RecordImage struct {
|
|||||||
// UNCPathj
|
// UNCPathj
|
||||||
UNCPath string `json:"UNCPath"`
|
UNCPath string `json:"UNCPath"`
|
||||||
|
|
||||||
// CKey
|
|
||||||
CKey string `json:"_ckey"`
|
|
||||||
|
|
||||||
// Account ID
|
// Account ID
|
||||||
AccountID uint64 `json:"accountId"`
|
AccountID uint64 `json:"accountId"`
|
||||||
|
|
||||||
@@ -143,12 +140,18 @@ type RecordImage struct {
|
|||||||
// ID
|
// ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// Independent
|
||||||
|
Independent bool `json:"independent"`
|
||||||
|
|
||||||
// Last modified
|
// Last modified
|
||||||
LastModified uint64 `json:"lastModified"`
|
LastModified uint64 `json:"lastModified"`
|
||||||
|
|
||||||
// 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"`
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ type Interface struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||||
|
|
||||||
// Maximum transmission unit, must be 1-9216
|
// Used for EXTNET, TRUNK and DPDK
|
||||||
// Used only to DPDK net type
|
// Must be 1500-9216
|
||||||
// Required: false
|
// Required: false
|
||||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||||
|
|
||||||
@@ -183,14 +183,6 @@ type CreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Start bool `url:"start" json:"start"`
|
Start bool `url:"start" json:"start"`
|
||||||
|
|
||||||
// System name
|
|
||||||
// Required: false
|
|
||||||
IS string `url:"IS,omitempty" json:"IS,omitempty"`
|
|
||||||
|
|
||||||
// Compute purpose
|
|
||||||
// Required: false
|
|
||||||
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
|
|
||||||
|
|
||||||
// Custom fields for compute. Must be a dict
|
// Custom fields for compute. Must be a dict
|
||||||
// Required: false
|
// Required: false
|
||||||
CustomFields string `url:"customFields,omitempty" json:"customFields,omitempty"`
|
CustomFields string `url:"customFields,omitempty" json:"customFields,omitempty"`
|
||||||
@@ -225,10 +217,6 @@ type CreateRequest 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"`
|
||||||
|
|
||||||
// Cache mode for boot disk
|
|
||||||
// Required: false
|
|
||||||
BootDiskCache string `url:"boot_disk_cache,omitempty" json:"boot_disk_cache,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
|
|||||||
@@ -115,10 +115,6 @@ type CreateBlankRequest struct {
|
|||||||
// The OS version that will be installed on the virtual machine
|
// The OS version that will be installed on the virtual machine
|
||||||
// Required: false
|
// Required: false
|
||||||
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
||||||
|
|
||||||
// Cache mode for boot disk
|
|
||||||
// Required: false
|
|
||||||
BootDiskCache string `url:"boot_disk_cache,omitempty" json:"boot_disk_cache,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -267,6 +267,9 @@ type ListResourceGroups struct {
|
|||||||
|
|
||||||
// Main information about Access Control List
|
// Main information about Access Control List
|
||||||
type ItemACL struct {
|
type ItemACL struct {
|
||||||
|
// Email
|
||||||
|
Email string `json:"email"`
|
||||||
|
|
||||||
// Explicit
|
// Explicit
|
||||||
Explicit bool `json:"explicit"`
|
Explicit bool `json:"explicit"`
|
||||||
|
|
||||||
|
|||||||
@@ -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]
|
||||||
|
|||||||
@@ -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
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -47,7 +47,7 @@ type RecordZone struct {
|
|||||||
K8SIDs []uint64 `json:"k8sIds"`
|
K8SIDs []uint64 `json:"k8sIds"`
|
||||||
|
|
||||||
// List of associated LB IDs
|
// List of associated LB IDs
|
||||||
LBIDs []uint64 `json:"lbIds"`
|
LBIDs []uint64 `json:"lbsIds"`
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
@@ -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"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,6 +215,9 @@ type InfoAccount struct {
|
|||||||
// UniqPools
|
// UniqPools
|
||||||
UniqPools []string `json:"uniqPools"`
|
UniqPools []string `json:"uniqPools"`
|
||||||
|
|
||||||
|
// Updated By
|
||||||
|
UpdatedBy string `json:"updatedBy"`
|
||||||
|
|
||||||
// UpdatedTime
|
// UpdatedTime
|
||||||
UpdatedTime uint64 `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,10 @@ type UpdateRequest struct {
|
|||||||
// Default zone ID
|
// Default zone ID
|
||||||
// Required: false
|
// Required: false
|
||||||
DefaultZoneID uint64 `url:"defaultZoneId,omitempty" json:"defaultZoneId,omitempty"`
|
DefaultZoneID uint64 `url:"defaultZoneId,omitempty" json:"defaultZoneId,omitempty"`
|
||||||
|
|
||||||
|
// CPU allocation parameter
|
||||||
|
// Required: false
|
||||||
|
CpuAllocationParameter string `url:"cpu_allocation_parameter,omitempty" json:"cpu_allocation_parameter,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update updates an account name and resource types and limits
|
// Update updates an account name and resource types and limits
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
@@ -20,23 +19,18 @@ type AbortSharedSnapshotMergeRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AbortSharedSnapshotMerge shared snapshots merge abort
|
// AbortSharedSnapshotMerge shared snapshots merge abort
|
||||||
func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (bool, error) {
|
func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudbroker/compute/abort_shared_snapshot_merge"
|
url := "/cloudbroker/compute/abort_shared_snapshot_merge"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
return string(res), nil
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
47
pkg/cloudbroker/compute/check_compute_placement.go
Normal file
47
pkg/cloudbroker/compute/check_compute_placement.go
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CheckComputePlacementRequest struct for check compute placement
|
||||||
|
type CheckComputePlacementRequest struct {
|
||||||
|
// IDs of compute instances to check
|
||||||
|
// Required: true
|
||||||
|
ComputeIDs []uint64 `url:"compute_ids" json:"compute_ids" validate:"required"`
|
||||||
|
|
||||||
|
// Filter by CPU and RAM when checking placement
|
||||||
|
// Required: false
|
||||||
|
// Default: true
|
||||||
|
FilterByCPURAM interface{} `url:"filter_by_cpu_ram,omitempty" json:"filter_by_cpu_ram,omitempty" validate:"omitempty,isBool"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckComputePlacement checks compute placement and returns structured result
|
||||||
|
func (c Compute) CheckComputePlacement(ctx context.Context, req CheckComputePlacementRequest) (CheckComputePlacementResult, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/compute/check_compute_placement"
|
||||||
|
|
||||||
|
if req.FilterByCPURAM == nil {
|
||||||
|
req.FilterByCPURAM = true
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make(CheckComputePlacementResult)
|
||||||
|
if err := json.Unmarshal(res, &result); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -2,8 +2,8 @@ package compute
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
@@ -17,22 +17,24 @@ type CloneAbortRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CloneAbort aborts a compute clone
|
// CloneAbort aborts a compute clone
|
||||||
func (c Compute) CloneAbort(ctx context.Context, req CloneAbortRequest) (bool, error) {
|
func (c Compute) CloneAbort(ctx context.Context, req CloneAbortRequest) ([]RecordCloneAbort, 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/compute/clone_abort"
|
url := "/cloudbroker/compute/clone_abort"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
result := make([]RecordCloneAbort, 0)
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -31,13 +31,6 @@ type DiskAddRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||||
|
|
||||||
// Type of the disk
|
|
||||||
// Should be one of:
|
|
||||||
// - D
|
|
||||||
// - B
|
|
||||||
// Required: false
|
|
||||||
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty" validate:"omitempty,computeDiskType"`
|
|
||||||
|
|
||||||
// Pool name
|
// Pool name
|
||||||
// By default will be chosen automatically
|
// By default will be chosen automatically
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -62,6 +55,10 @@ type DiskAddRequest struct {
|
|||||||
// Disk cache mode
|
// Disk cache mode
|
||||||
// Required: false
|
// Required: false
|
||||||
Cache string `url:"cache,omitempty" json:"cache,omitempty"`
|
Cache string `url:"cache,omitempty" json:"cache,omitempty"`
|
||||||
|
|
||||||
|
// BLK Discard
|
||||||
|
// Required: false
|
||||||
|
BLKDiscard interface{} `url:"blkdiscard,omitempty" json:"blkdiscard,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskAdd creates new disk and attach to compute
|
// DiskAdd creates new disk and attach to compute
|
||||||
|
|||||||
@@ -18,10 +18,6 @@ type DiskAttachRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
|
||||||
// Type of the disk B;D
|
|
||||||
// Required: false
|
|
||||||
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty"`
|
|
||||||
|
|
||||||
// Desired PCI slot (hex string, e.g. "0x1A")
|
// Desired PCI slot (hex string, e.g. "0x1A")
|
||||||
// Required: false
|
// Required: false
|
||||||
PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"`
|
PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"`
|
||||||
|
|||||||
@@ -391,6 +391,12 @@ type ItemDisk struct {
|
|||||||
// Access Control List
|
// Access Control List
|
||||||
ACL ItemACL `json:"acl"`
|
ACL ItemACL `json:"acl"`
|
||||||
|
|
||||||
|
// BLK Discard
|
||||||
|
BLKDiscard bool `json:"blkdiscard"`
|
||||||
|
|
||||||
|
// Block Size
|
||||||
|
BlockSize string `json:"block_size"`
|
||||||
|
|
||||||
// Boot partition
|
// Boot partition
|
||||||
BootPartition uint64 `json:"bootPartition"`
|
BootPartition uint64 `json:"bootPartition"`
|
||||||
|
|
||||||
@@ -436,6 +442,9 @@ type ItemDisk struct {
|
|||||||
// Image ID
|
// Image ID
|
||||||
ImageID uint64 `json:"imageId"`
|
ImageID uint64 `json:"imageId"`
|
||||||
|
|
||||||
|
// Independent
|
||||||
|
Independent bool `json:"independent"`
|
||||||
|
|
||||||
// List image IDs
|
// List image IDs
|
||||||
Images []uint64 `json:"images"`
|
Images []uint64 `json:"images"`
|
||||||
|
|
||||||
@@ -472,6 +481,9 @@ type ItemDisk struct {
|
|||||||
// Present to
|
// Present to
|
||||||
PresentTo map[string]uint64 `json:"presentTo"`
|
PresentTo map[string]uint64 `json:"presentTo"`
|
||||||
|
|
||||||
|
// Provision
|
||||||
|
Provision string `json:"provision"`
|
||||||
|
|
||||||
// Purge attempts
|
// Purge attempts
|
||||||
PurgeAttempts uint64 `json:"purgeAttempts"`
|
PurgeAttempts uint64 `json:"purgeAttempts"`
|
||||||
|
|
||||||
@@ -885,6 +897,9 @@ type InfoCompute struct {
|
|||||||
// VINS connected
|
// VINS connected
|
||||||
VINSConnected uint64 `json:"vinsConnected"`
|
VINSConnected uint64 `json:"vinsConnected"`
|
||||||
|
|
||||||
|
// Weight
|
||||||
|
Weight uint64 `json:"weight"`
|
||||||
|
|
||||||
// Zone ID
|
// Zone ID
|
||||||
ZoneID uint64 `json:"zoneId"`
|
ZoneID uint64 `json:"zoneId"`
|
||||||
}
|
}
|
||||||
@@ -1172,6 +1187,9 @@ type RecordCompute struct {
|
|||||||
// VNC password
|
// VNC password
|
||||||
VNCPassword string `json:"vncPasswd"`
|
VNCPassword string `json:"vncPasswd"`
|
||||||
|
|
||||||
|
// Weight
|
||||||
|
Weight uint64 `json:"weight"`
|
||||||
|
|
||||||
// Zone ID
|
// Zone ID
|
||||||
ZoneID uint64 `json:"zoneId"`
|
ZoneID uint64 `json:"zoneId"`
|
||||||
|
|
||||||
@@ -1463,6 +1481,17 @@ type MigrateStorageItem struct {
|
|||||||
TargetNodeID uint64 `json:"targetNodeId"`
|
TargetNodeID uint64 `json:"targetNodeId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RecordCloneAbort struct {
|
||||||
|
// Disk ID
|
||||||
|
DiskID uint64 `json:"disk_id"`
|
||||||
|
|
||||||
|
// Aborted
|
||||||
|
Aborted bool `json:"aborted"`
|
||||||
|
|
||||||
|
// Blockcopy abort job ID
|
||||||
|
BlockcopyAbortJobID string `json:"blockcopy_abort_job_id"`
|
||||||
|
}
|
||||||
|
|
||||||
type RecordCloneStatus struct {
|
type RecordCloneStatus struct {
|
||||||
// Disk ID
|
// Disk ID
|
||||||
DiskID int `json:"disk_id"`
|
DiskID int `json:"disk_id"`
|
||||||
@@ -1490,3 +1519,20 @@ type CloneStatus struct {
|
|||||||
// Progress percent
|
// Progress percent
|
||||||
ProgressPercent int `json:"progress_percent"`
|
ProgressPercent int `json:"progress_percent"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CheckComputePlacementError struct {
|
||||||
|
// Code
|
||||||
|
Code int64 `json:"code"`
|
||||||
|
|
||||||
|
// Message
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CheckComputePlacementItem struct {
|
||||||
|
// Nide IDs
|
||||||
|
NodeIDs []uint64 `json:"node_ids"`
|
||||||
|
// error
|
||||||
|
Error CheckComputePlacementError `json:"error,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CheckComputePlacementResult map[uint64]CheckComputePlacementItem
|
||||||
|
|||||||
@@ -39,9 +39,8 @@ type NetAttachRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
MACAddr string `url:"mac_addr,omitempty" json:"mac_addr,omitempty"`
|
MACAddr string `url:"mac_addr,omitempty" json:"mac_addr,omitempty"`
|
||||||
|
|
||||||
// Used only for EXTNET and DPDK
|
// Used for EXTNET, TRUNK and DPDK
|
||||||
// For DPDK must be 1-9216
|
// Must be 1500-9216
|
||||||
// For EXTNET must be 1500-9216
|
|
||||||
// Required: false
|
// Required: false
|
||||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -69,6 +69,10 @@ type UpdateRequest struct {
|
|||||||
// The OS version that will be installed on the virtual machine
|
// The OS version that will be installed on the virtual machine
|
||||||
// Required: false
|
// Required: false
|
||||||
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
||||||
|
|
||||||
|
// Priority weight of the compute: higher value means higher priority and later migration
|
||||||
|
// Required: false
|
||||||
|
Weight uint64 `url:"weight,omitempty" json:"weight,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update updates some properties of the compute
|
// Update updates some properties of the compute
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ type CreateRequest struct {
|
|||||||
// Cache mode of disk
|
// Cache mode of disk
|
||||||
// Required: false
|
// Required: false
|
||||||
Cache string `url:"cache,omitempty" json:"cache,omitempty"`
|
Cache string `url:"cache,omitempty" json:"cache,omitempty"`
|
||||||
|
|
||||||
|
// BLK Discard
|
||||||
|
// Required: false
|
||||||
|
BLKDiscard interface{} `url:"blkdiscard,omitempty" json:"blkdiscard,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create creates a disk
|
// Create creates a disk
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ var disks = ListDisks{
|
|||||||
Snapshots: []ItemSnapshot{},
|
Snapshots: []ItemSnapshot{},
|
||||||
Status: "ASSIGNED",
|
Status: "ASSIGNED",
|
||||||
TechStatus: "ALLOCATED",
|
TechStatus: "ALLOCATED",
|
||||||
Type: "B",
|
|
||||||
VMID: 48500,
|
VMID: 48500,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -120,7 +119,6 @@ var disks = ListDisks{
|
|||||||
Snapshots: []ItemSnapshot{},
|
Snapshots: []ItemSnapshot{},
|
||||||
Status: "ASSIGNED",
|
Status: "ASSIGNED",
|
||||||
TechStatus: "ALLOCATED",
|
TechStatus: "ALLOCATED",
|
||||||
Type: "B",
|
|
||||||
VMID: 48502,
|
VMID: 48502,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -38,10 +38,6 @@ type ListRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|
||||||
// Type of the disks
|
|
||||||
// Required: false
|
|
||||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
|
||||||
|
|
||||||
// Find by sep ID
|
// Find by sep ID
|
||||||
// Required: false
|
// Required: false
|
||||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||||
@@ -65,6 +61,14 @@ type ListRequest struct {
|
|||||||
// Page size
|
// Page size
|
||||||
// Required: false
|
// Required: false
|
||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
|
|
||||||
|
// ID of the resource group
|
||||||
|
// Required: false
|
||||||
|
RGID uint64 `url:"rg_id,omitempty" json:"rg_id,omitempty"`
|
||||||
|
|
||||||
|
// ID of the compute
|
||||||
|
// Required: false
|
||||||
|
ComputeID uint64 `url:"compute_id,omitempty" json:"compute_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of the created disks belonging to an account as a ListDisks struct
|
// List gets list of the created disks belonging to an account as a ListDisks struct
|
||||||
|
|||||||
@@ -34,10 +34,6 @@ type ListDeletedRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|
||||||
// Type of the disks
|
|
||||||
// Required: false
|
|
||||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
|
||||||
|
|
||||||
// Sort by one of supported fields, format +|-(field)
|
// Sort by one of supported fields, format +|-(field)
|
||||||
// Required: false
|
// Required: false
|
||||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
package disks
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ListTypesRequest struct to get list of types of disks
|
|
||||||
type ListTypesRequest struct {
|
|
||||||
// Show detailed disk types by seps
|
|
||||||
// Required: false
|
|
||||||
Detailed bool `url:"detailed" json:"detailed"`
|
|
||||||
|
|
||||||
// Sort by one of supported fields, format +|-(field)
|
|
||||||
// Required: false
|
|
||||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
|
||||||
|
|
||||||
// Page number
|
|
||||||
// Required: false
|
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
|
||||||
|
|
||||||
// Page size
|
|
||||||
// Required: false
|
|
||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListTypes gets list of defined disk types
|
|
||||||
func (d Disks) ListTypes(ctx context.Context, req ListTypesRequest) (*ListTypes, error) {
|
|
||||||
|
|
||||||
if err := validators.ValidateRequest(req); err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/disks/listTypes"
|
|
||||||
|
|
||||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
list := ListTypes{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &list)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &list, nil
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -26,10 +26,6 @@ type ListUnattachedRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
// Type of the disks
|
|
||||||
// Required: false
|
|
||||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
|
||||||
|
|
||||||
// ID of the account
|
// ID of the account
|
||||||
// Required: false
|
// Required: false
|
||||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
|
|||||||
@@ -53,6 +53,12 @@ type InfoDisk struct {
|
|||||||
// Access Control Control
|
// Access Control Control
|
||||||
ACL map[string]interface{} `json:"acl"`
|
ACL map[string]interface{} `json:"acl"`
|
||||||
|
|
||||||
|
// BLK Discard
|
||||||
|
BLKDiscard bool `json:"blkdiscard"`
|
||||||
|
|
||||||
|
// Block size of disk
|
||||||
|
BlockSize string `json:"block_size"`
|
||||||
|
|
||||||
// Boot partition
|
// Boot partition
|
||||||
BootPartition uint64 `json:"bootPartition"`
|
BootPartition uint64 `json:"bootPartition"`
|
||||||
|
|
||||||
@@ -125,6 +131,9 @@ type InfoDisk struct {
|
|||||||
// Present to
|
// Present to
|
||||||
PresentTo map[string]uint64 `json:"presentTo"`
|
PresentTo map[string]uint64 `json:"presentTo"`
|
||||||
|
|
||||||
|
// Provision
|
||||||
|
Provision string `json:"provision"`
|
||||||
|
|
||||||
// Purge attempts
|
// Purge attempts
|
||||||
PurgeAttempts uint64 `json:"purgeAttempts"`
|
PurgeAttempts uint64 `json:"purgeAttempts"`
|
||||||
|
|
||||||
@@ -179,9 +188,6 @@ type InfoDisk struct {
|
|||||||
// Need to clean before destroy
|
// Need to clean before destroy
|
||||||
ToClean bool `json:"to_clean"`
|
ToClean bool `json:"to_clean"`
|
||||||
|
|
||||||
// Type
|
|
||||||
Type string `json:"type"`
|
|
||||||
|
|
||||||
// Virtual machine ID
|
// Virtual machine ID
|
||||||
VMID uint64 `json:"vmid"`
|
VMID uint64 `json:"vmid"`
|
||||||
|
|
||||||
@@ -215,6 +221,9 @@ type ItemReplication struct {
|
|||||||
// Detailed indormation about disk
|
// Detailed indormation about disk
|
||||||
type RecordDisk struct {
|
type RecordDisk struct {
|
||||||
|
|
||||||
|
// Block size of disk
|
||||||
|
BlockSize string `json:"block_size"`
|
||||||
|
|
||||||
//Created by
|
//Created by
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
|
|
||||||
@@ -236,6 +245,9 @@ type RecordDisk struct {
|
|||||||
// Main information about disk
|
// Main information about disk
|
||||||
InfoDisk
|
InfoDisk
|
||||||
|
|
||||||
|
// Independent
|
||||||
|
Independent bool `json:"independent"`
|
||||||
|
|
||||||
//Updated by
|
//Updated by
|
||||||
UpdatedBy string `json:"updatedBy"`
|
UpdatedBy string `json:"updatedBy"`
|
||||||
|
|
||||||
@@ -264,9 +276,6 @@ type SearchListDisks []ItemDisk
|
|||||||
|
|
||||||
// Main information about unattached disk
|
// Main information about unattached disk
|
||||||
type ItemUnattachedDisk struct {
|
type ItemUnattachedDisk struct {
|
||||||
// CKey
|
|
||||||
CKey string `json:"_ckey"`
|
|
||||||
|
|
||||||
// Meta
|
// Meta
|
||||||
Meta []interface{} `json:"_meta"`
|
Meta []interface{} `json:"_meta"`
|
||||||
|
|
||||||
@@ -316,14 +325,6 @@ type ItemSnapshot struct {
|
|||||||
// List snapshots
|
// List snapshots
|
||||||
type ListSnapshots []ItemSnapshot
|
type ListSnapshots []ItemSnapshot
|
||||||
|
|
||||||
type ListTypes struct {
|
|
||||||
// Data
|
|
||||||
Data []interface{} `json:"data"`
|
|
||||||
|
|
||||||
// Entry count
|
|
||||||
EntryCount uint64 `json:"entryCount"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type MigrateStatus struct {
|
type MigrateStatus struct {
|
||||||
// Type
|
// Type
|
||||||
Type int `json:"type"`
|
Type int `json:"type"`
|
||||||
|
|||||||
@@ -17,6 +17,14 @@ type UpdateRequest struct {
|
|||||||
// Cache mode of disk
|
// Cache mode of disk
|
||||||
// Required: false
|
// Required: false
|
||||||
Cache string `url:"cache,omitempty" json:"cache,omitempty"`
|
Cache string `url:"cache,omitempty" json:"cache,omitempty"`
|
||||||
|
|
||||||
|
// BLK Discard
|
||||||
|
// Required: false
|
||||||
|
BLKDiscard interface{} `url:"blkdiscard,omitempty" json:"blkdiscard,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
|
// Block size of disk
|
||||||
|
// Required: false
|
||||||
|
BlockSize string `url:"block_size,omitempty" json:"block_size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update updates disk
|
// Update updates disk
|
||||||
|
|||||||
47
pkg/cloudbroker/image/create_multi_image.go
Normal file
47
pkg/cloudbroker/image/create_multi_image.go
Normal 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
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -53,12 +53,18 @@ type RecordImage struct {
|
|||||||
// ID
|
// ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// Independent
|
||||||
|
Independent bool `json:"independent"`
|
||||||
|
|
||||||
// Last modified
|
// Last modified
|
||||||
LastModified uint64 `json:"lastModified"`
|
LastModified uint64 `json:"lastModified"`
|
||||||
|
|
||||||
// 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"`
|
||||||
|
|
||||||
@@ -185,12 +191,18 @@ type ItemImage struct {
|
|||||||
// ID
|
// ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// Independent
|
||||||
|
Independent bool `json:"independent"`
|
||||||
|
|
||||||
// Last modified
|
// Last modified
|
||||||
LastModified uint64 `json:"lastModified"`
|
LastModified uint64 `json:"lastModified"`
|
||||||
|
|
||||||
// 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"`
|
||||||
|
|
||||||
|
|||||||
43
pkg/cloudbroker/image/multi_image_add_links.go
Normal file
43
pkg/cloudbroker/image/multi_image_add_links.go
Normal 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
|
||||||
|
}
|
||||||
43
pkg/cloudbroker/image/multi_image_del_links.go
Normal file
43
pkg/cloudbroker/image/multi_image_del_links.go
Normal 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
|
||||||
|
}
|
||||||
46
pkg/cloudbroker/image/multi_image_export.go
Normal file
46
pkg/cloudbroker/image/multi_image_export.go
Normal 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
|
||||||
|
}
|
||||||
@@ -28,8 +28,8 @@ type Interface struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||||
|
|
||||||
// Maximum transmission unit, must be 1-9216
|
// Used for EXTNET, TRUNK and DPDK
|
||||||
// Used only to DPDK net type
|
// Must be 1500-9216
|
||||||
// Required: false
|
// Required: false
|
||||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||||
|
|
||||||
@@ -106,6 +106,14 @@ type DataDisk struct {
|
|||||||
// Specify image id for create disk from template
|
// Specify image id for create disk from template
|
||||||
// Required: false
|
// Required: false
|
||||||
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
||||||
|
|
||||||
|
// Cache mode for disk
|
||||||
|
// Required: false
|
||||||
|
Cache string `url:"cache,omitempty" json:"cache,omitempty"`
|
||||||
|
|
||||||
|
// BLK Discard
|
||||||
|
// Required: false
|
||||||
|
BLKDiscard interface{} `url:"blkdiscard,omitempty" json:"blkdiscard,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateRequest struct to create KVM x86 VM
|
// CreateRequest struct to create KVM x86 VM
|
||||||
@@ -185,14 +193,6 @@ type CreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
NodeID uint64 `url:"node_id,omitempty" json:"node_id,omitempty"`
|
NodeID uint64 `url:"node_id,omitempty" json:"node_id,omitempty"`
|
||||||
|
|
||||||
// System name
|
|
||||||
// Required: false
|
|
||||||
IS string `url:"IS,omitempty" json:"IS,omitempty"`
|
|
||||||
|
|
||||||
// Compute purpose
|
|
||||||
// Required: false
|
|
||||||
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
|
|
||||||
|
|
||||||
// Custom fields for Compute. Must be dict
|
// Custom fields for Compute. Must be dict
|
||||||
// Required: false
|
// Required: false
|
||||||
CustomField string `url:"customFields,omitempty" json:"customFields,omitempty"`
|
CustomField string `url:"customFields,omitempty" json:"customFields,omitempty"`
|
||||||
@@ -231,6 +231,15 @@ type CreateRequest struct {
|
|||||||
// Cache mode for boot disk
|
// Cache mode for boot disk
|
||||||
// Required: false
|
// Required: false
|
||||||
BootDiskCache string `url:"boot_disk_cache,omitempty" json:"boot_disk_cache,omitempty"`
|
BootDiskCache string `url:"boot_disk_cache,omitempty" json:"boot_disk_cache,omitempty"`
|
||||||
|
|
||||||
|
// Boot Disk BLK Discard
|
||||||
|
// Required: false
|
||||||
|
BootDiskBLKDiscard interface{} `url:"boot_disk_blkdiscard,omitempty" json:"boot_disk_blkdiscard,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
|
// Priority weight of the VM: higher value means higher priority and later migration
|
||||||
|
// Required: false
|
||||||
|
// Default: 1
|
||||||
|
Weight uint64 `url:"weight,omitempty" json:"weight,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
|
|||||||
@@ -119,6 +119,15 @@ type CreateBlankRequest struct {
|
|||||||
// Cache mode for boot disk
|
// Cache mode for boot disk
|
||||||
// Required: false
|
// Required: false
|
||||||
BootDiskCache string `url:"boot_disk_cache,omitempty" json:"boot_disk_cache,omitempty"`
|
BootDiskCache string `url:"boot_disk_cache,omitempty" json:"boot_disk_cache,omitempty"`
|
||||||
|
|
||||||
|
// Boot Disk BLK Discard
|
||||||
|
// Required: false
|
||||||
|
BootDiskBLKDiscard interface{} `url:"boot_disk_blkdiscard" json:"boot_disk_blkdiscard" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
|
// Priority weight of the VM: higher value means higher priority and later migration
|
||||||
|
// Required: false
|
||||||
|
// Default: 1
|
||||||
|
Weight uint64 `url:"weight,omitempty" json:"weight,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ type InterfaceMassCreate struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||||
|
|
||||||
// Maximum transmission unit, must be 1-9216
|
// Used for EXTNET, TRUNK and DPDK
|
||||||
// Used only to DPDK net type
|
// Must be 1500-9216
|
||||||
// Required: false
|
// Required: false
|
||||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||||
|
|
||||||
@@ -156,6 +156,15 @@ type MassCreateRequest struct {
|
|||||||
// Cache mode for boot disk
|
// Cache mode for boot disk
|
||||||
// Required: false
|
// Required: false
|
||||||
BootDiskCache string `url:"boot_disk_cache,omitempty" json:"boot_disk_cache,omitempty"`
|
BootDiskCache string `url:"boot_disk_cache,omitempty" json:"boot_disk_cache,omitempty"`
|
||||||
|
|
||||||
|
// Boot Disk BLK Discard
|
||||||
|
// Required: false
|
||||||
|
BootDiskBLKDiscard interface{} `url:"boot_disk_blkdiscard" json:"boot_disk_blkdiscard" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
|
// Priority weight of the VM: higher value means higher priority and later migration
|
||||||
|
// Required: false
|
||||||
|
// Default: 1
|
||||||
|
Weight uint64 `url:"weight,omitempty" json:"weight,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type asyncWrapperMassCreateRequest struct {
|
type asyncWrapperMassCreateRequest struct {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ type EnableRequest struct {
|
|||||||
Message string `url:"message,omitempty" json:"message,omitempty"`
|
Message string `url:"message,omitempty" json:"message,omitempty"`
|
||||||
|
|
||||||
// Do not check locks, iscsi-sessions or disk-present
|
// Do not check locks, iscsi-sessions or disk-present
|
||||||
// Default: true
|
// Default: false
|
||||||
// Required: false
|
// Required: false
|
||||||
Force interface{} `url:"force" json:"force" validate:"isBool"`
|
Force interface{} `url:"force" json:"force" validate:"isBool"`
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ func (n Node) Enable(ctx context.Context, req EnableRequest) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if req.Force == nil {
|
if req.Force == nil {
|
||||||
req.Force = true
|
req.Force = false
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperEnableRequest{
|
reqWrapped := wrapperEnableRequest{
|
||||||
@@ -67,7 +67,7 @@ func (n Node) EnableAsync(ctx context.Context, req EnableRequest) (string, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
if req.Force == nil {
|
if req.Force == nil {
|
||||||
req.Force = true
|
req.Force = false
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperEnableRequest{
|
reqWrapped := wrapperEnableRequest{
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ type GetLogicalCoresCountRequest struct {
|
|||||||
// Node ID
|
// Node ID
|
||||||
// Required: true
|
// Required: true
|
||||||
NodeId uint64 `url:"node_id" json:"node_id" validate:"required"`
|
NodeId uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||||
|
|
||||||
|
// Target
|
||||||
|
// Required: false
|
||||||
|
Target string `url:"target,omitempty" json:"target,omitempty" validate:"omitempty,oneof=core node"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLogicalCoresCount get logical cores count by node
|
// GetLogicalCoresCount get logical cores count by node
|
||||||
@@ -24,7 +28,7 @@ func (i Node) GetLogicalCoresCount(ctx context.Context, req GetLogicalCoresCount
|
|||||||
|
|
||||||
url := "/cloudbroker/node/get_logical_cores_count"
|
url := "/cloudbroker/node/get_logical_cores_count"
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := i.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ type ListRequest struct {
|
|||||||
// Page size
|
// Page size
|
||||||
// Required: false
|
// Required: false
|
||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
|
|
||||||
|
// Find by zone ID
|
||||||
|
// Required: false
|
||||||
|
ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all nodes as a ListNodes struct
|
// List gets list of all nodes as a ListNodes struct
|
||||||
|
|||||||
@@ -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"`
|
||||||
|
|
||||||
|
|||||||
10
pkg/cloudbroker/resource_optimizer.go
Normal file
10
pkg/cloudbroker/resource_optimizer.go
Normal 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)
|
||||||
|
}
|
||||||
42
pkg/cloudbroker/resource_optimizer/drs_add_nodes.go
Normal file
42
pkg/cloudbroker/resource_optimizer/drs_add_nodes.go
Normal 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
|
||||||
|
}
|
||||||
58
pkg/cloudbroker/resource_optimizer/drs_create.go
Normal file
58
pkg/cloudbroker/resource_optimizer/drs_create.go
Normal 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
|
||||||
|
}
|
||||||
42
pkg/cloudbroker/resource_optimizer/drs_del_nodes.go
Normal file
42
pkg/cloudbroker/resource_optimizer/drs_del_nodes.go
Normal 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
|
||||||
|
}
|
||||||
38
pkg/cloudbroker/resource_optimizer/drs_remove.go
Normal file
38
pkg/cloudbroker/resource_optimizer/drs_remove.go
Normal 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
|
||||||
|
}
|
||||||
38
pkg/cloudbroker/resource_optimizer/drs_start.go
Normal file
38
pkg/cloudbroker/resource_optimizer/drs_start.go
Normal 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
|
||||||
|
}
|
||||||
38
pkg/cloudbroker/resource_optimizer/drs_stop.go
Normal file
38
pkg/cloudbroker/resource_optimizer/drs_stop.go
Normal 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
|
||||||
|
}
|
||||||
58
pkg/cloudbroker/resource_optimizer/drs_update.go
Normal file
58
pkg/cloudbroker/resource_optimizer/drs_update.go
Normal 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
|
||||||
|
}
|
||||||
16
pkg/cloudbroker/resource_optimizer/resource_optimizer.go
Normal file
16
pkg/cloudbroker/resource_optimizer/resource_optimizer.go
Normal 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,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 {
|
||||||
@@ -79,6 +79,9 @@ type ListResourceConsumption struct {
|
|||||||
|
|
||||||
// Access Control List
|
// Access Control List
|
||||||
type ACL struct {
|
type ACL struct {
|
||||||
|
// Email
|
||||||
|
Email string `json:"email"`
|
||||||
|
|
||||||
// Explicit
|
// Explicit
|
||||||
Explicit bool `json:"explicit"`
|
Explicit bool `json:"explicit"`
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ type UpdateRequest struct {
|
|||||||
// Storage policies
|
// Storage policies
|
||||||
// Required: false
|
// Required: false
|
||||||
StoragePolicies []StoragePolicy `url:"-" json:"storage_policies,omitempty"`
|
StoragePolicies []StoragePolicy `url:"-" json:"storage_policies,omitempty"`
|
||||||
|
|
||||||
|
// CPU allocation parameter
|
||||||
|
// Required: false
|
||||||
|
CPUAllocationParameter string `url:"cpu_allocation_parameter,omitempty" json:"cpu_allocation_parameter,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update updates resource group
|
// Update updates resource group
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ type InfoStoragePolicyWithID struct {
|
|||||||
// Max IOPS for the sotrage policy
|
// Max IOPS for the sotrage policy
|
||||||
LimitIOPS uint64 `json:"limit_iops"`
|
LimitIOPS uint64 `json:"limit_iops"`
|
||||||
|
|
||||||
// ID of the storage policy
|
// Which accounts and resource groups use the storage policy
|
||||||
StoragePolicyID uint64 `json:"storage_policy_id"`
|
Usage Usage `json:"usage"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListStoragePolicies struct {
|
type ListStoragePolicies struct {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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]
|
||||||
|
|||||||
@@ -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
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -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"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,10 +62,18 @@ type ListRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
CreatedFrom string `url:"created_from,omitempty" json:"created_from,omitempty"`
|
CreatedFrom string `url:"created_from,omitempty" json:"created_from,omitempty"`
|
||||||
|
|
||||||
// Filter lby create date to
|
// Filter by create date to
|
||||||
// Required: false
|
// Required: false
|
||||||
CreatedTo string `url:"created_to,omitempty" json:"created_to,omitempty"`
|
CreatedTo string `url:"created_to,omitempty" json:"created_to,omitempty"`
|
||||||
|
|
||||||
|
// Filter by operation status
|
||||||
|
// Required: false
|
||||||
|
OperationStatus string `url:"operation_status,omitempty" json:"operation_status,omitempty"`
|
||||||
|
|
||||||
|
// Filter by hypervisor status
|
||||||
|
// Required: false
|
||||||
|
HypervisorStatus string `url:"hypervisor_status,omitempty" json:"hypervisor_status,omitempty"`
|
||||||
|
|
||||||
// Page number for pagination
|
// Page number for pagination
|
||||||
// Required: false
|
// Required: false
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Label struct
|
||||||
|
type CreateLabels struct {
|
||||||
|
VMID string `url:"vm_id,omitempty" json:"vm_id,omitempty"`
|
||||||
|
VMName string `url:"vm_name,omitempty" json:"vm_name,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// CreateRequest struct to create logical port
|
// CreateRequest struct to create logical port
|
||||||
type CreateRequest struct {
|
type CreateRequest struct {
|
||||||
// ID of the access group
|
// ID of the access group
|
||||||
@@ -27,10 +33,6 @@ type CreateRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
Enabled interface{} `url:"enabled" json:"enabled" validate:"required,isBool"`
|
Enabled interface{} `url:"enabled" json:"enabled" validate:"required,isBool"`
|
||||||
|
|
||||||
// Is excluded from firewall. True or False
|
|
||||||
// Required: true
|
|
||||||
IsExcludedFromFirewall interface{} `url:"is_excluded_from_firewall" json:"is_excluded_from_firewall" validate:"required,isBool"`
|
|
||||||
|
|
||||||
// Hypervisor
|
// Hypervisor
|
||||||
// Required: true
|
// Required: true
|
||||||
Hypervisor string `url:"hypervisor" json:"hypervisor" validate:"required"`
|
Hypervisor string `url:"hypervisor" json:"hypervisor" validate:"required"`
|
||||||
@@ -54,6 +56,10 @@ type CreateRequest struct {
|
|||||||
// Logical port addresses
|
// Logical port addresses
|
||||||
// Required: false
|
// Required: false
|
||||||
LogicalPortAddresses []LogicalPortAddress `url:"logical_port_addresses,omitempty" json:"logical_port_addresses,omitempty" validate:"dive"`
|
LogicalPortAddresses []LogicalPortAddress `url:"logical_port_addresses,omitempty" json:"logical_port_addresses,omitempty" validate:"dive"`
|
||||||
|
|
||||||
|
// Labels
|
||||||
|
// Required: false
|
||||||
|
Labels CreateLabels `url:"labels,omitempty" json:"labels,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogicalPortAddressRequest struct representing logical port address
|
// LogicalPortAddressRequest struct representing logical port address
|
||||||
|
|||||||
134
pkg/sdn/logicalports/create_batch.go
Normal file
134
pkg/sdn/logicalports/create_batch.go
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
package logicalports
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CreateBatchLogicalPortAddress struct {
|
||||||
|
// IP
|
||||||
|
// Required: true
|
||||||
|
IP string `url:"ip" json:"ip" validate:"required"`
|
||||||
|
|
||||||
|
// IP Type
|
||||||
|
// Required: true
|
||||||
|
IPType string `url:"ip_type" json:"ip_type" validate:"required"`
|
||||||
|
|
||||||
|
// Is Discovered
|
||||||
|
// Required: true
|
||||||
|
IsDiscovered bool `url:"is_discovered" json:"is_discovered" validate:"required"`
|
||||||
|
|
||||||
|
// Is Primary
|
||||||
|
// Required: true
|
||||||
|
IsPrimary bool `url:"is_primary" json:"is_primary" validate:"required"`
|
||||||
|
|
||||||
|
// MAC
|
||||||
|
// Required: false
|
||||||
|
MAC string `url:"mac,omitempty" json:"mac,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateBatchBindings struct {
|
||||||
|
// Address Detection
|
||||||
|
// Required: true
|
||||||
|
AddressDetection bool `url:"address_detection" json:"address_detection" validate:"required"`
|
||||||
|
|
||||||
|
// Logical Port Address
|
||||||
|
// Required: true
|
||||||
|
LogicalPortAddresses []CreateBatchLogicalPortAddress `url:"logical_port_addresses" json:"logical_port_addresses" validate:"required,dive"`
|
||||||
|
|
||||||
|
// Port Security
|
||||||
|
// Required: true
|
||||||
|
PortSecurity bool `url:"port_security" json:"port_security" validate:"required"`
|
||||||
|
|
||||||
|
// Segment ID
|
||||||
|
// Required: true
|
||||||
|
SegmentID string `url:"segment_id" json:"segment_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateBatchLabels struct {
|
||||||
|
// VM ID
|
||||||
|
// Required: false
|
||||||
|
VMID string `url:"vm_id,omitempty" json:"vm_id,omitempty"`
|
||||||
|
|
||||||
|
// VM Name
|
||||||
|
// Required: false
|
||||||
|
VMName string `url:"vm_name,omitempty" json:"vm_name,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NetObjectGroups struct {
|
||||||
|
// ID
|
||||||
|
// Required: true
|
||||||
|
ID string `url:"id" json:"id" validate:"required"`
|
||||||
|
|
||||||
|
// Version ID
|
||||||
|
// Required: true
|
||||||
|
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Ports struct {
|
||||||
|
// Adapter MAC
|
||||||
|
// Required: false
|
||||||
|
AdapterMAC string `url:"adapter_mac,omitempty" json:"adapter_mac,omitempty"`
|
||||||
|
|
||||||
|
// Bindings
|
||||||
|
// Required: true
|
||||||
|
Bindings CreateBatchBindings `url:"bindings" json:"bindings" validate:"required"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
// Required: true
|
||||||
|
Description string `url:"description" json:"description" validate:"required"`
|
||||||
|
|
||||||
|
// Display Name
|
||||||
|
// Required: true
|
||||||
|
DisplayName string `url:"display_name" json:"display_name" validate:"required"`
|
||||||
|
|
||||||
|
// Enabled
|
||||||
|
// Required: true
|
||||||
|
Enabled bool `url:"enabled" json:"enabled" validate:"required"`
|
||||||
|
|
||||||
|
// Hypervisor
|
||||||
|
// Required: true
|
||||||
|
Hypervisor string `url:"hypervisor" json:"hypervisor" validate:"required"`
|
||||||
|
|
||||||
|
// Net Object Groups
|
||||||
|
// Required: false
|
||||||
|
NetObjectGroups []NetObjectGroups `json:"net_object_groups" validate:"required,dive"`
|
||||||
|
|
||||||
|
// Labels
|
||||||
|
// Required: false
|
||||||
|
Labels []CreateBatchLabels `url:"labels,omitempty" json:"labels,omitempty" validate:"required,dive"`
|
||||||
|
|
||||||
|
// Unique Identifier
|
||||||
|
// Required: false
|
||||||
|
UniqueIdentifier string `url:"unique_identifier,omitempty" json:"unique_identifier,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateBatchRequest struct to create a batch of logical ports
|
||||||
|
type CreateBatchRequest struct {
|
||||||
|
// Access Group ID
|
||||||
|
// Required: true
|
||||||
|
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||||
|
|
||||||
|
// Ports
|
||||||
|
// Required: true
|
||||||
|
Ports []Ports `json:"ports" validate:"required,dive"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateBatch creates a batch of logical ports
|
||||||
|
func (lp LogicalPorts) CreateBatch(ctx context.Context, req CreateBatchRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
url := "/sdn/logical_port/create_batch"
|
||||||
|
|
||||||
|
_, err = lp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
50
pkg/sdn/logicalports/delete_batch.go
Normal file
50
pkg/sdn/logicalports/delete_batch.go
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package logicalports
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PortsInfo struct {
|
||||||
|
// Force
|
||||||
|
// Required: true
|
||||||
|
Force bool `url:"force" json:"force" validate:"required"`
|
||||||
|
|
||||||
|
// ID
|
||||||
|
// Required: true
|
||||||
|
ID string `url:"id" json:"id" validate:"required"`
|
||||||
|
|
||||||
|
// Version ID
|
||||||
|
// Required: true
|
||||||
|
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteBatchRequest struct to delete a batch of logical ports
|
||||||
|
type DeleteBatchRequest struct {
|
||||||
|
// Access Group ID
|
||||||
|
// Required: true
|
||||||
|
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||||
|
|
||||||
|
// Ports Info
|
||||||
|
// Required: true
|
||||||
|
PortsInfo []PortsInfo `json:"ports_info" validate:"required,dive"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteBatch deletes a batch of logical ports
|
||||||
|
func (lp LogicalPorts) DeleteBatch(ctx context.Context, req DeleteBatchRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
url := "/sdn/logical_port/delete_batch"
|
||||||
|
|
||||||
|
_, err = lp.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
63
pkg/sdn/logicalports/exclude_firewall.go
Normal file
63
pkg/sdn/logicalports/exclude_firewall.go
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
package logicalports
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LogicalPortsForExcludeFromFirewall struct {
|
||||||
|
// Exclude IP Addresses
|
||||||
|
// Required: true
|
||||||
|
ExcludeIPAddresses bool `url:"exclude_ip_addresses" json:"exclude_ip_addresses" validate:"required"`
|
||||||
|
|
||||||
|
// ID
|
||||||
|
// Required: true
|
||||||
|
ID string `url:"id" json:"id" validate:"required"`
|
||||||
|
|
||||||
|
// Version ID
|
||||||
|
// Required: true
|
||||||
|
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExcludeFirewallRequest struct to exclude firewall for logical port
|
||||||
|
type ExcludeFirewallRequest struct {
|
||||||
|
// Access Group ID
|
||||||
|
// Required: true
|
||||||
|
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||||
|
|
||||||
|
// Logical Ports For Exclude From Firewall
|
||||||
|
// Required: true
|
||||||
|
LogicalPortsForExcludeFromFirewall []LogicalPortsForExcludeFromFirewall `json:"logical_ports_for_exclude_from_firewall" validate:"required,dive"`
|
||||||
|
|
||||||
|
// Exclusion Reason
|
||||||
|
// Required: false
|
||||||
|
ExclusionReason string `url:"exclusion_reason,omitempty" json:"exclusion_reason,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExcludeFirewall excludes firewall from a logical port
|
||||||
|
func (lp LogicalPorts) ExcludeFirewall(ctx context.Context, req ExcludeFirewallRequest) (*RecordVersion, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/sdn/logical_port/exclude_firewall"
|
||||||
|
|
||||||
|
res, err := lp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordVersion{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
@@ -70,6 +70,14 @@ type ListRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
CreatedTo string `url:"created_to,omitempty" json:"created_to,omitempty"`
|
CreatedTo string `url:"created_to,omitempty" json:"created_to,omitempty"`
|
||||||
|
|
||||||
|
// Filter by operation status
|
||||||
|
// Required: false
|
||||||
|
OperationStatus string `url:"operation_status,omitempty" json:"operation_status,omitempty"`
|
||||||
|
|
||||||
|
// Filter by hypervisor status
|
||||||
|
// Required: false
|
||||||
|
HypervisorStatus string `url:"hypervisor_status,omitempty" json:"hypervisor_status,omitempty"`
|
||||||
|
|
||||||
// Page number for pagination
|
// Page number for pagination
|
||||||
// Required: false
|
// Required: false
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
@@ -87,7 +95,7 @@ type ListRequest struct {
|
|||||||
SortOrder string `url:"sort_order,omitempty" json:"sort_order,omitempty"`
|
SortOrder string `url:"sort_order,omitempty" json:"sort_order,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of logical portts
|
// List of logical ports
|
||||||
func (i LogicalPorts) List(ctx context.Context, req ListRequest) (*LogicalPortsList, error) {
|
func (i LogicalPorts) List(ctx context.Context, req ListRequest) (*LogicalPortsList, error) {
|
||||||
res, err := i.ListRaw(ctx, req)
|
res, err := i.ListRaw(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ type LogicalPort struct {
|
|||||||
// Hypervisor display name
|
// Hypervisor display name
|
||||||
HypervisorDisplayName string `json:"hypervisor_display_name"`
|
HypervisorDisplayName string `json:"hypervisor_display_name"`
|
||||||
|
|
||||||
|
// Labels
|
||||||
|
Labels Labels `json:"labels"`
|
||||||
|
|
||||||
// Live migration target hypervisor
|
// Live migration target hypervisor
|
||||||
LiveMigrationTargetHV string `json:"live_migration_target_hv"`
|
LiveMigrationTargetHV string `json:"live_migration_target_hv"`
|
||||||
|
|
||||||
@@ -64,17 +67,21 @@ type LogicalPort struct {
|
|||||||
|
|
||||||
// Status information
|
// Status information
|
||||||
type Status struct {
|
type Status struct {
|
||||||
// Common status
|
|
||||||
Common string `json:"common"`
|
// Operation status
|
||||||
|
OperationStatus string `json:"operation_status"`
|
||||||
|
|
||||||
// Hypervisors status
|
// Hypervisors status
|
||||||
Hypervisors []HypervisorStatus `json:"hypervisors"`
|
Hypervisors []HypervisorStatus `json:"hypervisors"`
|
||||||
|
|
||||||
|
// Hypervisor status
|
||||||
|
HypervisorStatus string `json:"hypervisor_status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// HypervisorStatus information
|
// HypervisorStatus information
|
||||||
type HypervisorStatus struct {
|
type HypervisorStatus struct {
|
||||||
// Status
|
// Operation status
|
||||||
Status string `json:"status"`
|
OperationStatus string `json:"operation_status"`
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
@@ -106,9 +113,6 @@ type Bindings struct {
|
|||||||
// Address detection
|
// Address detection
|
||||||
AddressDetection bool `json:"address_detection"`
|
AddressDetection bool `json:"address_detection"`
|
||||||
|
|
||||||
// Is excluded from firewall
|
|
||||||
IsExcludedFromFirewall bool `json:"is_excluded_from_firewall"`
|
|
||||||
|
|
||||||
// Version ID
|
// Version ID
|
||||||
VersionID uint64 `json:"version_id"`
|
VersionID uint64 `json:"version_id"`
|
||||||
|
|
||||||
@@ -149,6 +153,7 @@ type LogicalPortAddress struct {
|
|||||||
AssignedAt string `json:"assigned_at"`
|
AssignedAt string `json:"assigned_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Migration status information
|
||||||
type MigrationStatus struct {
|
type MigrationStatus struct {
|
||||||
// ID
|
// ID
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
@@ -156,3 +161,18 @@ type MigrationStatus struct {
|
|||||||
// Version ID
|
// Version ID
|
||||||
VersionID uint64 `json:"version_id"`
|
VersionID uint64 `json:"version_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Labels information
|
||||||
|
type Labels struct {
|
||||||
|
// VM ID
|
||||||
|
VMID string `json:"vm_id"`
|
||||||
|
|
||||||
|
// VM name
|
||||||
|
VMName string `json:"vm_name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Information about a version
|
||||||
|
type RecordVersion struct {
|
||||||
|
// Version ID
|
||||||
|
VersionID uint64 `json:"version_id"`
|
||||||
|
}
|
||||||
|
|||||||
55
pkg/sdn/logicalports/unexclude_firewall.go
Normal file
55
pkg/sdn/logicalports/unexclude_firewall.go
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
package logicalports
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LogicalPortsForUnexcludeFromFirewall struct {
|
||||||
|
// Exclude IP Addresses
|
||||||
|
// Required: true
|
||||||
|
ID string `url:"id" json:"id" validate:"required"`
|
||||||
|
|
||||||
|
// Version ID
|
||||||
|
// Required: true
|
||||||
|
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnexcludeFirewallRequest struct to unexclude firewall for logical port
|
||||||
|
type UnexcludeFirewallRequest struct {
|
||||||
|
// Access Group ID
|
||||||
|
// Required: true
|
||||||
|
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||||
|
|
||||||
|
// Logical Ports For Unexclude From Firewall
|
||||||
|
// Required: true
|
||||||
|
LogicalPortsForUnexcludeFromFirewall []LogicalPortsForUnexcludeFromFirewall `json:"logical_ports_for_unexclude_from_firewall" validate:"required,dive"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnexcludeFirewallRequest struct to unexclude firewall for logical port
|
||||||
|
func (lp LogicalPorts) UnexcludeFirewall(ctx context.Context, req UnexcludeFirewallRequest) (*RecordVersion, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/sdn/logical_port/unexclude_firewall"
|
||||||
|
|
||||||
|
res, err := lp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordVersion{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
@@ -9,6 +9,12 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Label struct
|
||||||
|
type UpdateLabels struct {
|
||||||
|
VMID string `url:"vm_id,omitempty" json:"vm_id,omitempty"`
|
||||||
|
VMName string `url:"vm_name,omitempty" json:"vm_name,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// UpdateRequest struct to update logical port
|
// UpdateRequest struct to update logical port
|
||||||
type UpdateRequest struct {
|
type UpdateRequest struct {
|
||||||
// ID of the logical port
|
// ID of the logical port
|
||||||
@@ -47,10 +53,6 @@ type UpdateRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
PortSecurity interface{} `url:"port_security" json:"port_security" validate:"required,isBool"`
|
PortSecurity interface{} `url:"port_security" json:"port_security" validate:"required,isBool"`
|
||||||
|
|
||||||
// Is excluded from firewall. True or False
|
|
||||||
// Required: true
|
|
||||||
IsExcludedFromFirewall interface{} `url:"is_excluded_from_firewall" json:"is_excluded_from_firewall" validate:"required,isBool"`
|
|
||||||
|
|
||||||
// Segment ID
|
// Segment ID
|
||||||
// Required: true
|
// Required: true
|
||||||
SegmentID string `url:"segment_id" json:"segment_id" validate:"required"`
|
SegmentID string `url:"segment_id" json:"segment_id" validate:"required"`
|
||||||
@@ -62,6 +64,10 @@ type UpdateRequest struct {
|
|||||||
// Add addresses
|
// Add addresses
|
||||||
// Required: false
|
// Required: false
|
||||||
AddAddresses []AddAddress `url:"add_addresses,omitempty" json:"add_addresses,omitempty" validate:"dive"`
|
AddAddresses []AddAddress `url:"add_addresses,omitempty" json:"add_addresses,omitempty" validate:"dive"`
|
||||||
|
|
||||||
|
// Labels
|
||||||
|
// Required: false
|
||||||
|
Labels UpdateLabels `url:"labels,omitempty" json:"labels,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateAddress struct representing update address
|
// UpdateAddress struct representing update address
|
||||||
|
|||||||
62
pkg/sdn/netobjgroups/attach_l2_connection_ports.go
Normal file
62
pkg/sdn/netobjgroups/attach_l2_connection_ports.go
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package netobjgroups
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AttachL2ConnectionPortsRequest struct to attach l2 ports to a network object group
|
||||||
|
type AttachL2ConnectionPortsRequest struct {
|
||||||
|
// ID of a network object group
|
||||||
|
// Required: true
|
||||||
|
ObjectGroupID string `url:"object_group_id" json:"object_group_id" validate:"required"`
|
||||||
|
|
||||||
|
// ID of an access group
|
||||||
|
// Required: true
|
||||||
|
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||||
|
|
||||||
|
// Version ID
|
||||||
|
// Required: true
|
||||||
|
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||||
|
|
||||||
|
// Port Bindings
|
||||||
|
// Required: true
|
||||||
|
PortBindings []L2PortBindings `url:"port_bindings" json:"port_bindings" validate:"required,dive"`
|
||||||
|
}
|
||||||
|
type L2PortBindings struct {
|
||||||
|
// ID of a logical port
|
||||||
|
// Required: true
|
||||||
|
PortID string `url:"port_id" json:"port_id" validate:"required"`
|
||||||
|
|
||||||
|
// Version of a logical port
|
||||||
|
// Required: true
|
||||||
|
PortVersion int64 `url:"port_version" json:"port_version" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AttachLogicalPorts attaches l2 ports to a network object group
|
||||||
|
func (nog NetworkObjectGroups) AttachL2ConnectionPorts(ctx context.Context, req AttachL2ConnectionPortsRequest) (*RecordVersion, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/sdn/network_object_group/attach_l2_connection_ports"
|
||||||
|
|
||||||
|
res, err := nog.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordVersion{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
62
pkg/sdn/netobjgroups/detach_l2_connection_ports.go
Normal file
62
pkg/sdn/netobjgroups/detach_l2_connection_ports.go
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package netobjgroups
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DetachL2ConnectionPortsRequest struct to detach an l2 port from a network object group
|
||||||
|
type DetachL2ConnectionPortsRequest struct {
|
||||||
|
// ID of a network object group
|
||||||
|
// Required: true
|
||||||
|
ObjectGroupID string `url:"object_group_id" json:"object_group_id" validate:"required"`
|
||||||
|
|
||||||
|
// ID of an access group
|
||||||
|
// Required: true
|
||||||
|
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||||
|
|
||||||
|
// Version ID
|
||||||
|
// Required: true
|
||||||
|
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||||
|
|
||||||
|
// Port Bindings
|
||||||
|
// Required: true
|
||||||
|
PortBindings []DetachL2PortBindings `url:"port_bindings" json:"port_bindings" validate:"required,dive"`
|
||||||
|
}
|
||||||
|
type DetachL2PortBindings struct {
|
||||||
|
// ID of a logical port
|
||||||
|
// Required: true
|
||||||
|
PortID string `url:"port_id" json:"port_id" validate:"required"`
|
||||||
|
|
||||||
|
// Version of a logical port
|
||||||
|
// Required: true
|
||||||
|
PortVersion int64 `url:"port_version" json:"port_version" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DetachL2ConnectionPorts detaches logical ports from a network object group
|
||||||
|
func (nog NetworkObjectGroups) DetachL2ConnectionPorts(ctx context.Context, req DetachL2ConnectionPortsRequest) (*RecordVersion, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/sdn/network_object_group/detach_l2_connection_ports"
|
||||||
|
|
||||||
|
res, err := nog.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordVersion{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
7
tests/platform_upgrade/platform_tests_start.sh
Normal file
7
tests/platform_upgrade/platform_tests_start.sh
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
go test -v -run TestGetListCloudAPI > TestGetListCloudAPI.txt
|
||||||
|
go test -v -run TestGetListCloudbroker > TestGetListCloudbroker.txt
|
||||||
|
go test -v -run TestGetListSDNAPI > TestGetListSDNAPI.txt
|
||||||
|
go test -v -run TestRequestsCloudAPI > TestRequestsCloudAPI.txt
|
||||||
|
go test -v -run TestRequestsCloudbroker > TestRequestsCloudbroker.txt
|
||||||
|
go test -v -run TestRequestsSDN > TestRequestsSDN.txt
|
||||||
|
go test -v -run TestGetAllPaths > TestGetAllPaths.txt
|
||||||
@@ -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"
|
||||||
@@ -237,7 +238,6 @@ func getRequestsMapCloudAPI() map[string]interface{} {
|
|||||||
"/restmachine/cloudapi/disks/limitIO": disks.LimitIORequest{},
|
"/restmachine/cloudapi/disks/limitIO": disks.LimitIORequest{},
|
||||||
"/restmachine/cloudapi/disks/list": disks.ListRequest{},
|
"/restmachine/cloudapi/disks/list": disks.ListRequest{},
|
||||||
"/restmachine/cloudapi/disks/listDeleted": disks.ListDeletedRequest{},
|
"/restmachine/cloudapi/disks/listDeleted": disks.ListDeletedRequest{},
|
||||||
"/restmachine/cloudapi/disks/listTypes": disks.ListTypesRequest{},
|
|
||||||
"/restmachine/cloudapi/disks/listUnattached": disks.ListUnattachedRequest{},
|
"/restmachine/cloudapi/disks/listUnattached": disks.ListUnattachedRequest{},
|
||||||
"/restmachine/cloudapi/disks/rename": disks.RenameRequest{},
|
"/restmachine/cloudapi/disks/rename": disks.RenameRequest{},
|
||||||
"/restmachine/cloudapi/disks/replicate": disks.ReplicateRequest{},
|
"/restmachine/cloudapi/disks/replicate": disks.ReplicateRequest{},
|
||||||
@@ -570,6 +570,7 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
|||||||
"/restmachine/cloudbroker/compute/cdInsert": compute_cb.CDInsertRequest{},
|
"/restmachine/cloudbroker/compute/cdInsert": compute_cb.CDInsertRequest{},
|
||||||
"/restmachine/cloudbroker/compute/changeLinkState": compute_cb.ChangeLinkStateRequest{},
|
"/restmachine/cloudbroker/compute/changeLinkState": compute_cb.ChangeLinkStateRequest{},
|
||||||
"/restmachine/cloudbroker/compute/change_mtu": compute_cb.ChangeMTURequest{},
|
"/restmachine/cloudbroker/compute/change_mtu": compute_cb.ChangeMTURequest{},
|
||||||
|
"/restmachine/cloudbroker/compute/check_compute_placement": compute_cb.CheckComputePlacementRequest{},
|
||||||
"/restmachine/cloudbroker/compute/change_security_groups": compute_cb.ChangeSecGroupsRequest{},
|
"/restmachine/cloudbroker/compute/change_security_groups": compute_cb.ChangeSecGroupsRequest{},
|
||||||
"/restmachine/cloudbroker/compute/clone": compute_cb.CloneRequest{},
|
"/restmachine/cloudbroker/compute/clone": compute_cb.CloneRequest{},
|
||||||
"/restmachine/cloudbroker/compute/clone_abort": compute_cb.CloneAbortRequest{},
|
"/restmachine/cloudbroker/compute/clone_abort": compute_cb.CloneAbortRequest{},
|
||||||
@@ -672,7 +673,6 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
|||||||
"/restmachine/cloudbroker/disks/limitIO": disks_cb.LimitIORequest{},
|
"/restmachine/cloudbroker/disks/limitIO": disks_cb.LimitIORequest{},
|
||||||
"/restmachine/cloudbroker/disks/list": disks_cb.ListRequest{},
|
"/restmachine/cloudbroker/disks/list": disks_cb.ListRequest{},
|
||||||
"/restmachine/cloudbroker/disks/listDeleted": disks_cb.ListDeletedRequest{},
|
"/restmachine/cloudbroker/disks/listDeleted": disks_cb.ListDeletedRequest{},
|
||||||
"/restmachine/cloudbroker/disks/listTypes": disks_cb.ListTypesRequest{},
|
|
||||||
"/restmachine/cloudbroker/disks/listUnattached": disks_cb.ListUnattachedRequest{},
|
"/restmachine/cloudbroker/disks/listUnattached": disks_cb.ListUnattachedRequest{},
|
||||||
"/restmachine/cloudbroker/disks/rename": disks_cb.RenameRequest{},
|
"/restmachine/cloudbroker/disks/rename": disks_cb.RenameRequest{},
|
||||||
"/restmachine/cloudbroker/disks/present": disks_cb.PresentRequest{},
|
"/restmachine/cloudbroker/disks/present": disks_cb.PresentRequest{},
|
||||||
@@ -796,6 +796,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{},
|
||||||
@@ -920,6 +924,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{},
|
||||||
@@ -1165,6 +1178,8 @@ func getRequestsMapSDN() map[string]interface{} {
|
|||||||
"/restmachine/sdn/network_object_group/get": netobjgroups.GetRequest{},
|
"/restmachine/sdn/network_object_group/get": netobjgroups.GetRequest{},
|
||||||
"/restmachine/sdn/network_object_group/list": netobjgroups.ListRequest{},
|
"/restmachine/sdn/network_object_group/list": netobjgroups.ListRequest{},
|
||||||
"/restmachine/sdn/network_object_group/update": netobjgroups.UpdateRequest{},
|
"/restmachine/sdn/network_object_group/update": netobjgroups.UpdateRequest{},
|
||||||
|
"/restmachine/sdn/network_object_group/attach_l2_connection_ports": netobjgroups.AttachL2ConnectionPortsRequest{},
|
||||||
|
"/restmachine/sdn/network_object_group/detach_l2_connection_ports": netobjgroups.DetachL2ConnectionPortsRequest{},
|
||||||
|
|
||||||
// segments
|
// segments
|
||||||
"/restmachine/sdn/segment/create": segments.CreateRequest{},
|
"/restmachine/sdn/segment/create": segments.CreateRequest{},
|
||||||
|
|||||||
Reference in New Issue
Block a user