Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2c810504d | ||
|
|
b834e5d074 | ||
| e1f0d354af | |||
|
|
d149ba19fd | ||
| c17b6f2336 | |||
|
|
b1fbd6872d | ||
|
|
365a4991d2 | ||
| bb90a2d511 | |||
|
|
f111bf25fc |
97
CHANGELOG.md
97
CHANGELOG.md
@@ -1,9 +1,9 @@
|
||||
## Version 1.13.1
|
||||
## Version 1.14.1
|
||||
|
||||
Методы `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 и в следующих версиях будут удалены
|
||||
Методы `ComputeCISet`, `ComputeCIUnset`, `GetAudits` в cloudbroker/computeGetAudits и `GetAudits` в cloudbroker/compute стали deprecated и будут удалены в следующих версиях |
|
||||
Методы `ComputeCISet`, `ComputeCIUnset`, `GetAudits` в cloudbroker/compute и `GetAudits` в cloudapi/compute стали deprecated и будут удалены в следующих версиях
|
||||
Методы `ComputeCISet`, `ComputeCIUnset` в cloudbroker/image стали deprecated и будут удалены в следующих версиях
|
||||
|
||||
Все методы группы `.SDN()` находятся в альфа-версии.
|
||||
|
||||
@@ -11,61 +11,60 @@
|
||||
|
||||
#### account
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | ---|
|
||||
| BGOS-686 | Поле `Policies` в структуры ответа `LimitsRG` в cloudapi/account и `Limits` в cloudbroker/account |
|
||||
| --- | --- |
|
||||
| BGOS-780 | Вычисляемое поле `DeletedBy` в структуру ответа `ItemAccount` в cloudapi/account |
|
||||
|
||||
#### access groups
|
||||
#### compute
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-693 | Поле `OwnerDisplayName` в структуру запроса `ListGroupsRequest` и поле `Comment` в структуру ответа `AccessGroupItem` |
|
||||
| BGOS-777 | Структура ответа `RecordCloneAbort` в cloudbroker/compute |
|
||||
| BGOS-774 | Опциональное поле `Weight` в структуру запроса `UpdateRequest` в cloudbroker/compute |
|
||||
| BGOS-774 | Вычисляемое поле `Weight` в структуры ответа `InfoCompute` и `RecordCompute` в cloudbroker/compute и в структуры ответа `RecordCompute` и `ItemCompute` в cloudapi/compute |
|
||||
|
||||
#### backup
|
||||
#### kvmx86
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-688 | Опциональное поле `NodeID` в структуры запросов `RestoreDiskFromBackupRequest` и `RestoreDisksFromBackupRequest` в cloudbroker/backup |
|
||||
|
||||
#### node
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | ---|
|
||||
| BGOS-691 | Поле `UsableCPUs` в структурах ответа `RecordNode` и `ItemNode` в cloudbroker/node |
|
||||
|
||||
#### storage policy
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | ---|
|
||||
| BGOS-690 | Поле `SepTechStatus` в структуру `AccessSEPPool` в структуре ответа `ItemStoragePolicy` в cloudapi/stpolicy и в cloudbroker/stpolicy |
|
||||
|
||||
#### user
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | ---|
|
||||
| BGOS-692 | Поле `SortBy` в структуру запроса `GetAuditRequest` в cloudbroker/user |
|
||||
|
||||
### Изменено
|
||||
|
||||
#### user
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | ---|
|
||||
| BGOS-700 | Изменен тип поля `EmailAddress` с `[]string` на `string` в структуре запроса `CreateRequest` в cloudbroker/user |
|
||||
| BGOS-700 | Изменен тип возвращаемого значения метода `Create` с `bool` на `string` в cloudbroker/user |
|
||||
|
||||
### Удалено
|
||||
|
||||
#### account
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | ---|
|
||||
| BGOS-686 | Поле `CUNP` из структуры ответа `ResourceLimits` в cloudapi/account и cloudbroker/account |
|
||||
| BGOS-686 | Поле `ExtTraffic` из структур ответа `Resource` и `LimitsRG` в cloudapi/account и `Resource` и `Limits` в cloudbroker/account |
|
||||
|
||||
#### grid
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-686 | Поле `ExtTraffic` из структуры ответа `RecordResource` в cloudbroker/grid |
|
||||
| BGOS-775 | Опциональное поле `Weight` в структуры запроса `CreateRequest`, `CreateBlankRequest` и `MassCreateRequest` в cloudbroker/kvmx86 |
|
||||
|
||||
#### rg
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | ---|
|
||||
| BGOS-686 | Поле `ExtTraffic` из структур ответа `Resource` и `RecordResourceUsage` в cloudapi/rg и `Reservation` в cloudbroker/rg |
|
||||
| --- | --- |
|
||||
| BGOS-776 | Вычисляемое поле `Email` в структуры ответа `ItemACL` в cloudapi/rg и в `ACL` в cloudbroker/rg |
|
||||
| BGOS-779 | Опциональные поля `RGID` и `ComputeID` в структуру запроса `ListRequest` в cloudapi/rg и в cloudbroker/rg |
|
||||
|
||||
#### user
|
||||
#### stpolicy
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-686 | Поле `ExtTraffic` из структуры ответа `Resources` в cloudapi/user |
|
||||
| BGOS-784 | Вычисляемое поле `Usage` в структуру ответа `InfoStoragePolicyWithID` в cloudbroker/stpolicy |
|
||||
|
||||
|
||||
### Изменено
|
||||
|
||||
#### compute
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-777 | Тип возвращаемого значения метода `CloneAbort` с `bool` на `[]RecordCloneAbort` в cloudbroker/compute |
|
||||
|
||||
### Удалено
|
||||
|
||||
#### compute
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-781 | Опциональное поле `DiskType` из структур `DiskAddRequest` и `DiskAttachRequest` в cloudapi/compute и в cloudbroker/compute |
|
||||
| BGOS-785 | Вычисляемое поле `Type` из структур `ItemDisk`, `RecordDisk` и `ItemDiskUnattached` в cloudapi/compute и из структуры `InfoDisk` в cloudbroker/compute |
|
||||
|
||||
#### disks
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-781 | Структура запросов `ListTypesRequest`, структура ответов `ListTypes`, метод `ListTypes` в cloudapi/disks и в cloudbroker/disks |
|
||||
| BGOS-781 | Опциональное поле `Type` из структур `ListRequest`, `ListDeletedRequest` и `ListUnattachedRequest` в cloudapi/disks и в cloudbroker/disks |
|
||||
|
||||
#### kvmx86
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-773 | Опциональные поля `IS` и `IPAType` из структур запроса `CreateRequest` в cloudapi/kvmx86 и в cloudbroker/kvmx86 |
|
||||
|
||||
#### stpolicy
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-784 | Вычисляемое поле `StoragePolicyID` из структуры ответа `InfoStoragePolicyWithID` в cloudbroker/stpolicy |
|
||||
|
||||
11
README.md
11
README.md
@@ -18,6 +18,7 @@ Decort SDK - это библиотека, написанная на языке G
|
||||
- Версия 1.11.х Decort-SDK соответствует 4.3.0 версии платформы
|
||||
- Версия 1.12.х Decort-SDK соответствует 4.4.0 версии платформы
|
||||
- Версия 1.13.х Decort-SDK соответствует 4.5.0 версии платформы
|
||||
- Версия 1.14.х Decort-SDK соответствует 4.6.0 версии платформы
|
||||
|
||||
## Оглавление
|
||||
|
||||
@@ -466,16 +467,6 @@ type CreateRequest struct {
|
||||
// Node ID
|
||||
// Required: false
|
||||
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"`
|
||||
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ var FileName = map[string]string{
|
||||
var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"}
|
||||
|
||||
var VersionMap = map[string]string{
|
||||
"4.6.0": "-",
|
||||
"4.5.0": "-",
|
||||
"4.4.0": "-",
|
||||
"4.3.0": "-",
|
||||
|
||||
@@ -86,13 +86,6 @@ func computeModeValidator(fe validator.FieldLevel) bool {
|
||||
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.
|
||||
func computeNetTypeValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
@@ -151,13 +144,6 @@ func computeDataDisksValidator(fe validator.FieldLevel) bool {
|
||||
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.
|
||||
func flipgroupClientTypeValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
@@ -471,3 +457,10 @@ func addressPoolNetTypeValidator(fe validator.FieldLevel) bool {
|
||||
|
||||
return IsInSlice(fieldValue, addressPoolNetTypeValues)
|
||||
}
|
||||
|
||||
// sepTechStatusValidator is used to validate SepTechStatus fields
|
||||
func sepTechStatusValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
|
||||
return IsInSlice(fieldValue, sepTechStatusValues)
|
||||
}
|
||||
|
||||
@@ -86,12 +86,6 @@ func errorMessage(fe validator.FieldError) string {
|
||||
fe.Field(),
|
||||
joinValues(computeModeValues))
|
||||
|
||||
case "computeDiskType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(computeDiskTypeValues))
|
||||
|
||||
case "mtu":
|
||||
return fmt.Sprint(prefix, fe.Field(), "must be ", mtuMin, "-", mtuMax)
|
||||
|
||||
@@ -122,13 +116,6 @@ func errorMessage(fe validator.FieldError) string {
|
||||
fe.Field(),
|
||||
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
|
||||
case "flipgroupClientType":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
@@ -366,6 +353,12 @@ func errorMessage(fe validator.FieldError) string {
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(ipTypeValues))
|
||||
|
||||
case "sepTechStatus":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(sepTechStatusValues))
|
||||
}
|
||||
|
||||
return fe.Error()
|
||||
|
||||
@@ -86,11 +86,6 @@ func registerAllValidators(validate *validator.Validate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("computeDiskType", computeDiskTypeValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("computeNetType", computeNetTypeValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -111,11 +106,6 @@ func registerAllValidators(validate *validator.Validate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("diskType", diskTypeValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("flipgroupClientType", flipgroupClientTypeValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -311,5 +301,10 @@ func registerAllValidators(validate *validator.Validate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("sepTechStatus", sepTechStatusValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,14 +14,11 @@ var (
|
||||
computeTopologyValues = []string{"compute", "node"}
|
||||
computePolicyValues = []string{"RECOMMENDED", "REQUIRED"}
|
||||
computeModeValues = []string{"EQ", "EN", "ANY"}
|
||||
computeDiskTypeValues = []string{"D", "B"}
|
||||
computeNetTypeValues = []string{"EXTNET", "VINS"}
|
||||
computex86NetTypeValues = []string{"EXTNET", "VINS", "VFNIC", "DPDK", "SDN", "EMPTY", "TRUNK"}
|
||||
computeOrderValues = []string{"cdrom", "network", "hd"}
|
||||
computeDataDisksValues = []string{"KEEP", "DETACH", "DESTROY"}
|
||||
|
||||
diskTypeValues = []string{"B", "T", "D"}
|
||||
|
||||
flipgroupClientTypeValues = []string{"compute", "vins"}
|
||||
|
||||
massCreateNetTypeValues = []string{"EXTNET", "VINS", "TRUNK"}
|
||||
@@ -66,7 +63,7 @@ var (
|
||||
|
||||
loaderTypeValues = []string{"linux", "windows", "unknown"}
|
||||
|
||||
sepTypeValues = []string{"hitachi", "dorado", "tatlin", "shared", "local", "des"}
|
||||
sepTypeValues = []string{"hitachi", "dorado", "tatlin", "shared", "local", "des", "ustor"}
|
||||
|
||||
languageValues = []string{"ru", "en"}
|
||||
|
||||
@@ -81,6 +78,8 @@ var (
|
||||
addressPoolNetTypeValues = []string{"IPv4", "IPv6", "MAC"}
|
||||
|
||||
ipTypeValues = []string{"v4, v6"}
|
||||
|
||||
sepTechStatusValues = []string{"ENABLED", "DISABLED"}
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -95,6 +95,9 @@ type ItemAccount struct {
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// Deleted by
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
|
||||
// Description
|
||||
Description string `json:"desc"`
|
||||
|
||||
@@ -299,6 +302,9 @@ type RecordAccount struct {
|
||||
// UniqPools
|
||||
UniqPools []interface{} `json:"uniqPools"`
|
||||
|
||||
// Updated By
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
|
||||
@@ -38,10 +38,6 @@ type GroupAddRequest struct {
|
||||
// Required: true
|
||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
||||
|
||||
// Compute driver like a KVM_X86, etc.
|
||||
// Required: true
|
||||
Driver string `url:"driver" json:"driver" validate:"required"`
|
||||
|
||||
// Storage endpoint provider ID
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
@@ -25,15 +25,15 @@ type GroupResizeRequest struct {
|
||||
// Chipset for new computes, either i440fx or Q35 (i440fx by default)
|
||||
// Available values : i440fx, Q35
|
||||
// Default value : Q35
|
||||
// Required: true
|
||||
Chipset string `url:"chipset" json:"chipset" validate:"required,chipset"`
|
||||
// Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
|
||||
// Either delta or absolute value of computes
|
||||
// Should be one of:
|
||||
// - ABSOLUTE
|
||||
// - RELATIVE
|
||||
// Required: true
|
||||
Mode string `url:"mode" json:"mode" validate:"bserviceMode"`
|
||||
// Required: false
|
||||
Mode string `url:"mode,omitempty" json:"mode,omitempty" validate:"omitempty,bserviceMode"`
|
||||
}
|
||||
|
||||
// GroupResize resize the group by changing the number of computes
|
||||
|
||||
@@ -38,9 +38,8 @@ type AffinityRuleAddRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
}
|
||||
|
||||
// AffinityRuleAdd add affinity rule
|
||||
|
||||
@@ -38,9 +38,8 @@ type AffinityRuleRemoveRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
}
|
||||
|
||||
// AffinityRuleRemove remove affinity rule
|
||||
|
||||
@@ -38,9 +38,8 @@ type AntiAffinityRuleAddRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
}
|
||||
|
||||
// AntiAffinityRuleAdd add anti affinity rule
|
||||
|
||||
@@ -38,9 +38,8 @@ type AntiAffinityRuleRemoveRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
}
|
||||
|
||||
// AntiAffinityRuleRemove remove anti affinity rule
|
||||
|
||||
@@ -26,13 +26,6 @@ type DiskAddRequest struct {
|
||||
// Required: true
|
||||
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
|
||||
// By default the same with boot disk
|
||||
// Required: false
|
||||
|
||||
@@ -18,10 +18,6 @@ type DiskAttachRequest struct {
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
|
||||
// Type of the disk B;D
|
||||
// Required: false
|
||||
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty" validate:"omitempty,computeDiskType"`
|
||||
|
||||
// Desired PCI slot (hex string, e.g. "0x1A")
|
||||
// Required: false
|
||||
PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"`
|
||||
|
||||
@@ -545,6 +545,9 @@ type RecordCompute struct {
|
||||
// VNC password
|
||||
VNCPassword string `json:"vncPasswd"`
|
||||
|
||||
// Weight
|
||||
Weight uint64 `json:"weight"`
|
||||
|
||||
// Zone ID
|
||||
// Required: false
|
||||
ZoneID uint64 `json:"zoneId"`
|
||||
@@ -789,12 +792,21 @@ type ItemComputeDisk struct {
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
// BLK Discard
|
||||
BLKDiscard bool `json:"blkdiscard"`
|
||||
|
||||
// Block Size
|
||||
BlockSize string `json:"block_size"`
|
||||
|
||||
// Boot partition
|
||||
BootPartition uint64 `json:"bootPartition"`
|
||||
|
||||
// Bus number
|
||||
BusNumber uint64 `json:"bus_number"`
|
||||
|
||||
// Chache
|
||||
Cache string `json:"cache"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
@@ -1226,6 +1238,9 @@ type ItemCompute struct {
|
||||
// VINS connected
|
||||
VINSConnected uint64 `json:"vinsConnected"`
|
||||
|
||||
// Weight
|
||||
Weight uint64 `json:"weight"`
|
||||
|
||||
// Zone ID
|
||||
ZoneID uint64 `json:"zoneId"`
|
||||
}
|
||||
@@ -1237,6 +1252,9 @@ type ListInfoDisks []InfoDisk
|
||||
type InfoDisk struct {
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// SEP ID
|
||||
SepID int64 `json:"sepId"`
|
||||
}
|
||||
|
||||
// List information about computes
|
||||
|
||||
@@ -20,7 +20,7 @@ type NetAttachRequest struct {
|
||||
// 'VFNIC' for connect to vfpool
|
||||
// 'DPDK' for connect to DPDK
|
||||
// `EMPTY` for connect empty network
|
||||
// `SDT` for connect to SDN
|
||||
// `SDN` for connect to SDN
|
||||
// `TRUNK` for connect to TRUNK
|
||||
// Required: true
|
||||
NetType string `url:"netType" json:"netType" validate:"computex86NetType"`
|
||||
@@ -45,6 +45,27 @@ type NetAttachRequest struct {
|
||||
// Required: false
|
||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||
|
||||
// Net mask
|
||||
// Used only to DPDK or VFNIC net type
|
||||
// Required: false
|
||||
NetMask uint64 `url:"netMask,omitempty" json:"netMask,omitempty"`
|
||||
|
||||
// SDN Segment ID
|
||||
// Required: false
|
||||
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
||||
|
||||
// SDN Object Group ID
|
||||
// Required: false
|
||||
SDNObjectGroupID string `url:"sdn_object_group_id,omitempty" json:"sdn_object_group_id,omitempty"`
|
||||
|
||||
// SDN Logical Port Display Name
|
||||
// Required: false
|
||||
SDNLogicalPortDisplayName string `url:"sdn_logical_port_display_name,omitempty" json:"sdn_logical_port_display_name,omitempty"`
|
||||
|
||||
// SDN Logical Port Description
|
||||
// Required: false
|
||||
SDNLogicalPortDescription string `url:"sdn_logical_port_description,omitempty" json:"sdn_logical_port_description,omitempty"`
|
||||
|
||||
// Unique identifier of logical port on SDN side
|
||||
// Required: false
|
||||
SDNInterfaceID string `url:"sdn_interface_id,omitempty" json:"sdn_interface_id,omitempty" validate:"omitempty"`
|
||||
|
||||
@@ -48,7 +48,6 @@ var disks = ListDisks{
|
||||
Snapshots: []ItemSnapshot{},
|
||||
Status: "ASSIGNED",
|
||||
TechStatus: techStatusAllocated,
|
||||
Type: "B",
|
||||
VMID: 48500,
|
||||
},
|
||||
{
|
||||
@@ -92,7 +91,6 @@ var disks = ListDisks{
|
||||
Snapshots: []ItemSnapshot{},
|
||||
Status: "ASSIGNED",
|
||||
TechStatus: techStatusAllocated,
|
||||
Type: "B",
|
||||
VMID: 48502,
|
||||
},
|
||||
},
|
||||
@@ -224,7 +222,6 @@ var searchDisks = ListSearchDisks{
|
||||
Snapshots: []ItemSnapshot{},
|
||||
Status: "ASSIGNED",
|
||||
TechStatus: techStatusAllocated,
|
||||
Type: "B",
|
||||
VMID: 48500,
|
||||
},
|
||||
ItemDisk{
|
||||
@@ -268,7 +265,6 @@ var searchDisks = ListSearchDisks{
|
||||
Snapshots: []ItemSnapshot{},
|
||||
Status: "ASSIGNED",
|
||||
TechStatus: techStatusAllocated,
|
||||
Type: "B",
|
||||
VMID: 48502,
|
||||
},
|
||||
}
|
||||
@@ -360,7 +356,6 @@ func TestListSearchDisks_SortByCreatedTime(t *testing.T) {
|
||||
var unattachedDisks = ListDisksUnattached{
|
||||
Data: []ItemDiskUnattached{
|
||||
{
|
||||
CKey: "",
|
||||
Meta: []interface{}{
|
||||
"cloudbroker",
|
||||
"disk",
|
||||
@@ -412,7 +407,6 @@ var unattachedDisks = ListDisksUnattached{
|
||||
VMID: 0,
|
||||
},
|
||||
{
|
||||
CKey: "",
|
||||
Meta: []interface{}{
|
||||
"cloudbroker",
|
||||
"disk",
|
||||
|
||||
@@ -38,10 +38,6 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
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
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
@@ -65,6 +61,14 @@ type ListRequest struct {
|
||||
// Page size
|
||||
// Required: false
|
||||
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
|
||||
|
||||
@@ -34,10 +34,6 @@ type ListDeletedRequest struct {
|
||||
// Required: false
|
||||
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)
|
||||
// Required: false
|
||||
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
|
||||
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
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
@@ -11,6 +11,12 @@ type ItemDisk struct {
|
||||
// Account name
|
||||
AccountName string `json:"accountName"`
|
||||
|
||||
// BLK Discard
|
||||
BLKDiscard bool `json:"blkdiscard"`
|
||||
|
||||
// Block size of disk
|
||||
BlockSize string `json:"block_size"`
|
||||
|
||||
// Computes
|
||||
Computes map[string]string `json:"computes"`
|
||||
|
||||
@@ -128,9 +134,6 @@ type ItemDisk struct {
|
||||
// Need to clean before destroy
|
||||
ToClean bool `json:"to_clean"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// Virtual machine ID
|
||||
VMID uint64 `json:"vmid"`
|
||||
|
||||
@@ -139,12 +142,12 @@ type ItemDisk struct {
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Cache mode of disk
|
||||
Cache string `json:"cache"`
|
||||
}
|
||||
|
||||
type ItemDiskUnattached struct {
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
|
||||
// Meta
|
||||
Meta []interface{} `json:"_meta"`
|
||||
|
||||
@@ -157,9 +160,18 @@ type ItemDiskUnattached struct {
|
||||
// Access Control List
|
||||
ACL map[string]interface{} `json:"acl"`
|
||||
|
||||
// BLK Discard
|
||||
BLKDiscard bool `json:"blkdiscard"`
|
||||
|
||||
// Block size of disk
|
||||
BlockSize string `json:"block_size"`
|
||||
|
||||
// Boot Partition
|
||||
BootPartition uint64 `json:"bootPartition"`
|
||||
|
||||
// Cache
|
||||
Cache string `json:"cache"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
@@ -268,9 +280,6 @@ type ItemDiskUnattached struct {
|
||||
// Tech status
|
||||
TechStatus string `json:"techStatus"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// Virtual machine ID
|
||||
VMID uint64 `json:"vmid"`
|
||||
}
|
||||
@@ -375,6 +384,12 @@ type RecordDisk struct {
|
||||
// Account name
|
||||
AccountName string `json:"accountName"`
|
||||
|
||||
// BLK Discard
|
||||
BLKDiscard bool `json:"blkdiscard"`
|
||||
|
||||
// Block size of disk
|
||||
BlockSize string `json:"block_size"`
|
||||
|
||||
// Computes
|
||||
Computes map[string]string `json:"computes"`
|
||||
|
||||
@@ -492,9 +507,6 @@ type RecordDisk struct {
|
||||
// Need to clean before destroy
|
||||
ToClean bool `json:"to_clean"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// Virtual machine ID
|
||||
VMID uint64 `json:"vmid"`
|
||||
|
||||
@@ -503,6 +515,9 @@ type RecordDisk struct {
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Cache mode of disk
|
||||
Cache string `json:"cache"`
|
||||
}
|
||||
|
||||
type ItemReplication struct {
|
||||
@@ -524,11 +539,3 @@ type ItemReplication struct {
|
||||
// VolumeID
|
||||
VolumeID string `json:"volumeId"`
|
||||
}
|
||||
|
||||
type ListTypes struct {
|
||||
// Data
|
||||
Data []interface{} `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
@@ -34,10 +34,6 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
AccountId uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// Find by resource group ID
|
||||
// Required: false
|
||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||
|
||||
// Find by id
|
||||
// Required: false
|
||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||
|
||||
@@ -85,12 +85,6 @@ type RecordFLIPGroup struct {
|
||||
// Network
|
||||
Network string `json:"network"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// Resource group name
|
||||
RGName string `json:"rgName"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
|
||||
@@ -92,9 +92,6 @@ type RecordImage struct {
|
||||
// UNCPathj
|
||||
UNCPath string `json:"UNCPath"`
|
||||
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
|
||||
@@ -35,10 +35,31 @@ type Interface struct {
|
||||
// Required: false
|
||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||
|
||||
// Net mask
|
||||
// Used only to DPDK or VFNIC net type
|
||||
// Required: false
|
||||
NetMask uint64 `url:"netMask,omitempty" json:"netMask,omitempty"`
|
||||
|
||||
// MAC address to assign to this VM when connecting to the specified network
|
||||
// Required: false
|
||||
MAC string `url:"mac,omitempty" json:"mac,omitempty" validate:"omitempty"`
|
||||
|
||||
// SDN Segment ID
|
||||
// Required: false
|
||||
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
||||
|
||||
// SDN Object Group ID
|
||||
// Required: false
|
||||
SDNObjectGroupID string `url:"sdn_object_group_id,omitempty" json:"sdn_object_group_id,omitempty"`
|
||||
|
||||
// SDN Logical Port Display Name
|
||||
// Required: false
|
||||
SDNLogicalPortDisplayName string `url:"sdn_logical_port_display_name,omitempty" json:"sdn_logical_port_display_name,omitempty"`
|
||||
|
||||
// SDN Logical Port Description
|
||||
// Required: false
|
||||
SDNLogicalPortDescription string `url:"sdn_logical_port_description,omitempty" json:"sdn_logical_port_description,omitempty"`
|
||||
|
||||
// SDN interface id
|
||||
// Required: false
|
||||
SDNInterfaceID string `url:"sdn_interface_id,omitempty" json:"sdn_interface_id,omitempty"`
|
||||
@@ -162,14 +183,6 @@ type CreateRequest struct {
|
||||
// Required: false
|
||||
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
|
||||
// Required: false
|
||||
CustomFields string `url:"customFields,omitempty" json:"customFields,omitempty"`
|
||||
|
||||
@@ -38,8 +38,8 @@ type CreateRequest struct {
|
||||
HighlyAvailable bool `url:"highlyAvailable,omitempty" json:"highlyAvailable,omitempty"`
|
||||
|
||||
// Start now Load balancer
|
||||
// Required: true
|
||||
Start bool `url:"start" json:"start" validate:"required"`
|
||||
// Required: false
|
||||
Start interface{} `url:"start,omitempty" json:"start,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Text description of this load balancer
|
||||
// Required: false
|
||||
|
||||
@@ -267,6 +267,9 @@ type ListResourceGroups struct {
|
||||
|
||||
// Main information about Access Control List
|
||||
type ItemACL struct {
|
||||
// Email
|
||||
Email string `json:"email"`
|
||||
|
||||
// Explicit
|
||||
Explicit bool `json:"explicit"`
|
||||
|
||||
|
||||
@@ -56,6 +56,10 @@ type ListRequest struct {
|
||||
// Search by pool name
|
||||
// Required: false
|
||||
PoolName string `url:"pool_name,omitempty" json:"pool_name,omitempty"`
|
||||
|
||||
// Filter SEP's by tech status (ENABLED, DISABLED)
|
||||
// Required: false
|
||||
SepTechStatus string `url:"sep_tech_status,omitempty" json:"sep_tech_status,omitempty" validate:"omitempty,sepTechStatus"`
|
||||
}
|
||||
|
||||
// List gets list of storage policies as a ListStoragePolicies struct
|
||||
|
||||
@@ -29,6 +29,9 @@ type ItemTrunk struct {
|
||||
// MAC
|
||||
MAC string `json:"mac"`
|
||||
|
||||
// MTU
|
||||
MTU uint64 `json:"mtu"`
|
||||
|
||||
// Name of a trunk
|
||||
Name string `json:"name"`
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@ type ListZones struct {
|
||||
|
||||
// Detailed information about the zone record
|
||||
type RecordZone struct {
|
||||
// If true, all nodes belonging to the given zone will be marked for autostart
|
||||
AutoStart bool `json:"autostart"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
|
||||
@@ -215,6 +215,9 @@ type InfoAccount struct {
|
||||
// UniqPools
|
||||
UniqPools []string `json:"uniqPools"`
|
||||
|
||||
// Updated By
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// UpdatedTime
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
|
||||
@@ -95,6 +95,15 @@ type RecordAudit struct {
|
||||
|
||||
// TTL
|
||||
TTL string `json:"_ttl"`
|
||||
|
||||
// Resgroup ID
|
||||
ResgroupID uint64 `json:"resgroup_id"`
|
||||
|
||||
// Account ID
|
||||
AccountID uint64 `json:"account_id"`
|
||||
|
||||
// Compute ID
|
||||
ComputeID uint64 `json:"compute_id"`
|
||||
}
|
||||
|
||||
// List of Linked Jobs
|
||||
|
||||
@@ -38,10 +38,6 @@ type GroupAddRequest struct {
|
||||
// Required: true
|
||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
||||
|
||||
// Compute driver like a KVM_X86, etc.
|
||||
// Required: true
|
||||
Driver string `url:"driver" json:"driver" validate:"required"`
|
||||
|
||||
// Storage endpoint provider ID
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
@@ -22,18 +22,18 @@ type GroupResizeRequest struct {
|
||||
// Required: true
|
||||
Count int64 `url:"count" json:"count" validate:"required"`
|
||||
|
||||
//Chipset for new computes, either i440fx or Q35 (i440fx by default)
|
||||
//Available values : i440fx, Q35
|
||||
//Default value : Q35
|
||||
//Required: true
|
||||
Chipset string `url:"chipset" json:"chipset" validate:"required,chipset"`
|
||||
// Chipset for new computes, either i440fx or Q35 (i440fx by default)
|
||||
// Available values : i440fx, Q35
|
||||
// Default value : Q35
|
||||
// Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"`
|
||||
|
||||
// Either delta or absolute value of computes
|
||||
// Should be one of:
|
||||
// - ABSOLUTE
|
||||
// - RELATIVE
|
||||
// Required: true
|
||||
Mode string `url:"mode" json:"mode" validate:"bserviceMode"`
|
||||
// Required: false
|
||||
Mode string `url:"mode,omitempty" json:"mode,omitempty" validate:"omitempty,bserviceMode"`
|
||||
}
|
||||
|
||||
// GroupResize resize the group by changing the number of computes
|
||||
|
||||
@@ -40,9 +40,8 @@ type AffinityRuleAddRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
}
|
||||
|
||||
// AffinityRuleAdd adds affinity rule
|
||||
|
||||
@@ -38,9 +38,8 @@ type AffinityRuleRemoveRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
}
|
||||
|
||||
// AffinityRuleRemove remove affinity rule
|
||||
|
||||
@@ -38,9 +38,8 @@ type AntiAffinityRuleAddRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
}
|
||||
|
||||
// AntiAffinityRuleAdd adds anti affinity rule
|
||||
|
||||
@@ -38,9 +38,8 @@ type AntiAffinityRuleRemoveRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
}
|
||||
|
||||
// AntiAffinityRuleRemove removes anti affinity rule
|
||||
|
||||
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 (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
@@ -17,22 +17,24 @@ type CloneAbortRequest struct {
|
||||
}
|
||||
|
||||
// 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)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/clone_abort"
|
||||
|
||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
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 {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
type GetCloneStatusRequest struct {
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||
ComputeID string `url:"compute_id" json:"compute_id" validate:"required"`
|
||||
}
|
||||
|
||||
// GetCloneStatus gets information about compute clone status as a RecordCloneStatus struct
|
||||
|
||||
@@ -31,13 +31,6 @@ type DiskAddRequest struct {
|
||||
// Required: true
|
||||
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
|
||||
// By default will be chosen automatically
|
||||
// Required: false
|
||||
@@ -58,6 +51,14 @@ type DiskAddRequest struct {
|
||||
// Desired bus number (hex string, e.g. "0x03")
|
||||
// Required: false
|
||||
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
|
||||
|
||||
// Disk cache mode
|
||||
// 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"`
|
||||
}
|
||||
|
||||
// DiskAdd creates new disk and attach to compute
|
||||
|
||||
@@ -18,10 +18,6 @@ type DiskAttachRequest struct {
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
|
||||
// Type of the disk B;D
|
||||
// Required: false
|
||||
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty"`
|
||||
|
||||
// Desired PCI slot (hex string, e.g. "0x1A")
|
||||
// Required: false
|
||||
PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"`
|
||||
|
||||
@@ -391,12 +391,21 @@ type ItemDisk struct {
|
||||
// Access Control List
|
||||
ACL ItemACL `json:"acl"`
|
||||
|
||||
// BLK Discard
|
||||
BLKDiscard bool `json:"blkdiscard"`
|
||||
|
||||
// Block Size
|
||||
BlockSize string `json:"block_size"`
|
||||
|
||||
// Boot partition
|
||||
BootPartition uint64 `json:"bootPartition"`
|
||||
|
||||
// Bus number
|
||||
BusNumber uint64 `json:"bus_number"`
|
||||
|
||||
// Chache
|
||||
Cache string `json:"cache"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
@@ -841,7 +850,7 @@ type InfoCompute struct {
|
||||
SnapSets ListSnapshots `json:"snapSets"`
|
||||
|
||||
// Node ID
|
||||
NodeID uint64 `json:"nodeId"`
|
||||
NodeID uint64 `json:"node_id"`
|
||||
|
||||
// Node name
|
||||
NodeName string `json:"nodeName"`
|
||||
@@ -882,6 +891,9 @@ type InfoCompute struct {
|
||||
// VINS connected
|
||||
VINSConnected uint64 `json:"vinsConnected"`
|
||||
|
||||
// Weight
|
||||
Weight uint64 `json:"weight"`
|
||||
|
||||
// Zone ID
|
||||
ZoneID uint64 `json:"zoneId"`
|
||||
}
|
||||
@@ -1169,8 +1181,14 @@ type RecordCompute struct {
|
||||
// VNC password
|
||||
VNCPassword string `json:"vncPasswd"`
|
||||
|
||||
// Weight
|
||||
Weight uint64 `json:"weight"`
|
||||
|
||||
// Zone ID
|
||||
ZoneID uint64 `json:"zoneId"`
|
||||
|
||||
//todo
|
||||
_ uint64 `json:"nodeId"`
|
||||
}
|
||||
|
||||
type LoaderMetaIso struct {
|
||||
@@ -1280,6 +1298,9 @@ type ItemDeletedCompute struct {
|
||||
type InfoDisk struct {
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// SEP ID
|
||||
SepID int64 `json:"sepId"`
|
||||
}
|
||||
|
||||
// List computes
|
||||
@@ -1454,6 +1475,14 @@ type MigrateStorageItem struct {
|
||||
TargetNodeID uint64 `json:"targetNodeId"`
|
||||
}
|
||||
|
||||
type RecordCloneAbort struct {
|
||||
// Disk ID
|
||||
DiskID uint64 `json:"disk_id"`
|
||||
|
||||
// Abort status
|
||||
Status bool `json:"status"`
|
||||
}
|
||||
|
||||
type RecordCloneStatus struct {
|
||||
// Disk ID
|
||||
DiskID int `json:"disk_id"`
|
||||
@@ -1481,3 +1510,20 @@ type CloneStatus struct {
|
||||
// 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[string]CheckComputePlacementItem
|
||||
|
||||
@@ -20,7 +20,7 @@ type NetAttachRequest struct {
|
||||
// 'VFNIC' for connect to vfpool
|
||||
// 'DPDK' for connect to DPDK
|
||||
// `EMPTY` for connect empty network
|
||||
// `SDT` for connect to SDN
|
||||
// `SDN` for connect to SDN
|
||||
// `TRUNK` for connect to TRUNK
|
||||
// Required: true
|
||||
NetType string `url:"netType" json:"netType" validate:"computex86NetType"`
|
||||
@@ -45,6 +45,27 @@ type NetAttachRequest struct {
|
||||
// Required: false
|
||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
|
||||
|
||||
// Net mask
|
||||
// Used only to DPDK or VFNIC net type
|
||||
// Required: false
|
||||
NetMask uint64 `url:"netMask,omitempty" json:"netMask,omitempty"`
|
||||
|
||||
// SDN Segment ID
|
||||
// Required: false
|
||||
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
||||
|
||||
// SDN Object Group ID
|
||||
// Required: false
|
||||
SDNObjectGroupID string `url:"sdn_object_group_id,omitempty" json:"sdn_object_group_id,omitempty"`
|
||||
|
||||
// SDN Logical Port Display Name
|
||||
// Required: false
|
||||
SDNLogicalPortDisplayName string `url:"sdn_logical_port_display_name,omitempty" json:"sdn_logical_port_display_name,omitempty"`
|
||||
|
||||
// SDN Logical Port Description
|
||||
// Required: false
|
||||
SDNLogicalPortDescription string `url:"sdn_logical_port_description,omitempty" json:"sdn_logical_port_description,omitempty"`
|
||||
|
||||
// Unique identifier of logical port on SDN side
|
||||
// Required: false
|
||||
SDNInterfaceID string `url:"sdn_interface_id,omitempty" json:"sdn_interface_id,omitempty" validate:"omitempty"`
|
||||
|
||||
@@ -20,7 +20,7 @@ type StartRequest struct {
|
||||
|
||||
// ID of node to start compute
|
||||
// Required: false
|
||||
NodeID uint64 `url:"nodeId,omitempty" json:"nodeId,omitempty"`
|
||||
NodeID uint64 `url:"node_id,omitempty" json:"node_id,omitempty"`
|
||||
}
|
||||
|
||||
// Start starts compute
|
||||
|
||||
@@ -33,7 +33,11 @@ type StartMigrationOutRequest struct {
|
||||
|
||||
// Mapping of guest disk target names to absolute paths on the destination host.
|
||||
// Required: false
|
||||
Diskmap map[string]string `url:"diskmap,omitempty" json:"diskmap,omitempty"`
|
||||
DiskMap map[string]string `url:"diskmap,omitempty" json:"diskmap,omitempty"`
|
||||
|
||||
// Mapping of network interfaces
|
||||
// Required: false
|
||||
NetMap map[string]string `url:"netmap,omitempty" json:"netmap,omitempty"`
|
||||
|
||||
// Mapping for CD/DVD devices or their source paths to new ISO/device paths on the destination
|
||||
// Required: false
|
||||
|
||||
@@ -69,6 +69,10 @@ type UpdateRequest struct {
|
||||
// The OS version that will be installed on the virtual machine
|
||||
// Required: false
|
||||
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
|
||||
|
||||
@@ -37,6 +37,14 @@ type CreateRequest struct {
|
||||
// Pool name to create disk
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// Cache mode of 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"`
|
||||
}
|
||||
|
||||
// Create creates a disk
|
||||
|
||||
@@ -59,7 +59,6 @@ var disks = ListDisks{
|
||||
Snapshots: []ItemSnapshot{},
|
||||
Status: "ASSIGNED",
|
||||
TechStatus: "ALLOCATED",
|
||||
Type: "B",
|
||||
VMID: 48500,
|
||||
},
|
||||
},
|
||||
@@ -120,7 +119,6 @@ var disks = ListDisks{
|
||||
Snapshots: []ItemSnapshot{},
|
||||
Status: "ASSIGNED",
|
||||
TechStatus: "ALLOCATED",
|
||||
Type: "B",
|
||||
VMID: 48502,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -38,10 +38,6 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
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
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
@@ -65,6 +61,14 @@ type ListRequest struct {
|
||||
// Page size
|
||||
// Required: false
|
||||
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
|
||||
|
||||
@@ -34,10 +34,6 @@ type ListDeletedRequest struct {
|
||||
// Required: false
|
||||
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)
|
||||
// Required: false
|
||||
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
|
||||
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
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
@@ -53,6 +53,12 @@ type InfoDisk struct {
|
||||
// Access Control Control
|
||||
ACL map[string]interface{} `json:"acl"`
|
||||
|
||||
// BLK Discard
|
||||
BLKDiscard bool `json:"blkdiscard"`
|
||||
|
||||
// Block size of disk
|
||||
BlockSize string `json:"block_size"`
|
||||
|
||||
// Boot partition
|
||||
BootPartition uint64 `json:"bootPartition"`
|
||||
|
||||
@@ -179,14 +185,14 @@ type InfoDisk struct {
|
||||
// Need to clean before destroy
|
||||
ToClean bool `json:"to_clean"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// Virtual machine ID
|
||||
VMID uint64 `json:"vmid"`
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Cache mode of disk
|
||||
Cache string `json:"cache"`
|
||||
}
|
||||
|
||||
type ItemReplication struct {
|
||||
@@ -212,6 +218,9 @@ type ItemReplication struct {
|
||||
// Detailed indormation about disk
|
||||
type RecordDisk struct {
|
||||
|
||||
// Block size of disk
|
||||
BlockSize string `json:"block_size"`
|
||||
|
||||
//Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
@@ -261,9 +270,6 @@ type SearchListDisks []ItemDisk
|
||||
|
||||
// Main information about unattached disk
|
||||
type ItemUnattachedDisk struct {
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
|
||||
// Meta
|
||||
Meta []interface{} `json:"_meta"`
|
||||
|
||||
@@ -313,14 +319,6 @@ type ItemSnapshot struct {
|
||||
// List snapshots
|
||||
type ListSnapshots []ItemSnapshot
|
||||
|
||||
type ListTypes struct {
|
||||
// Data
|
||||
Data []interface{} `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
type MigrateStatus struct {
|
||||
// Type
|
||||
Type int `json:"type"`
|
||||
|
||||
50
pkg/cloudbroker/disks/update.go
Normal file
50
pkg/cloudbroker/disks/update.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// UpdateRequest struct to update disk
|
||||
type UpdateRequest struct {
|
||||
// ID of the disk to update
|
||||
// Required: true
|
||||
DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"`
|
||||
|
||||
// Cache mode of 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"`
|
||||
|
||||
// Block size of disk
|
||||
// Required: false
|
||||
BlockSize string `url:"block_size,omitempty" json:"block_size,omitempty"`
|
||||
}
|
||||
|
||||
// Update updates disk
|
||||
func (d Disks) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/update"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -34,10 +34,6 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
AccountId uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// Find by resource group ID
|
||||
// Required: false
|
||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||
|
||||
// Find by id
|
||||
// Required: false
|
||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||
|
||||
@@ -85,12 +85,6 @@ type RecordFLIPGroup struct {
|
||||
// Network
|
||||
Network string `json:"network"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// Resource group name
|
||||
RGName string `json:"rgName"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ type PurgeLogsRequest struct {
|
||||
GID uint64 `url:"gid" json:"gid" validate:"required"`
|
||||
|
||||
// Age of the records to remove, e.g. -1h for records older than 1 hour, -1w - one week, etc
|
||||
// Required: true
|
||||
Age string `url:"age" json:"age" validate:"required"`
|
||||
// Required: false
|
||||
Age string `url:"age,omitempty" json:"age,omitempty"`
|
||||
}
|
||||
|
||||
// PurgeLogs clear Log and ECO records that are older than the specified age.
|
||||
|
||||
@@ -37,6 +37,11 @@ type Interface struct {
|
||||
// Required: false
|
||||
MAC string `url:"mac,omitempty" json:"mac,omitempty" validate:"omitempty"`
|
||||
|
||||
// Net mask
|
||||
// Used only to DPDK or VFNIC net type
|
||||
// Required: false
|
||||
NetMask uint64 `url:"netMask,omitempty" json:"netMask,omitempty"`
|
||||
|
||||
// SDN interface id
|
||||
// Required: false
|
||||
SDNInterfaceID string `url:"sdn_interface_id,omitempty" json:"sdn_interface_id,omitempty"`
|
||||
@@ -52,6 +57,22 @@ type Interface struct {
|
||||
// Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK)
|
||||
// Required: false
|
||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// SDN Segment ID
|
||||
// Required: false
|
||||
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
||||
|
||||
// SDN Object Group ID
|
||||
// Required: false
|
||||
SDNObjectGroupID string `url:"sdn_object_group_id,omitempty" json:"sdn_object_group_id,omitempty"`
|
||||
|
||||
// SDN Logical Port Display Name
|
||||
// Required: false
|
||||
SDNLogicalPortDisplayName string `url:"sdn_logical_port_display_name,omitempty" json:"sdn_logical_port_display_name,omitempty"`
|
||||
|
||||
// SDN Logical Port Description
|
||||
// Required: false
|
||||
SDNLogicalPortDescription string `url:"sdn_logical_port_description,omitempty" json:"sdn_logical_port_description,omitempty"`
|
||||
}
|
||||
|
||||
// DataDisk detailed struct for DataDisks field in CreateRequest, CreateBlankRequest and MassCreateRequest
|
||||
@@ -85,6 +106,14 @@ type DataDisk struct {
|
||||
// Specify image id for create disk from template
|
||||
// Required: false
|
||||
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
|
||||
@@ -164,14 +193,6 @@ type CreateRequest struct {
|
||||
// Required: false
|
||||
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
|
||||
// Required: false
|
||||
CustomField string `url:"customFields,omitempty" json:"customFields,omitempty"`
|
||||
@@ -206,6 +227,19 @@ type CreateRequest struct {
|
||||
// Zone ID
|
||||
// Required: false
|
||||
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"`
|
||||
|
||||
// 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
|
||||
|
||||
@@ -115,6 +115,19 @@ type CreateBlankRequest struct {
|
||||
// The OS version that will be installed on the virtual machine
|
||||
// Required: false
|
||||
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"`
|
||||
|
||||
// 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
|
||||
|
||||
@@ -14,9 +14,13 @@ type InterfaceMassCreate struct {
|
||||
// - VINS
|
||||
// - EXTNET
|
||||
// - TRUNK
|
||||
// - SDN
|
||||
// For SDN, one of the fields sdn_interface_id or sdn_segment_id is specified, but not both at the same time
|
||||
// Required: false
|
||||
NetType string `url:"netType" json:"netType" validate:"required,massCreateNetType"`
|
||||
|
||||
// Network ID for connect
|
||||
// Required: false
|
||||
NetID uint64 `url:"netId" json:"netId" validate:"required"`
|
||||
|
||||
// IP address to assign to this VM when connecting to the specified network
|
||||
@@ -47,6 +51,22 @@ type InterfaceMassCreate struct {
|
||||
// Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK)
|
||||
// Required: false
|
||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// SDN Segment ID
|
||||
// Required: false
|
||||
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
||||
|
||||
// SDN Object Group ID
|
||||
// Required: false
|
||||
SDNObjectGroupID string `url:"sdn_object_group_id,omitempty" json:"sdn_object_group_id,omitempty"`
|
||||
|
||||
// SDN Logical Port Display Name
|
||||
// Required: false
|
||||
SDNLogicalPortDisplayName string `url:"sdn_logical_port_display_name,omitempty" json:"sdn_logical_port_display_name,omitempty"`
|
||||
|
||||
// SDN Logical Port Description
|
||||
// Required: false
|
||||
SDNLogicalPortDescription string `url:"sdn_logical_port_description,omitempty" json:"sdn_logical_port_description,omitempty"`
|
||||
}
|
||||
|
||||
// MassCreateRequest struct to mass create KVM x86
|
||||
@@ -132,6 +152,19 @@ type MassCreateRequest struct {
|
||||
// The OS version that will be installed on the virtual machine
|
||||
// Required: false
|
||||
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"`
|
||||
|
||||
// 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 {
|
||||
|
||||
@@ -30,8 +30,8 @@ type CreateRequest struct {
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
|
||||
// Start now Load balancer
|
||||
// Required: true
|
||||
Start bool `url:"start" json:"start" validate:"required"`
|
||||
// Required: false
|
||||
Start interface{} `url:"start,omitempty" json:"start,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Custom sysctl values for Load Balancer instance. Applied on boot
|
||||
// Required: false
|
||||
|
||||
42
pkg/cloudbroker/node/autostart.go
Normal file
42
pkg/cloudbroker/node/autostart.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// AutoStartRequest struct to set node autostart
|
||||
type AutoStartRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||
|
||||
// Auto start
|
||||
// Required: true
|
||||
AutoStart bool `url:"autostart" json:"autostart" validate:"required"`
|
||||
}
|
||||
|
||||
// AutoStart sets node autostart
|
||||
func (n Node) AutoStart(ctx context.Context, req AutoStartRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/autostart"
|
||||
|
||||
res, err := n.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
|
||||
}
|
||||
@@ -49,6 +49,10 @@ type ListRequest struct {
|
||||
// Page size
|
||||
// Required: false
|
||||
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
|
||||
|
||||
@@ -26,6 +26,11 @@ type MaintenanceRequest struct {
|
||||
// Reason
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
|
||||
// Allow node auto-enable
|
||||
// Default: false
|
||||
// Required: false
|
||||
AutoStart bool `url:"autostart" json:"autostart"`
|
||||
}
|
||||
|
||||
// Maintenance places node in maintenance state
|
||||
|
||||
@@ -26,6 +26,9 @@ type RecordNode struct {
|
||||
// Isolated Cpus
|
||||
IsolatedCpus []interface{} `json:"isolatedCpus"`
|
||||
|
||||
// MemAllocationRatio
|
||||
MemAllocationRatio float64 `json:"mem_allocation_ratio"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
@@ -85,6 +88,12 @@ type RecordNode struct {
|
||||
|
||||
// CPU used by the node
|
||||
UsableCPUs []string `json:"usable_cpus"`
|
||||
|
||||
// AutoStart
|
||||
AutoStart bool `json:"autostart"`
|
||||
|
||||
// AutoStart Count
|
||||
AutoStartCount uint64 `json:"autostart_count"`
|
||||
}
|
||||
|
||||
// Resource consumption of the node
|
||||
@@ -301,6 +310,12 @@ type ItemNode struct {
|
||||
|
||||
// CPU used by the node
|
||||
UsableCPUs []string `json:"usable_cpus"`
|
||||
|
||||
// AutoStart
|
||||
AutoStart bool `json:"autostart"`
|
||||
|
||||
// AutoStart Count
|
||||
AutoStartCount uint64 `json:"autostart_count"`
|
||||
}
|
||||
|
||||
type PackageInfo struct {
|
||||
|
||||
@@ -5,13 +5,14 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type VFParam struct {
|
||||
// Number of VF to assign
|
||||
// ID of the FN
|
||||
// Required: true
|
||||
VFNum uint64 `url:"vfNum" json:"vfNum" validate:"required"`
|
||||
FNID uint64 `url:"fnId" json:"fnId" validate:"required"`
|
||||
|
||||
// Trust
|
||||
// Required: true
|
||||
@@ -46,7 +47,7 @@ func (n Node) SetVFsParams(ctx context.Context, req SetVFsParamsRequest) (bool,
|
||||
|
||||
url := "/cloudbroker/node/setVFsParams"
|
||||
|
||||
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := n.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -79,6 +79,9 @@ type ListResourceConsumption struct {
|
||||
|
||||
// Access Control List
|
||||
type ACL struct {
|
||||
// Email
|
||||
Email string `json:"email"`
|
||||
|
||||
// Explicit
|
||||
Explicit bool `json:"explicit"`
|
||||
|
||||
|
||||
@@ -20,22 +20,22 @@ type AddConsumerNodesRequest struct {
|
||||
}
|
||||
|
||||
// AddConsumerNodes adds consumer nodes to SEP parameters
|
||||
func (s SEP) AddConsumerNodes(ctx context.Context, req AddConsumerNodesRequest) (bool, error) {
|
||||
func (s SEP) AddConsumerNodes(ctx context.Context, req AddConsumerNodesRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/sep/addConsumerNodes"
|
||||
|
||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
@@ -20,22 +20,22 @@ type AddProviderNodesRequest struct {
|
||||
}
|
||||
|
||||
// AddProviderNodes adds provider nodes to SEP parameters
|
||||
func (s SEP) AddProviderNodes(ctx context.Context, req AddProviderNodesRequest) (bool, error) {
|
||||
func (s SEP) AddProviderNodes(ctx context.Context, req AddProviderNodesRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/sep/addProviderNodes"
|
||||
|
||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
@@ -20,7 +20,7 @@ type CreateRequest struct {
|
||||
|
||||
// Type of storage
|
||||
// Required: true
|
||||
SEPType string `url:"sep_type" json:"sep_type" validate:"required"`
|
||||
SEPType string `url:"sep_type" json:"sep_type" validate:"required,sepType"`
|
||||
|
||||
// SEP config
|
||||
// Required: true
|
||||
@@ -30,14 +30,6 @@ type CreateRequest struct {
|
||||
// Required: false
|
||||
Description string `url:"description,omitempty" json:"description,omitempty"`
|
||||
|
||||
// List of provider node IDs
|
||||
// Required: false
|
||||
ProviderNIDs []uint64 `url:"provider_nids,omitempty" json:"provider_nids,omitempty"`
|
||||
|
||||
// List of consumer node IDs
|
||||
// Required: false
|
||||
ConsumerNIDs []uint64 `url:"consumer_nids,omitempty" json:"consumer_nids,omitempty"`
|
||||
|
||||
// Enable SEP after creation
|
||||
// Required: false
|
||||
Enable bool `url:"enable,omitempty" json:"enable,omitempty"`
|
||||
|
||||
@@ -20,8 +20,8 @@ type DelConsumerNodesRequest struct {
|
||||
|
||||
// The force flag must be set to true only if the node will never come back online
|
||||
// Default: false
|
||||
// Required: true
|
||||
Force bool `url:"force" json:"force" validate:"required"`
|
||||
// Required: false
|
||||
Force bool `url:"force" json:"force"`
|
||||
}
|
||||
|
||||
// DelConsumerNodes excludes consumer nodes from SEP parameters
|
||||
|
||||
@@ -42,6 +42,9 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Sort by SEP IDs
|
||||
SepIDs []uint64 `url:"sep_ids,omitempty" json:"sep_ids,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
|
||||
@@ -56,6 +56,10 @@ type ListRequest struct {
|
||||
// Search by pool name
|
||||
// Required: false
|
||||
PoolName string `url:"pool_name,omitempty" json:"pool_name,omitempty"`
|
||||
|
||||
// Filter SEP's by tech status (ENABLED, DISABLED)
|
||||
// Required: false
|
||||
SepTechStatus string `url:"sep_tech_status,omitempty" json:"sep_tech_status,omitempty" validate:"omitempty,sepTechStatus"`
|
||||
}
|
||||
|
||||
// List gets list of storage policies as a ListStoragePolicies struct
|
||||
|
||||
@@ -22,8 +22,8 @@ type InfoStoragePolicyWithID struct {
|
||||
// Max IOPS for the sotrage policy
|
||||
LimitIOPS uint64 `json:"limit_iops"`
|
||||
|
||||
// ID of the storage policy
|
||||
StoragePolicyID uint64 `json:"storage_policy_id"`
|
||||
// Which accounts and resource groups use the storage policy
|
||||
Usage Usage `json:"usage"`
|
||||
}
|
||||
|
||||
type ListStoragePolicies struct {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
@@ -13,6 +14,10 @@ type UpdateRequest struct {
|
||||
// Required: true
|
||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||
|
||||
// List of storage endpoint access objects
|
||||
// Required: false
|
||||
AccessSEPsPools []AccessSEPsPool `url:"access_seps_pools,omitempty" json:"access_seps_pools,omitempty"`
|
||||
|
||||
// New name for the storage policy
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
@@ -51,6 +56,6 @@ func (sp StPolicy) UpdateRaw(ctx context.Context, req UpdateRequest) ([]byte, er
|
||||
|
||||
url := "/cloudbroker/storage_policy/update"
|
||||
|
||||
res, err := sp.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := sp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@@ -33,6 +33,11 @@ type CreateRequest struct {
|
||||
// Native VLAN ID
|
||||
// Required: false
|
||||
NativeVLANID uint64 `url:"native_vlan_id,omitempty" json:"native_vlan_id,omitempty"`
|
||||
|
||||
// MTU
|
||||
// Default value: 1500
|
||||
// Required: false
|
||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty"`
|
||||
}
|
||||
|
||||
// Create creates a user.
|
||||
|
||||
@@ -29,6 +29,9 @@ type ItemTrunk struct {
|
||||
// MAC
|
||||
MAC string `json:"mac"`
|
||||
|
||||
// MTU
|
||||
MTU uint64 `json:"mtu"`
|
||||
|
||||
// Name of a trunk
|
||||
Name string `json:"name"`
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ type UpdateRequest struct {
|
||||
TrunkID uint64 `url:"id" json:"id" validate:"required"`
|
||||
|
||||
// New name of the trunk
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// List of trunk tags (values between 1-4095)
|
||||
// Required: true
|
||||
TrunkTags string `url:"trunk_tags" json:"trunk_tags" validate:"required,trunkTags"`
|
||||
// Required: false
|
||||
TrunkTags string `url:"trunk_tags,omitempty" json:"trunk_tags,omitempty" validate:"omitempty,trunkTags"`
|
||||
|
||||
// New description of the trunk
|
||||
// Required: false
|
||||
@@ -29,6 +29,11 @@ type UpdateRequest struct {
|
||||
// New native VLAN ID
|
||||
// Required: false
|
||||
NativeVLANID uint64 `url:"native_vlan_id,omitempty" json:"native_vlan_id,omitempty"`
|
||||
|
||||
// MTU
|
||||
// Default value: 1500
|
||||
// Required: false
|
||||
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty"`
|
||||
}
|
||||
|
||||
// Update updates a trunk
|
||||
|
||||
@@ -15,8 +15,8 @@ type GetMatchingUsernamesRequest struct {
|
||||
UsernameRegex string `url:"usernameregex" json:"usernameregex" validate:"required"`
|
||||
|
||||
// The number of usernames to return.
|
||||
// Required: true
|
||||
Limit uint64 `url:"limit" json:"limit" validate:"required"`
|
||||
// Required: false
|
||||
Limit uint64 `url:"limit,omitempty" json:"limit,omitempty"`
|
||||
}
|
||||
|
||||
// GetMatchingUsernames gets a list of the matching usernames for a given string.
|
||||
|
||||
@@ -17,6 +17,10 @@ type CreateRequest struct {
|
||||
// Description
|
||||
// Required: false
|
||||
Description string `url:"description,omitempty" json:"description,omitempty"`
|
||||
|
||||
// If true, all nodes belonging to the given zone will be marked for autostart
|
||||
// Required: false
|
||||
AutoStart interface{} `url:"autostart,omitempty" json:"autostart,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// Create creates zone object
|
||||
|
||||
@@ -10,6 +10,9 @@ type ListZones struct {
|
||||
|
||||
// Detailed information about the zone record
|
||||
type RecordZone struct {
|
||||
// If true, all nodes belonging to the given zone will be marked for autostart
|
||||
AutoStart bool `json:"autostart"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
|
||||
43
pkg/cloudbroker/zone/node_autostart.go
Normal file
43
pkg/cloudbroker/zone/node_autostart.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package zone
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// NodeAutoStartRequest struct to set node autostart in zone
|
||||
type NodeAutoStartRequest struct {
|
||||
// ID of zone
|
||||
// Required: true
|
||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||
|
||||
// AutoStart nodes in zone
|
||||
// Required: true
|
||||
AutoStart bool `url:"autostart" json:"autostart" validate:"required"`
|
||||
}
|
||||
|
||||
// NodeAutoStart sets node autostart in zone
|
||||
func (e Zone) NodeAutoStart(ctx context.Context, req NodeAutoStartRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/zone/node_autostart"
|
||||
|
||||
res, err := e.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
|
||||
}
|
||||
@@ -21,6 +21,10 @@ type UpdateRequest struct {
|
||||
// Description
|
||||
// Required: false
|
||||
Description string `url:"description,omitempty" json:"description,omitempty"`
|
||||
|
||||
// If true, all nodes belonging to the given zone will be marked for autostart
|
||||
// Required: false
|
||||
AutoStart interface{} `url:"autostart,omitempty" json:"autostart,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// Update updates zone object
|
||||
|
||||
@@ -62,10 +62,18 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
CreatedFrom string `url:"created_from,omitempty" json:"created_from,omitempty"`
|
||||
|
||||
// Filter lby create date to
|
||||
// Filter by create date to
|
||||
// Required: false
|
||||
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
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
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
|
||||
}
|
||||
@@ -8,9 +8,11 @@
|
||||
- [Тесты Raw методов (Get, List)](#тесты-raw-методов-get-list)
|
||||
- [Cloudapi](#cloudapi)
|
||||
- [Cloudbroker](#cloudbroker)
|
||||
- [SDN](#sdn)
|
||||
- [Тесты запросов](#тесты-запросов)
|
||||
- [Cloudapi](#cloudapi-1)
|
||||
- [Cloudbroker](#cloudbroker-1)
|
||||
- [SDN](#sdn-1)
|
||||
- [Тесты API методов](#тесты-api-методов)
|
||||
|
||||
## Подготовка к тестам
|
||||
@@ -46,6 +48,13 @@
|
||||
Запустить тест `TestGetListCloudbroker` в `decort-sdk/tests/platform_upgrade/cloud_test.go`
|
||||
При наличии подсвеченных полей, проверить, что они содержатся на платформе и не содержатся в go структурах, завести и исправить ошибку.
|
||||
|
||||
### SDN
|
||||
|
||||
Запустить тест `TestGetListSDNAPI` в `decort-sdk/tests/platform_upgrade/cloud_test.go`
|
||||
При наличии подсвеченных полей, проверить, что они содержатся на платформе и не содержатся в go структурах, завести и исправить ошибку.
|
||||
|
||||
Пример вывода аналогичен тестам для Cloudapi и Cloudbroker.
|
||||
|
||||
## Тесты запросов
|
||||
|
||||
### Cloudapi
|
||||
@@ -89,6 +98,13 @@ FAIL
|
||||
FAIL
|
||||
```
|
||||
|
||||
### SDN
|
||||
|
||||
Запустить тест `TestRequestsSDN` в `decort-sdk/tests/platform_upgrade/cloud_test.go`
|
||||
При наличии подсвеченных ошибок, проверить, что они являются ошибками (возможны ситуации, когда расхождение платформы и sdk задумано специально), завести и исправить ошибку.
|
||||
|
||||
Пример вывода аналогичен тестам для Cloudapi и Cloudbroker.
|
||||
|
||||
## Тесты API методов
|
||||
|
||||
Запустить тест `TestGetAllPaths` в `decort-sdk/tests/platform_upgrade/cloud_test.go`
|
||||
|
||||
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
|
||||
@@ -135,7 +135,7 @@ func getRequestsMapCloudAPI() map[string]interface{} {
|
||||
"/restmachine/cloudapi/bservice/snapshotRollback": bservice.SnapshotRollbackRequest{},
|
||||
"/restmachine/cloudapi/bservice/start": bservice.StartRequest{},
|
||||
"/restmachine/cloudapi/bservice/stop": bservice.StopRequest{},
|
||||
|
||||
"/restmachine/cloudapi/bservice/migrateToZone": bservice.MigrateToZoneRequest{},
|
||||
// compute
|
||||
"/restmachine/cloudapi/compute/abort_shared_snapshot_merge": compute.AbortSharedSnapshotMergeRequest{},
|
||||
"/restmachine/cloudapi/compute/shared_snapshot_merge_status": compute.SharedSnapshotMergeStatusRequest{},
|
||||
@@ -194,7 +194,7 @@ func getRequestsMapCloudAPI() map[string]interface{} {
|
||||
"/restmachine/cloudapi/compute/pfwDel": compute.PFWDelRequest{},
|
||||
"/restmachine/cloudapi/compute/pfwList": compute.PFWListRequest{},
|
||||
"/restmachine/cloudapi/compute/pause": compute.PauseRequest{},
|
||||
"/restmachine/cloudapi/compute/pinToNode": compute.PinToNodeRequest{},
|
||||
"/restmachine/cloudapi/compute/pin_to_node": compute.PinToNodeRequest{},
|
||||
"/restmachine/cloudapi/compute/powerCycle": compute.PowerCycleRequest{},
|
||||
"/restmachine/cloudapi/compute/reboot": compute.RebootRequest{},
|
||||
"/restmachine/cloudapi/compute/redeploy": compute.RedeployRequest{},
|
||||
@@ -212,7 +212,7 @@ func getRequestsMapCloudAPI() map[string]interface{} {
|
||||
"/restmachine/cloudapi/compute/stop": compute.StopRequest{},
|
||||
"/restmachine/cloudapi/compute/tagAdd": compute.TagAddRequest{},
|
||||
"/restmachine/cloudapi/compute/tagRemove": compute.TagRemoveRequest{},
|
||||
"/restmachine/cloudapi/compute/unpinFromNode": compute.UnpinFromNodeRequest{},
|
||||
"/restmachine/cloudapi/compute/unpin_from_node": compute.UnpinFromNodeRequest{},
|
||||
"/restmachine/cloudapi/compute/update": compute.UpdateRequest{},
|
||||
"/restmachine/cloudapi/compute/userGrant": compute.UserGrantRequest{},
|
||||
"/restmachine/cloudapi/compute/userList": compute.UserListRequest{},
|
||||
@@ -225,6 +225,7 @@ func getRequestsMapCloudAPI() map[string]interface{} {
|
||||
"/restmachine/cloudapi/compute/guest_agent_execute": compute.GuestAgentExecuteRequest{},
|
||||
"/restmachine/cloudapi/compute/guest_agent_feature_get": compute.GuestAgentFeatureGetRequest{},
|
||||
"/restmachine/cloudapi/compute/guest_agent_feature_update": compute.GuestAgentFeatureUpdateRequest{},
|
||||
"/restmachine/cloudapi/compute/migrateToZone": compute.MigrateToZoneRequest{},
|
||||
|
||||
// disks
|
||||
"/restmachine/cloudapi/disks/change_disk_storage_policy": disks.ChangeDiskStoragePolicyRequest{},
|
||||
@@ -236,7 +237,6 @@ func getRequestsMapCloudAPI() map[string]interface{} {
|
||||
"/restmachine/cloudapi/disks/limitIO": disks.LimitIORequest{},
|
||||
"/restmachine/cloudapi/disks/list": disks.ListRequest{},
|
||||
"/restmachine/cloudapi/disks/listDeleted": disks.ListDeletedRequest{},
|
||||
"/restmachine/cloudapi/disks/listTypes": disks.ListTypesRequest{},
|
||||
"/restmachine/cloudapi/disks/listUnattached": disks.ListUnattachedRequest{},
|
||||
"/restmachine/cloudapi/disks/rename": disks.RenameRequest{},
|
||||
"/restmachine/cloudapi/disks/replicate": disks.ReplicateRequest{},
|
||||
@@ -314,6 +314,7 @@ func getRequestsMapCloudAPI() map[string]interface{} {
|
||||
"/restmachine/cloudapi/k8s/workersGroupGetByName": k8s.WorkersGroupGetByNameRequest{},
|
||||
"/restmachine/cloudapi/k8s/workerReset": k8s.WorkerResetRequest{},
|
||||
"/restmachine/cloudapi/k8s/workerRestart": k8s.WorkerRestartRequest{},
|
||||
"/restmachine/cloudapi/k8s/migrateToZone": k8s.MigrateToZoneRequest{},
|
||||
|
||||
// kvmx86
|
||||
"/restmachine/cloudapi/kvmx86/create": kvmx86.CreateRequest{},
|
||||
@@ -346,6 +347,7 @@ func getRequestsMapCloudAPI() map[string]interface{} {
|
||||
"/restmachine/cloudapi/lb/stop": lb.StopRequest{},
|
||||
"/restmachine/cloudapi/lb/update": lb.UpdateRequest{},
|
||||
"/restmachine/cloudapi/lb/updateSysctlParams": lb.UpdateSysctParamsRequest{},
|
||||
"/restmachine/cloudapi/lb/migrateToZone": lb.MigrateToZoneRequest{},
|
||||
|
||||
// locations
|
||||
"/restmachine/cloudapi/locations/getUrl": EmptyStruct{},
|
||||
@@ -465,6 +467,7 @@ func getRequestsMapCloudAPI() map[string]interface{} {
|
||||
"/restmachine/cloudapi/vins/staticRouteList": vins.StaticRouteListRequest{},
|
||||
"/restmachine/cloudapi/vins/vnfdevRedeploy": vins.VNFDevRedeployRequest{},
|
||||
"/restmachine/cloudapi/vins/vnfdevRestart": vins.VNFDevRestartRequest{},
|
||||
"/restmachine/cloudapi/vins/migrateToZone": vins.MigrateToZoneRequest{},
|
||||
|
||||
// zone
|
||||
"/restmachine/cloudapi/zone/get": zone.GetRequest{},
|
||||
@@ -508,6 +511,8 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/account/updateComputeFeatures": account_cb.UpdateComputeFeaturesRequest{},
|
||||
"/restmachine/cloudbroker/account/updateResourceTypes": account_cb.UpdateResourceTypesRequest{},
|
||||
"/restmachine/cloudbroker/account/updateUser": account_cb.UpdateUserRequest{},
|
||||
"/restmachine/cloudbroker/account/addZone": account_cb.AddZoneRequest{},
|
||||
"/restmachine/cloudbroker/account/removeZone": account_cb.RemoveZoneRequest{},
|
||||
|
||||
// apiaccess_cb
|
||||
"/restmachine/cloudbroker/apiaccess/apisExclude": apiaccess_cb.APIsExcludeRequest{},
|
||||
@@ -564,6 +569,7 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/compute/cdInsert": compute_cb.CDInsertRequest{},
|
||||
"/restmachine/cloudbroker/compute/changeLinkState": compute_cb.ChangeLinkStateRequest{},
|
||||
"/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/clone": compute_cb.CloneRequest{},
|
||||
"/restmachine/cloudbroker/compute/clone_abort": compute_cb.CloneAbortRequest{},
|
||||
@@ -650,6 +656,10 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/compute/guest_agent_feature_get": compute_cb.GuestAgentFeatureGetRequest{},
|
||||
"/restmachine/cloudbroker/compute/guest_agent_feature_update": compute_cb.GuestAgentFeatureUpdateRequest{},
|
||||
"/restmachine/cloudbroker/compute/change_read_only": compute_cb.ChangeReadOnlyRequest{},
|
||||
"/restmachine/cloudbroker/compute/migrateToZone": compute_cb.MigrateToZoneRequest{},
|
||||
"/restmachine/cloudbroker/compute/migrate_abort": compute_cb.MigrateAbortRequest{},
|
||||
"/restmachine/cloudbroker/compute/start_migration_out": compute_cb.StartMigrationOutRequest{},
|
||||
"/restmachine/cloudbroker/compute/stop_migration_out": compute_cb.StopMigrationOutRequest{},
|
||||
|
||||
// disks
|
||||
"/restmachine/cloudbroker/disks/change_disk_storage_policy": disks_cb.ChangeDiskStoragePolicyRequest{},
|
||||
@@ -662,7 +672,6 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/disks/limitIO": disks_cb.LimitIORequest{},
|
||||
"/restmachine/cloudbroker/disks/list": disks_cb.ListRequest{},
|
||||
"/restmachine/cloudbroker/disks/listDeleted": disks_cb.ListDeletedRequest{},
|
||||
"/restmachine/cloudbroker/disks/listTypes": disks_cb.ListTypesRequest{},
|
||||
"/restmachine/cloudbroker/disks/listUnattached": disks_cb.ListUnattachedRequest{},
|
||||
"/restmachine/cloudbroker/disks/rename": disks_cb.RenameRequest{},
|
||||
"/restmachine/cloudbroker/disks/present": disks_cb.PresentRequest{},
|
||||
@@ -683,6 +692,7 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/disks/migrate": disks_cb.MigrateRequest{},
|
||||
"/restmachine/cloudbroker/disks/migrate_abort": disks_cb.MigrateAbortRequest{},
|
||||
"/restmachine/cloudbroker/disks/migrate_status": disks_cb.GetMigrateStatusRequest{},
|
||||
"/restmachine/cloudbroker/disks/update": disks_cb.UpdateRequest{},
|
||||
|
||||
// dpdknet
|
||||
"/restmachine/cloudbroker/dpdknet/get": dpdknet_cb.GetRequest{},
|
||||
@@ -726,6 +736,7 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/extnet/staticRouteDel": extnet_cb.StaticRouteDelRequest{},
|
||||
"/restmachine/cloudbroker/extnet/staticRouteList": extnet_cb.StaticRouteListRequest{},
|
||||
"/restmachine/cloudbroker/extnet/update": extnet_cb.UpdateRequest{},
|
||||
"/restmachine/cloudbroker/extnet/migrateToZone": extnet_cb.MigrateToZoneRequest{},
|
||||
|
||||
// flipgroup
|
||||
"/restmachine/cloudbroker/flipgroup/computeAdd": flipgroup_cb.ComputeAddRequest{},
|
||||
@@ -824,6 +835,7 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/k8s/workersGroupGetByName": k8s_cb.WorkersGroupGetByNameRequest{},
|
||||
"/restmachine/cloudbroker/k8s/workerReset": k8s_cb.WorkerResetRequest{},
|
||||
"/restmachine/cloudbroker/k8s/workerRestart": k8s_cb.WorkerRestartRequest{},
|
||||
"/restmachine/cloudbroker/k8s/migrateToZone": k8s_cb.MigrateToZoneRequest{},
|
||||
|
||||
// kvmx86
|
||||
"/restmachine/cloudbroker/kvmx86/create": kvmx86_cb.CreateRequest{},
|
||||
@@ -857,6 +869,7 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/lb/stop": lb_cb.StopRequest{},
|
||||
"/restmachine/cloudbroker/lb/update": lb_cb.UpdateRequest{},
|
||||
"/restmachine/cloudbroker/lb/updateSysctlParams": lb_cb.UpdateSysctParamsRequest{},
|
||||
"/restmachine/cloudbroker/lb/migrateToZone": lb_cb.MigrateToZoneRequest{},
|
||||
|
||||
// node
|
||||
"/restmachine/cloudbroker/node/add_ssh_identity": node_cb.AddSSHIdentityRequest{},
|
||||
@@ -876,10 +889,11 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/node/setVFsNumber": node_cb.SetVFsNumberRequest{},
|
||||
"/restmachine/cloudbroker/node/update": node_cb.UpdateRequest{},
|
||||
"/restmachine/cloudbroker/node/update_description": node_cb.UpdateDescriptionRequest{},
|
||||
"/restmachine/cloudbroker/node/setVFsParams": node_cb.VFParam{},
|
||||
"/restmachine/cloudbroker/node/setVFsParams": node_cb.SetVFsParamsRequest{},
|
||||
"/restmachine/cloudbroker/node/get_logical_cores_count": node_cb.GetLogicalCoresCountRequest{},
|
||||
"/restmachine/cloudbroker/node/set_cpu_allocation_ratio": node_cb.SetCpuAllocationRatioRequest{},
|
||||
"/restmachine/cloudbroker/node/set_mem_allocation_ratio": node_cb.SetMemAllocationRatioRequest{},
|
||||
"/restmachine/cloudbroker/node/autostart": node_cb.AutoStartRequest{},
|
||||
|
||||
// pcidevice
|
||||
"/restmachine/cloudbroker/pcidevice/create": pcidevice_cb.CreateRequest{},
|
||||
@@ -976,6 +990,7 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/sep/sharedLockStop": sep_cb.SharedLockStopRequest{},
|
||||
"/restmachine/cloudbroker/sep/listAvailableSepAndPools": sep_cb.ListAvailableSEPAndPoolsRequest{},
|
||||
"/restmachine/cloudbroker/sep/sharedLockStart": sep_cb.SharedLockStartRequest{},
|
||||
"/restmachine/cloudbroker/sep/getTemplate": sep_cb.GetTemplateRequest{},
|
||||
|
||||
// storage_policy
|
||||
"/restmachine/cloudbroker/storage_policy/get": stpolicy_cb.GetRequest{},
|
||||
@@ -1074,15 +1089,17 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/vins/vnfdevReset": vins_cb.VNFDevResetRequest{},
|
||||
"/restmachine/cloudbroker/vins/vnfdevStart": vins_cb.VNFDevStartRequest{},
|
||||
"/restmachine/cloudbroker/vins/vnfdevStop": vins_cb.VNFDevStopRequest{},
|
||||
"/restmachine/cloudbroker/vins/migrateToZone": vins_cb.MigrateToZoneRequest{},
|
||||
|
||||
// zone
|
||||
"/restmachine/cloudbroker/zone/get": zone_cb.GetRequest{},
|
||||
"/restmachine/cloudbroker/zone/list": zone_cb.ListRequest{},
|
||||
"/restmachine/cloudbroker/zone/create": zone_cb.CreateRequest{},
|
||||
"/restmachine/cloudbroker/zone/delete": zone_cb.DeleteRequest{},
|
||||
"/restmachine/cloudbroker/zone/update": zone_cb.UpdateRequest{},
|
||||
"/restmachine/cloudbroker/zone/addNode": zone_cb.AddNodeRequest{},
|
||||
"/restmachine/cloudbroker/zone/delNode": zone_cb.DelNodeRequest{},
|
||||
"/restmachine/cloudbroker/zone/get": zone_cb.GetRequest{},
|
||||
"/restmachine/cloudbroker/zone/list": zone_cb.ListRequest{},
|
||||
"/restmachine/cloudbroker/zone/create": zone_cb.CreateRequest{},
|
||||
"/restmachine/cloudbroker/zone/delete": zone_cb.DeleteRequest{},
|
||||
"/restmachine/cloudbroker/zone/update": zone_cb.UpdateRequest{},
|
||||
"/restmachine/cloudbroker/zone/addNode": zone_cb.AddNodeRequest{},
|
||||
"/restmachine/cloudbroker/zone/delNode": zone_cb.DelNodeRequest{},
|
||||
"/restmachine/cloudbroker/zone/node_autostart": zone_cb.NodeAutoStartRequest{},
|
||||
|
||||
// security policy
|
||||
"/sdn/security_policy/create": secpolicies.CreateRequest{},
|
||||
@@ -1147,6 +1164,8 @@ func getRequestsMapSDN() map[string]interface{} {
|
||||
"/restmachine/sdn/network_object_group/get": netobjgroups.GetRequest{},
|
||||
"/restmachine/sdn/network_object_group/list": netobjgroups.ListRequest{},
|
||||
"/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
|
||||
"/restmachine/sdn/segment/create": segments.CreateRequest{},
|
||||
|
||||
@@ -9,6 +9,31 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// extractTypeFromSchema extracts type from schema, handling oneOf cases
|
||||
// When oneOf contains a type and null, it returns the non-null type
|
||||
func extractTypeFromSchema(schema map[string]interface{}) string {
|
||||
// Check for direct type
|
||||
if paramType, ok := schema["type"].(string); ok {
|
||||
return paramType
|
||||
}
|
||||
|
||||
// Check for oneOf
|
||||
if oneOf, ok := schema["oneOf"].([]interface{}); ok {
|
||||
for _, item := range oneOf {
|
||||
if itemMap, ok := item.(map[string]interface{}); ok {
|
||||
if itemType, ok := itemMap["type"].(string); ok {
|
||||
// Skip null type, return the first non-null type found
|
||||
if itemType != "null" {
|
||||
return itemType
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func getParameters(input map[string]interface{}) []interface{} {
|
||||
var emptySlice []interface{}
|
||||
methods := []string{"get", "post", "put", "delete", "patch", "head", "options"}
|
||||
@@ -33,57 +58,126 @@ func getParameters(input map[string]interface{}) []interface{} {
|
||||
return emptySlice
|
||||
}
|
||||
|
||||
params, ok := parameters["parameters"]
|
||||
if !ok {
|
||||
return emptySlice
|
||||
}
|
||||
var result []interface{}
|
||||
|
||||
res, ok := params.([]interface{})
|
||||
if !ok {
|
||||
return emptySlice
|
||||
}
|
||||
// Check if there's a body parameter
|
||||
for _, p := range res {
|
||||
param, ok := p.(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if param["name"] == "body" {
|
||||
schema, ok := param["schema"].(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
properties, ok := schema["properties"].(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
requiredFields := make(map[string]bool)
|
||||
if req, ok := schema["required"].([]interface{}); ok {
|
||||
for _, r := range req {
|
||||
requiredFields[r.(string)] = true
|
||||
if requestBody, ok := parameters["requestBody"].(map[string]interface{}); ok {
|
||||
if content, ok := requestBody["content"].(map[string]interface{}); ok {
|
||||
// Check for application/x-www-form-urlencoded, application/json, or multipart/form-data
|
||||
var schemaData map[string]interface{}
|
||||
var found bool
|
||||
|
||||
if formData, ok := content["application/x-www-form-urlencoded"].(map[string]interface{}); ok {
|
||||
if schema, ok := formData["schema"].(map[string]interface{}); ok {
|
||||
schemaData = schema
|
||||
found = true
|
||||
}
|
||||
} else if jsonData, ok := content["application/json"].(map[string]interface{}); ok {
|
||||
if schema, ok := jsonData["schema"].(map[string]interface{}); ok {
|
||||
schemaData = schema
|
||||
found = true
|
||||
}
|
||||
} else if multipartData, ok := content["multipart/form-data"].(map[string]interface{}); ok {
|
||||
if schema, ok := multipartData["schema"].(map[string]interface{}); ok {
|
||||
schemaData = schema
|
||||
found = true
|
||||
}
|
||||
}
|
||||
var newParams []interface{}
|
||||
for name, prop := range properties {
|
||||
propMap, ok := prop.(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
newParam := make(map[string]interface{})
|
||||
newParam["name"] = name
|
||||
newParam["type"] = propMap["type"]
|
||||
newParam["required"] = requiredFields[name]
|
||||
if propMap["type"] == "array" {
|
||||
if items, ok := propMap["items"].(map[string]interface{}); ok {
|
||||
newParam["items"] = items
|
||||
|
||||
if found && schemaData != nil {
|
||||
if properties, ok := schemaData["properties"].(map[string]interface{}); ok {
|
||||
requiredFields := make(map[string]bool)
|
||||
if req, ok := schemaData["required"].([]interface{}); ok {
|
||||
for _, r := range req {
|
||||
if reqStr, ok := r.(string); ok {
|
||||
requiredFields[reqStr] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
for name, prop := range properties {
|
||||
propMap, ok := prop.(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
newParam := make(map[string]interface{})
|
||||
newParam["name"] = name
|
||||
propType := extractTypeFromSchema(propMap)
|
||||
if propType != "" {
|
||||
newParam["type"] = propType
|
||||
}
|
||||
newParam["required"] = requiredFields[name]
|
||||
if propType == "array" {
|
||||
// Try to get items from propMap first
|
||||
if items, ok := propMap["items"].(map[string]interface{}); ok {
|
||||
newParam["items"] = items
|
||||
} else if oneOf, ok := propMap["oneOf"].([]interface{}); ok {
|
||||
// If items not in propMap, try to get from oneOf array element
|
||||
for _, item := range oneOf {
|
||||
if itemMap, ok := item.(map[string]interface{}); ok {
|
||||
if itemType, ok := itemMap["type"].(string); ok && itemType == "array" {
|
||||
if items, ok := itemMap["items"].(map[string]interface{}); ok {
|
||||
newParam["items"] = items
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
result = append(result, newParam)
|
||||
}
|
||||
}
|
||||
newParams = append(newParams, newParam)
|
||||
}
|
||||
return newParams
|
||||
}
|
||||
}
|
||||
return res
|
||||
|
||||
if params, ok := parameters["parameters"].([]interface{}); ok {
|
||||
for _, p := range params {
|
||||
param, ok := p.(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
newParam := make(map[string]interface{})
|
||||
if name, ok := param["name"].(string); ok {
|
||||
newParam["name"] = name
|
||||
}
|
||||
if schema, ok := param["schema"].(map[string]interface{}); ok {
|
||||
paramType := extractTypeFromSchema(schema)
|
||||
if paramType != "" {
|
||||
newParam["type"] = paramType
|
||||
}
|
||||
if paramType == "array" {
|
||||
if items, ok := schema["items"].(map[string]interface{}); ok {
|
||||
newParam["items"] = items
|
||||
} else if oneOf, ok := schema["oneOf"].([]interface{}); ok {
|
||||
for _, item := range oneOf {
|
||||
if itemMap, ok := item.(map[string]interface{}); ok {
|
||||
if itemType, ok := itemMap["type"].(string); ok && itemType == "array" {
|
||||
if items, ok := itemMap["items"].(map[string]interface{}); ok {
|
||||
newParam["items"] = items
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Handle required field
|
||||
if required, ok := param["required"].(bool); ok {
|
||||
newParam["required"] = required
|
||||
} else {
|
||||
newParam["required"] = false
|
||||
}
|
||||
result = append(result, newParam)
|
||||
}
|
||||
}
|
||||
|
||||
if len(result) > 0 {
|
||||
return result
|
||||
}
|
||||
|
||||
return emptySlice
|
||||
}
|
||||
|
||||
func getBytesFromJSON(fileName string, t *testing.T) []byte {
|
||||
@@ -144,6 +238,25 @@ func getErrorsFromJSON(bytes []byte, t *testing.T, cloud string) {
|
||||
if len(params) != typStruct.NumField() {
|
||||
errs = append(errs, fmt.Sprintf("Platform (%d) and golang structure (%d) have different amount of fields.", len(params), typStruct.NumField()))
|
||||
}
|
||||
paramMap := make(map[string]bool)
|
||||
paramRequiredMap := make(map[string]bool)
|
||||
for _, p := range params {
|
||||
param, ok := p.(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
name, ok := param["name"].(string)
|
||||
if ok {
|
||||
paramMap[name] = true
|
||||
required, ok := param["required"].(bool)
|
||||
if ok {
|
||||
paramRequiredMap[name] = required
|
||||
} else {
|
||||
paramRequiredMap[name] = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, p := range params {
|
||||
param, ok := p.(map[string]interface{})
|
||||
if !ok {
|
||||
@@ -198,6 +311,33 @@ func getErrorsFromJSON(bytes []byte, t *testing.T, cloud string) {
|
||||
errs = append(errs, fmt.Sprintf("Platform has field %s that golang structure doesn't", name))
|
||||
}
|
||||
}
|
||||
|
||||
// Check if required fields in Go structure are missing from platform JSON
|
||||
// or if they exist but are not required on platform
|
||||
for i := 0; i < typStruct.NumField(); i++ {
|
||||
jsonTag := typStruct.Field(i).Tag.Get("json")
|
||||
validation, _ := typStruct.Field(i).Tag.Lookup("validate")
|
||||
|
||||
fieldName := strings.Split(jsonTag, ",")[0]
|
||||
if fieldName == "" || fieldName == "-" {
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.Contains(validation, "required") {
|
||||
if !paramMap[fieldName] {
|
||||
errs = append(errs, fmt.Sprintf("Golang structure has required field %s that platform doesn't", fieldName))
|
||||
} else {
|
||||
platformRequired := paramRequiredMap[fieldName]
|
||||
if !platformRequired {
|
||||
fieldType := typStruct.Field(i).Type
|
||||
if fieldType.Kind() == reflect.Bool {
|
||||
errs = append(errs, fmt.Sprintf("Golang structure has required field %s that platform doesn't", fieldName))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
msg := fmt.Sprintf("Path %s has following errors: %v", k, errs)
|
||||
t.Error(msg)
|
||||
|
||||
@@ -48,6 +48,7 @@ var DEPRECATED_GROUPS = []string{
|
||||
"/cloudbroker/vins/staticRouteAccessGrant",
|
||||
"/cloudbroker/vins/staticRouteAccessRevoke",
|
||||
"/restmachine/cloudbroker/image/updateNodes",
|
||||
"/restmachine/cloudbroker/image/uploadImageFile",
|
||||
}
|
||||
|
||||
// getUrlsFromBytes converts bytes to array of urls strings
|
||||
|
||||
Reference in New Issue
Block a user