Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f679261f74 | |||
| b897b3447a | |||
|
|
cd5d1c9d0b | ||
| f5a632654b |
184
CHANGELOG.md
184
CHANGELOG.md
@@ -1,4 +1,4 @@
|
||||
## Version 1.15.0
|
||||
## Version 1.15.2
|
||||
|
||||
Методы `Audits` в cloudapi/compute, cloudbroker/compute, cloudapi/account, cloudbroker/account, cloudapi/vins, cloudbroker/vins, cloudapi/rg и cloudbroker/rg стали deprecated и в следующих версиях будут удалены, вместо них необходимо использовать метод `List` в cloudapi/audit и cloudbroker/audit с соответствующими фильтрами
|
||||
Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и в следующих версиях будут удалены
|
||||
@@ -10,190 +10,32 @@
|
||||
|
||||
### Добавлено
|
||||
|
||||
#### compute
|
||||
#### image
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-864 | Методы `GetCPUAlignmentProfile`, `SetCPUAlignmentProfile` и `DeleteCPUAlignmentProfile` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-864 | Структуры запросов `GetCPUAlignmentProfileRequest`, `SetCPUAlignmentProfileRequest` и `DeleteCPUAlignmentProfileRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-865 | Вычисляемое поле `CPUAlignmentProfile` в структуру ответа `RecordCompute` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-865 | Вычисляемое поле `CPUAlignmentProfile` в структуру ответа `ItemCompute` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-865 | Структура ответа `CPUAlignmentProfile` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-872 | Опциональное поле `WithMemory` в структуру запроса `SnapshotCreateRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-872 | Опциональное поле `WithMemory` в структуру запроса `SnapshotRollbackRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-872 | Вычисляемые поля `MemoryDumpImage` и `Compute` в структуру ответа `ItemSnapshot` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-872 | Методы `SnapshotCreateAsync`, `SnapshotRollbackAsync` и `AbortSharedSnapshotMergeAsync` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-872 | Опциональное поле `NodeID` в структуру запроса `SnapshotRollbackRequest` в cloudbroker/compute |
|
||||
| BGOS-877 | Опциональное поле `Clock` в структуру запроса `UpdateRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-877 | Вычисляемое поле `Clock` в структуры ответа `RecordCompute` и `ItemCompute` в cloudapi/compute|
|
||||
| BGOS-877 | Вычисляемое поле `Clock` в структуры ответа `RecordCompute` и `InfoCompute` в cloudbroker/compute |
|
||||
| BGOS-885 | Методы `CDEjectAsync`, `CDInsertAsync`, `ChangeIPAsync`, `ChangeLinkStateAsync`, `ChangeSecGroupsAsync`, `ChangeMTUAsync`, `CloneAsync`, `CreateTemplateAsync`, `DeleteAsync`, `DisableAsync`, `DiskAddAsync`, `DiskAttachAsync`, `DiskDelAsync`, `DiskDetachAsync`, `DiskQOSAsync`, `DiskResizeAsync`, `DiskSwitchToReplicationAsync`, `GuestAgentDisableAsync`, `GuestAgentEnableAsync`, `GuestAgentExecuteRequestAsync`, `GuestAgentFeatureUpdateAsync`, `MigrateToZoneAsync`, `MoveToRGAsync`, `NetAttachAsync`, `NetDetachAsync`, `PauseAsync`, `PFWAddAsync`, `PFWDelAsync`, `PinToNodeAsync`, `PowerCycleAsync`, `RebootAsync`, `RedeployAsync`, `ResetAsync`, `ResizeAsync`, `RestoreAsync`, `ResumeAsync`, `StartAsync`, `StopAsync`, `MassDeleteAsync`, `MassRebootAsync`, `MassStartAsync`, `MassStopAsync`, `MigrateAbortAsync`, `MigrateStorageAbortAsync`, `MigrateStorageCleanUpAsync`, `NetQOSAsync` и `RaiseDownAsync` в cloudbroker/compute |
|
||||
| BGOS-885 | Методы `CDEjectAsync`, `CDInsertAsync`, `ChangeIPAsync`, `ChangeLinkStateAsync`, `ChangeMTUAsync`, `ChangeSecGroupsAsync`, `CloneAsync`, `DeleteAsync`, `DisableAsync`, `DiskAddAsync`, `DiskDelAsync`, `DiskAttachAsync`, `DiskDetachAsync`, `DiskQOSAsync`, `DiskResizeAsync`, `DiskSwitchToReplicationAsync`, `GuestAgentDisableAsync`, `GuestAgentEnableAsync`, `GuestAgentExecuteRequestAsync`, `GuestAgentFeatureUpdateAsync`, `MigrateToZoneAsync`, `MoveToRGAsync`, `NetAttachAsync`, `NetDetachAsync`, `PauseAsync`, `PFWAddAsync`, `PFWDelAsync`, `PinToNodeAsync`, `PowerCycleAsync`, `RebootAsync`, `RedeployAsync`, `ResetAsync`, `ResizeAsync`, `RestoreAsync`, `ResumeAsync`, `StartAsync` и `StopAsync` в cloudapi/compute |
|
||||
| BGOS-894 | Опциональное поле `ReadOnly` в структуры запросов `DiskAddRequest` и `DiskAttachRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-894 | Опциональное поле `ReadOnly` в структуры ответа `InfoDisk` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-894 | Опциональное поле `ReadOnly` в структуру ответа `ItemComputeDisk` в cloudapi/compute |
|
||||
| BGOS-894 | Опциональное поле `ReadOnly` в структуру ответа `ItemDisk` в cloudbroker/compute |
|
||||
| BGOS-916 | Вычисляемые поля `Compute` и `MemoryDumpImage` в структуру ответа `ItemSnapSet` в cloudapi/image |
|
||||
|
||||
#### disks
|
||||
#### node
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-895 | Вычисляемое поле `ComputesReadOnly` в структуру ответа `InfoDisk` в cloudbroker/disks |
|
||||
| BGOS-895 | Вычисляемое поле `ComputesReadOnly` в структуры ответа `ItemDisk` и `RecordDisk` в cloudapi/disks |
|
||||
|
||||
#### extnet
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-876 | Вычисляемое поле `FreeIPs` в структуру ответа `ItemExtNet` в cloudapi/extnet |
|
||||
|
||||
#### grid
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-888 | Вычисляемые поля `CPUAllocationRatio`, `CPUAllocationRatioVM`, `CustomBackupPath`, `InterfaceGenerationScheme`, `MACAddressPrefix`, `NodeSelfStopTimerUptimeMonitor` и `NodeSelfStopUptimeMonitor` в структуру ответа `RecordSettingsGrid` в cloudbroker/grid |
|
||||
| BGOS-888 | Вычисляемое поле `ZeroAccessEnabled` в структуру ответа `RecordGrid` в cloudbroker/grid |
|
||||
| BGOS-888 | Вычисляемое поле `Policies` в структуру ответа `RecordResource` и структура ответа `PolicyUsage` в cloudbroker/grid |
|
||||
|
||||
#### kvmx86
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-865 | Опциональное поле `CPUAlignmentProfile` в структуры запросов `CreateRequest` и `CreateBlankRequest` в cloudapi/kvmx86 и cloudbroker/kvmx86 |
|
||||
| BGOS-865 | Опциональное поле `CPUAlignmentProfile` в структуру запроса `MassCreateRequest` в cloudbroker/kvmx86 |
|
||||
| BGOS-877 | Опциональное поле `Clock` в структуры запросов `CreateRequest` и `CreateBlankRequest` в cloudapi/kvmx86 и cloudbroker/kvmx86 |
|
||||
| BGOS-877 | Опциональное поле `Clock` в структуру запроса `MassCreateRequest` в cloudbroker/kvmx86 |
|
||||
|
||||
#### node
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-866 | Вычисляемые поля `OneGAvailable`, `OneGFree`, `OneGReserved`, `OneGUsed`, `OneGDPDKReserved`, `TwoMAvailable`, `TwoMFree`, `TwoMReserved` и `TwoMUsed` в структуру ответа `ItemMemory` в cloudbroker/node |
|
||||
| BGOS-879 | Методы `GetPCIDevices`, `PCIDeviceDriverToVFIO` и `PCIDeviceDriverToKernel` в cloudbroker/node |
|
||||
| BGOS-879 | Структуры запросов `GetPCIDevicesRequest`, `PCIDeviceDriverToVFIORequest` и `PCIDeviceDriverToKernelRequest` в cloudbroker/node |
|
||||
| BGOS-879 | Структуры ответов `RecordPCIDeviceDriver`, `ListPCIDevices` и `ItemPCIDevice` в cloudbroker/node |
|
||||
| BGOS-880 | Вычисляемое поле `PCIDevices` в структуру ответа `ItemNode` в cloudbroker/node |
|
||||
| BGOS-882 | Метод `GetNetworkInfo` и структура запроса `GetNetworkInfoRequest` в cloudbroker/node |
|
||||
| BGOS-882 | Структуры ответа `RecordNodeNetworkInfo`, `SystemNetworkInfo`, `OVSNetworkInfo`, `LibvirtNetworkInfo` и `NetworkTopology` в cloudbroker/node |
|
||||
| BGOS-890 | Структура ответа `ItemNode` для методов `SetCpuAllocationRatio` и `SetMemAllocationRatio` в cloudbroker/node |
|
||||
|
||||
#### sep
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-873 | Метод `Update` и структура запроса `UpdateRequest` в cloudbroker/sep |
|
||||
| BGOS-919 | Вычисляемое поле `MaxSupportedGeneration` в структуру ответа `CpuInfo` в cloudbroker/node |
|
||||
|
||||
#### zone
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-862 | Метод `AddCPUAlignmentProfile` и структура запроса `AddCPUAlignmentProfileRequest` в cloudbroker/zone |
|
||||
| BGOS-862 | Метод `DeleteCPUAlignmentProfile` и структура запроса `DeleteCPUAlignmentProfileRequest` в cloudbroker/zone |
|
||||
| BGOS-862 | Метод `GetCPUAlignmentProfile` и структура запроса `GetCPUAlignmentProfileRequest` в cloudbroker/zone |
|
||||
| BGOS-862 | Метод `ListCPUAlignmentProfile` и структура запроса `ListCPUAlignmentProfileRequest` в cloudbroker/zone |
|
||||
| BGOS-862 | Метод `TestCPUAlignmentProfile` и структура запроса `TestCPUAlignmentProfileRequest` в cloudbroker/zone |
|
||||
| BGOS-862 | Структуры ответов `ListCPUAlignmentProfiles`, `ItemCPUAlignmentProfile`, `TestCPUAlignmentProfileResult` и `CpuAlignmentProfileCandidate` в cloudbroker/zone |
|
||||
| BGOS-863 | Вычисляемое поле `CpuAlignmentProfiles` в структуры ответа `RecordZone` и `ItemZone` и структура `CpuAlignmentProfile` в cloudapi/zone и cloudbroker/zone |
|
||||
| BGOS-914 | Вычисляемые поля `ID`, `Name` и `ConsumedBy` в структуру ответа `RecordConsumption` в cloudbroker/sep |
|
||||
| BGOS-914 | Структура ответа `ListConsumption` в cloudbroker/sep |
|
||||
|
||||
#### SDN logicalports
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-896 | Обязательное поле `ID` в структуру запроса `UpdateAddress` в sdn/logical_port |
|
||||
|
||||
#### SDN netobjgroups
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-884 | Опциональное поле `Type` в структуру запроса `ListRequest` в sdn/netobjgroups |
|
||||
|
||||
### Изменено
|
||||
|
||||
#### account
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-887 | Тип поля `CPUAllocationRatio` с `float64` на `uint64` в структуре ответа `RecordAccount` в cloudapi/account |
|
||||
| BGOS-887 | Тип поля `CPUAllocationRatio` с `float64` на `uint64` в структуре ответа `InfoAccount` в cloudbroker/account |
|
||||
| BGOS-918 | Тип обязательного поля `Ratio` с `float64` на `uint64` в структуре запроса `SetCPUAllocationRatioRequest` в cloudbroker/account |
|
||||
|
||||
#### compute
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
#### SEP
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-874 | Поле `StoragePolicyID` с обязательного на опциональное в структуре запроса `RedeployRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
| BGOS-870 | Тип поля `BLKDiscard` с `bool` на `string` и переименование в `Discard` в структуре ответа `ItemComputeDisk` в cloudapi/compute |
|
||||
| BGOS-870 | Тип поля `BLKDiscard` с `bool` на `string` и переименование в `Discard` в структуре ответа `ItemDisk` в cloudbroker/compute|
|
||||
| BGOS-870 | Тип поля `BLKDiscard` с `bool` на `string` и переименование в `Discard` в структуре запроса `DiskAddRequest` в cloudbroker/compute|
|
||||
| BGOS-885 | Тип возвращаемого значения с `string` на `bool` в методе `Restore` в cloudapi/compute |
|
||||
| BGOS-885 | Тип возвращаемого значения с `string` на `bool` в методе `MigrateStorageAbort` в cloudbroker/compute |
|
||||
| BGOS-885 | Тип возвращаемого значения с `string` на `bool` в методе `MigrateStorageCleanUp` в cloudbroker/compute |
|
||||
| BGOS-885 | Название метода с `Validate` на `MoveToRG` в cloudbroker/compute |
|
||||
| BGOS-893 | Тип поля `SDNObjectGroupID` с `string` на `[]string` и переименование в `SDNObjectGroupIDs` в структуре запроса `NetAttachRequest` в cloudapi/compute и cloudbroker/compute |
|
||||
|
||||
|
||||
#### disks
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-870 | Тип поля `BLKDiscard` с `bool` на `string` и переименование в `Discard` в структурах ответа `RecordDisk`, `ItemDisk` и `ItemDiskUnattached` в cloudapi/disks |
|
||||
| BGOS-870 | Тип поля `BLKDiscard` с `bool` на `string` и переименование в `Discard` в структуре ответа `InfoDisk` в cloudbroker/disks |
|
||||
| BGOS-870 | Тип поля `BLKDiscard` с `bool` на `string` и переименование в `Discard` в структурах запросов `CreateRequest` и `UpdateRequest` в cloudbroker/disks |
|
||||
| BGOS-881 | Поле `StoragePolicyID` c опционального на обязательное в структуре запроса `MigrateRequest` в cloudbroker/disks |
|
||||
|
||||
#### grid
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-888 | Тип поля `Ratio` с `float64` на `uint64` в структурах запросов `SetCPUAllocationRatioRequest`, `SetCPUAllocationRatioForVMRequest` и `SetMemAllocationRatioRequest` в cloudbroker/grid |
|
||||
|
||||
#### image
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-860 | Тип ответа метода `MultiImageExport` со `string` на `uint64` в cloudbroker/image |
|
||||
| BGOS-869 | Тип вычисляемого поля `AccountID` с опционального на обязательный в структуре `CreateVirtualRequest` в cloudapi/image |
|
||||
| BGOS-878 | Тип поля `TypeImage` в структуре запроса `ListRequest` с `string` на `[]string` в cloudbroker/image и cloudapi/image |
|
||||
|
||||
#### kvmx86
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-870 | Тип поля `BLKDiscard` с `bool` на `string` и переименование в `Discard` в структуре ответа `DataDisk` в cloudbroker/kvmx86 |
|
||||
| BGOS-870 | Тип поля `BootDiskBLKDiscard` с `bool` на `string` и переименование в `BootDiskDiscard` в структурах запросов `CreateRequest`, `CreateBlankRequest` и `MassCreateRequest` в cloudbroker/kvmx86 |
|
||||
| BGOS-893 | Тип поля `SDNObjectGroupID` с `string` на `[]string` и переименование в `SDNObjectGroupIDs` в структуре `Interface` в cloudapi/kvmx86 и cloudbroker/kvmx86 |
|
||||
| BGOS-893 | Тип поля `SDNObjectGroupID` с `string` на `[]string` и переименование в `SDNObjectGroupIDs` в структуре `InterfaceMassCreate` в cloudbroker/kvmx86 |
|
||||
|
||||
#### node
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-867 | Тип обязательного поля `Ratio` с `float64` на `uint64` в структурах запросов `SetMemAllocationRatioRequest` и `SetCpuAllocationRatioRequest` в cloudbroker/node |
|
||||
| BGOS-889 | Тип поля `VCPU` с `float64` на `uint64` в структуре ответа `FreeResourcesInfo` в cloudbroker/node |
|
||||
| BGOS-889 | Тип полей `CPUAllocationRatio` и `MemAllocationRatio` с `float64` на `uint64` в структурах ответа `RecordNode` и `ItemNode` в cloudbroker/node |
|
||||
|
||||
#### resmon
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-868 | Тип поля `EndTime` с обязательного на опциональное в структурах запроса `GetByNodeRequest`, `GetByNodesRequest` `GetByGRIDRequest`, `GetByComputeRequest` и `GetByComputesRequest` в cloudbroker/resmon |
|
||||
|
||||
#### rg
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-886 | Тип поля `CPUAllocationRatio` с `float64` на `uint64` в структурах ответа `RecordResourceGroup` и `ItemResourceGroup` в cloudapi/rg |
|
||||
| BGOS-886 | Тип поля `CPUAllocationRatio` с `float64` на `uint64` в структуре ответа `ItemRG` в cloudbroker/rg |
|
||||
| BGOS-886 | Тип поля `Ratio` с `float64` на `uint64` в структуре запроса `SetCPUAllocationRatioRequest` в cloudbroker/rg |
|
||||
|
||||
#### user
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-891 | Тип поля `Password` с опционального на обязательный в структуре запроса `CreateRequest` в cloudbroker/user |
|
||||
|
||||
#### SDN logicalports
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-896 | Тип полей `IsDiscovered` и `MAC` с опционального на обязательный в структурах запроса `UpdateAddress` и `AddAddress` в sdn/logical_port |
|
||||
| BGOS-896 | Тип поля `IsDiscovered` с опционального на обязательный в структуре запроса `LogicalPortAddressRequest` в sdn/logical_port
|
||||
| BGOS-896 | Тип полей `IsDiscovered`, `MAC` с `interface` на `bool` в структурах запроса `UpdateAddress`, `AddAddress`, `LogicalPortAddressRequest` в sdn/logical_port/update |
|
||||
|
||||
### Исправлено
|
||||
|
||||
#### vfpool
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-871 | Тип поля `Config` в структуре запроса `wrapperUpdateRequest` с `[]string` на `string` в cloudbroker/vfpool |
|
||||
|
||||
### Удалено
|
||||
|
||||
#### grid
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-888 | Вычисляемые поля `CKey` и `Meta` из структуры ответа `RecordGrid` в cloudbroker/grid |
|
||||
|
||||
#### user
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-861 | Значение по умолчанию опционального поля `Password` в структуре запроса `CreateRequest` в cloudbroker/user |
|
||||
| BGOS-875 | Опциональное поле `Password` из структуры ответа `ItemUser` в cloudbroker/user |
|
||||
| BGOS-914 | Тип поля `SEPID` с обязательного на опциональный в структуре запроса `ConsumptionRequest` в cloudbroker/sep |
|
||||
| BGOS-914 | Тип ответа метода `Consumption` с `RecordConsumption` на `ListConsumption` в cloudbroker/sep |
|
||||
|
||||
@@ -36,6 +36,10 @@ type DecortClient struct {
|
||||
|
||||
// Сlient builder
|
||||
func New(cfg config.Config) *DecortClient {
|
||||
if err := validators.ValidateConfig(cfg); err != nil {
|
||||
panic(validators.ValidationErrors(validators.GetErrors(err)))
|
||||
}
|
||||
|
||||
if cfg.Retries == 0 {
|
||||
cfg.Retries = 5
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/google/go-querystring/query"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn"
|
||||
@@ -38,6 +39,10 @@ type tokenJSON struct {
|
||||
|
||||
// Сlient builder
|
||||
func NewBVS(cfg config.BVSConfig) *BVSDecortClient {
|
||||
if err := validators.ValidateConfig(cfg); err != nil {
|
||||
panic(validators.ValidationErrors(validators.GetErrors(err)))
|
||||
}
|
||||
|
||||
if cfg.Retries == 0 {
|
||||
cfg.Retries = 5
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/google/go-querystring/query"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn"
|
||||
@@ -32,6 +33,10 @@ type LegacyDecortClient struct {
|
||||
|
||||
// Legacy client builder
|
||||
func NewLegacy(cfg config.LegacyConfig) *LegacyDecortClient {
|
||||
if err := validators.ValidateConfig(cfg); err != nil {
|
||||
panic(validators.ValidationErrors(validators.GetErrors(err)))
|
||||
}
|
||||
|
||||
if cfg.Retries == 0 {
|
||||
cfg.Retries = 5
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ type ItemSnapshot struct {
|
||||
// Compute info
|
||||
Compute RecordCompute `json:"compute"`
|
||||
|
||||
// List disk ID
|
||||
// List of disk IDs
|
||||
Disks []uint64 `json:"disks"`
|
||||
|
||||
// GUID
|
||||
@@ -690,7 +690,10 @@ type ListOSUser []ItemOSUser
|
||||
|
||||
// Main information about snapsets
|
||||
type ItemSnapSet struct {
|
||||
// List disk IDs
|
||||
// Compute info
|
||||
Compute RecordCompute `json:"compute"`
|
||||
|
||||
// List disk ID
|
||||
Disks []uint64 `json:"disks"`
|
||||
|
||||
// GUID
|
||||
@@ -699,6 +702,9 @@ type ItemSnapSet struct {
|
||||
// Label
|
||||
Label string `json:"label"`
|
||||
|
||||
// Memory dump image ID
|
||||
MemoryDumpImage uint64 `json:"memory_dump_image"`
|
||||
|
||||
// Timestamp
|
||||
Timestamp uint64 `json:"timestamp"`
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
@@ -102,6 +103,6 @@ func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
url := "/cloudapi/image/list"
|
||||
|
||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package kvmx86
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
@@ -231,7 +231,6 @@ type CreateRequest struct {
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r CreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
@@ -239,12 +238,6 @@ func (r CreateRequest) GetRAM() map[string]uint64 {
|
||||
return res
|
||||
}
|
||||
|
||||
type wrapperCreateRequest struct {
|
||||
CreateRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
DataDisks []string `url:"dataDisks,omitempty"`
|
||||
}
|
||||
|
||||
// Create creates KVM x86 VM based on specified OS image
|
||||
func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -252,55 +245,12 @@ func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
var interfaces []string
|
||||
|
||||
if len(req.Interfaces) != 0 {
|
||||
interfaces = make([]string, 0, len(req.Interfaces))
|
||||
|
||||
for i := range req.Interfaces {
|
||||
b, err := json.Marshal(req.Interfaces[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
}
|
||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateRequest{
|
||||
CreateRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
url := "/cloudapi/kvmx86/create"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return strconv.ParseUint(string(res), 10, 64)
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package kvmx86
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
@@ -136,12 +136,6 @@ func (r CreateBlankRequest) GetRAM() map[string]uint64 {
|
||||
return res
|
||||
}
|
||||
|
||||
type wrapperCreateBlankRequest struct {
|
||||
CreateBlankRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
DataDisks []string `url:"dataDisks,omitempty"`
|
||||
}
|
||||
|
||||
// CreateBlank creates KVM x86 VM from scratch
|
||||
func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -149,55 +143,12 @@ func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
var interfaces []string
|
||||
|
||||
if len(req.Interfaces) != 0 {
|
||||
interfaces = make([]string, 0, len(req.Interfaces))
|
||||
|
||||
for i := range req.Interfaces {
|
||||
b, err := json.Marshal(req.Interfaces[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
}
|
||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateBlankRequest{
|
||||
CreateBlankRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
url := "/cloudapi/kvmx86/createBlank"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return strconv.ParseUint(string(res), 10, 64)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ type SetCPUAllocationRatioRequest struct {
|
||||
|
||||
// CPU allocation ratio, i.e. one pCPU = ratio*vCPU
|
||||
// Required: true
|
||||
Ratio float64 `url:"ratio" json:"ratio" validate:"required"`
|
||||
Ratio uint64 `url:"ratio" json:"ratio" validate:"required"`
|
||||
}
|
||||
|
||||
// SetCPUAllocationRatio sets CPU allocation ratio
|
||||
|
||||
@@ -18,11 +18,6 @@ type MigrateRequest struct {
|
||||
// Particular Node ID to migrate this compute to
|
||||
// Required: false
|
||||
TargetNodeID uint64 `url:"targetNodeId,omitempty" json:"targetNodeId,omitempty"`
|
||||
|
||||
// If live migration fails, destroy compute
|
||||
// on source node and recreate on the target
|
||||
// Required: false
|
||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||
}
|
||||
|
||||
type AsyncWrapperMigrateRequest struct {
|
||||
|
||||
@@ -12,15 +12,19 @@ import (
|
||||
// Must be provided if NewVMUUID is provided.
|
||||
type OSUser struct {
|
||||
// Login of a user
|
||||
Login string `url:"login,omitempty" json:"login,omitempty"`
|
||||
// Required: true
|
||||
Login string `url:"login" json:"login" validate:"required"`
|
||||
|
||||
// Password of a user
|
||||
Password string `url:"password,omitempty" json:"password,omitempty"`
|
||||
// Required: true
|
||||
Password string `url:"password" json:"password" validate:"required"`
|
||||
|
||||
// GUID
|
||||
// Required: false
|
||||
GUID string `url:"guid,omitempty" json:"guid,omitempty"`
|
||||
|
||||
// Pubkey
|
||||
// Required: false
|
||||
Pubkey string `url:"pubkey,omitempty" json:"pubkey,omitempty"`
|
||||
}
|
||||
|
||||
@@ -36,7 +40,7 @@ type StopMigrationINRequest struct {
|
||||
|
||||
// OS user data for Guest OS
|
||||
// Required: false
|
||||
OSUsers []OSUser `url:"os_users,omitempty" json:"os_users,omitempty"`
|
||||
OSUsers []OSUser `url:"os_users,omitempty" json:"os_users,omitempty" validate:"omitempty,dive"`
|
||||
}
|
||||
|
||||
// StopMigrationIN stops compute for external migration in
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
@@ -102,6 +103,6 @@ func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
url := "/cloudbroker/image/list"
|
||||
|
||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package kvmx86
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
@@ -254,7 +254,6 @@ type CreateRequest struct {
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r CreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
@@ -262,12 +261,6 @@ func (r CreateRequest) GetRAM() map[string]uint64 {
|
||||
return res
|
||||
}
|
||||
|
||||
type wrapperCreateRequest struct {
|
||||
CreateRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
DataDisks []string `url:"dataDisks,omitempty"`
|
||||
}
|
||||
|
||||
// Create creates KVM PowerPC VM based on specified OS image
|
||||
func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -275,55 +268,12 @@ func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
var interfaces []string
|
||||
|
||||
if len(req.Interfaces) != 0 {
|
||||
interfaces = make([]string, 0, len(req.Interfaces))
|
||||
|
||||
for i := range req.Interfaces {
|
||||
b, err := json.Marshal(req.Interfaces[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
}
|
||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateRequest{
|
||||
CreateRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/kvmx86/create"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return strconv.ParseUint(string(res), 10, 64)
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package kvmx86
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
@@ -149,12 +149,6 @@ func (r CreateBlankRequest) GetRAM() map[string]uint64 {
|
||||
return res
|
||||
}
|
||||
|
||||
type wrapperCreateBlankRequest struct {
|
||||
CreateBlankRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
DataDisks []string `url:"dataDisks,omitempty"`
|
||||
}
|
||||
|
||||
// CreateBlank creates KVM x86 VM from scratch
|
||||
func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -162,56 +156,12 @@ func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
var interfaces []string
|
||||
|
||||
if len(req.Interfaces) != 0 {
|
||||
interfaces = make([]string, 0, len(req.Interfaces))
|
||||
|
||||
for i := range req.Interfaces {
|
||||
b, err := json.Marshal(req.Interfaces[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
}
|
||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateBlankRequest{
|
||||
CreateBlankRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/kvmx86/createBlank"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
return strconv.ParseUint(string(res), 10, 64)
|
||||
}
|
||||
|
||||
@@ -3,8 +3,11 @@ package kvmx86
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
@@ -177,14 +180,8 @@ type MassCreateRequest struct {
|
||||
Clock string `url:"clock,omitempty" json:"clock,omitempty"`
|
||||
}
|
||||
|
||||
type asyncWrapperMassCreateRequest struct {
|
||||
wrapperMassCreateRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r MassCreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
@@ -194,8 +191,24 @@ func (r MassCreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
type wrapperMassCreateRequest struct {
|
||||
MassCreateRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
DataDisks []string `url:"dataDisks,omitempty"`
|
||||
AsyncMode bool `json:"asyncMode"`
|
||||
}
|
||||
|
||||
type massCreateResponse struct {
|
||||
Created []uint64 `json:"created"`
|
||||
Errors map[string]string `json:"errors"`
|
||||
}
|
||||
|
||||
type MassCreateError struct {
|
||||
Errors map[string]string
|
||||
}
|
||||
|
||||
func (e *MassCreateError) Error() string {
|
||||
errs := make([]error, 0, len(e.Errors))
|
||||
for k, v := range e.Errors {
|
||||
errs = append(errs, fmt.Errorf("%s: %s", k, v))
|
||||
}
|
||||
return errors.Join(errs...).Error()
|
||||
}
|
||||
|
||||
// MassCreate creates KVM x86 computes based on specified OS image
|
||||
@@ -205,113 +218,42 @@ func (k KVMX86) MassCreate(ctx context.Context, req MassCreateRequest) ([]uint64
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
var interfaces []string
|
||||
|
||||
if len(req.Interfaces) != 0 {
|
||||
interfaces = make([]string, 0, len(req.Interfaces))
|
||||
|
||||
for i := range req.Interfaces {
|
||||
b, err := json.Marshal(req.Interfaces[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
}
|
||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperMassCreateRequest{
|
||||
MassCreateRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
finalReq := asyncWrapperMassCreateRequest{wrapperMassCreateRequest: reqWrapped, AsyncMode: false}
|
||||
|
||||
url := "/cloudbroker/kvmx86/massCreate"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, finalReq)
|
||||
res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, wrapperMassCreateRequest{
|
||||
MassCreateRequest: req,
|
||||
AsyncMode: false,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
computes := make([]uint64, 0)
|
||||
var result massCreateResponse
|
||||
|
||||
err = json.Unmarshal(res, &computes)
|
||||
if err != nil {
|
||||
if err = json.Unmarshal(res, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return computes, nil
|
||||
if len(result.Errors) > 0 {
|
||||
return result.Created, &MassCreateError{Errors: result.Errors}
|
||||
}
|
||||
|
||||
return result.Created, nil
|
||||
}
|
||||
|
||||
// MassCreate creates KVM x86 computes based on specified OS image in async mode
|
||||
// MassCreateAsync creates KVM x86 computes based on specified OS image in async mode
|
||||
func (k KVMX86) MassCreateAsync(ctx context.Context, req MassCreateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
var interfaces []string
|
||||
|
||||
if len(req.Interfaces) != 0 {
|
||||
interfaces = make([]string, 0, len(req.Interfaces))
|
||||
|
||||
for i := range req.Interfaces {
|
||||
b, err := json.Marshal(req.Interfaces[i])
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
}
|
||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperMassCreateRequest{
|
||||
MassCreateRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
finalReq := asyncWrapperMassCreateRequest{wrapperMassCreateRequest: reqWrapped, AsyncMode: true}
|
||||
|
||||
url := "/cloudbroker/kvmx86/massCreate"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, finalReq)
|
||||
res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, wrapperMassCreateRequest{
|
||||
MassCreateRequest: req,
|
||||
AsyncMode: true,
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
76
pkg/cloudbroker/node/install.go
Normal file
76
pkg/cloudbroker/node/install.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// InstallRequest struct to install a node
|
||||
type InstallRequest struct {
|
||||
// Node name
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// Node roles
|
||||
// Required: true
|
||||
Roles []string `url:"roles" json:"roles" validate:"required"`
|
||||
|
||||
// OS version
|
||||
// Required: true
|
||||
OSVersion string `url:"os_version" json:"os_version" validate:"required"`
|
||||
|
||||
// OS user
|
||||
// Required: false
|
||||
OSUser string `url:"os_user,omitempty" json:"os_user,omitempty"`
|
||||
|
||||
// OS user password
|
||||
// Required: true
|
||||
OSUserPassword string `url:"os_user_password" json:"os_user_password" validate:"required"`
|
||||
|
||||
// Backplane IP address
|
||||
// Required: true
|
||||
BackplaneIP string `url:"backplane_ip" json:"backplane_ip" validate:"required"`
|
||||
|
||||
// Management IP address
|
||||
// Required: true
|
||||
ManagementIP string `url:"management_ip" json:"management_ip" validate:"required"`
|
||||
|
||||
// VX backend IP address
|
||||
// Required: true
|
||||
VXBackendIP string `url:"vxbackend_ip" json:"vxbackend_ip" validate:"required"`
|
||||
|
||||
// Gateway management IP address
|
||||
// Required: true
|
||||
GWMgmtIP string `url:"gw_mgmt_ip" json:"gw_mgmt_ip" validate:"required"`
|
||||
|
||||
// IPMI address
|
||||
// Required: true
|
||||
IPMIAddress string `url:"ipmi_address" json:"ipmi_address" validate:"required"`
|
||||
|
||||
// IPMI user
|
||||
// Required: true
|
||||
IPMIUser string `url:"ipmi_user" json:"ipmi_user" validate:"required"`
|
||||
|
||||
// IPMI password
|
||||
// Required: true
|
||||
IPMIPassword string `url:"ipmi_password" json:"ipmi_password" validate:"required"`
|
||||
}
|
||||
|
||||
// Install installs a node
|
||||
func (n Node) Install(ctx context.Context, req InstallRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/install"
|
||||
|
||||
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -161,8 +161,11 @@ type CpuInfo struct {
|
||||
// Flags
|
||||
Flags []string `json:"flags"`
|
||||
|
||||
// Mddel name
|
||||
// Model name
|
||||
ModelName string `json:"model_name"`
|
||||
|
||||
// Max supported generation
|
||||
MaxSupportedGeneration string `json:"max_supported_generation"`
|
||||
}
|
||||
|
||||
// Main information about node
|
||||
|
||||
@@ -11,12 +11,12 @@ import (
|
||||
// ConsumptionRequest struct to get consumption info
|
||||
type ConsumptionRequest struct {
|
||||
// Storage endpoint provider ID
|
||||
// Required: true
|
||||
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"`
|
||||
}
|
||||
|
||||
// Consumption gets SEP consumption info
|
||||
func (s SEP) Consumption(ctx context.Context, req ConsumptionRequest) (*RecordConsumption, error) {
|
||||
func (s SEP) Consumption(ctx context.Context, req ConsumptionRequest) (*ListConsumption, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
@@ -29,7 +29,7 @@ func (s SEP) Consumption(ctx context.Context, req ConsumptionRequest) (*RecordCo
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordConsumption{}
|
||||
info := ListConsumption{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
|
||||
@@ -47,8 +47,22 @@ type ByPool struct {
|
||||
UsageLimit uint64 `json:"usage_limit"`
|
||||
}
|
||||
|
||||
// List of Resource groups
|
||||
type ListConsumption struct {
|
||||
// Data
|
||||
Data []RecordConsumption `json:"data"`
|
||||
|
||||
// Enrtry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main information about consumption
|
||||
type RecordConsumption struct {
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
// By pool
|
||||
ByPool map[string]ByPool `json:"byPool"`
|
||||
|
||||
@@ -57,6 +71,9 @@ type RecordConsumption struct {
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// Consumed by
|
||||
ConsumedBy []uint64 `json:"consumedBy"`
|
||||
}
|
||||
|
||||
// Main information about URI
|
||||
|
||||
@@ -12,6 +12,21 @@ type CpuAlignmentProfile struct {
|
||||
Model string `json:"model"`
|
||||
}
|
||||
|
||||
// Supported CPU model
|
||||
type SupportedCpuModel struct {
|
||||
// Vendor
|
||||
Vendor string `json:"vendor"`
|
||||
|
||||
// Model
|
||||
Model string `json:"model"`
|
||||
|
||||
// Count
|
||||
Count uint64 `json:"count"`
|
||||
|
||||
// Percentage
|
||||
Percentage float64 `json:"percentage"`
|
||||
}
|
||||
|
||||
// CPU alignment profile candidate
|
||||
type CpuAlignmentProfileCandidate struct {
|
||||
// Profile name
|
||||
@@ -27,7 +42,7 @@ type CpuAlignmentProfileCandidate struct {
|
||||
Count uint64 `json:"count"`
|
||||
|
||||
// Percentage
|
||||
Percentage uint64 `json:"percentage"`
|
||||
Percentage float64 `json:"percentage"`
|
||||
|
||||
// Required count
|
||||
RequiredCount uint64 `json:"required_count"`
|
||||
@@ -40,6 +55,9 @@ type TestCPUAlignmentProfileResult struct {
|
||||
|
||||
// Candidates
|
||||
Candidates []CpuAlignmentProfileCandidate `json:"candidates"`
|
||||
|
||||
// Supported CPU models
|
||||
SupportedCpuModels []SupportedCpuModel `json:"supported_cpu_models"`
|
||||
}
|
||||
|
||||
// Item for list_cpu_alignment_profile response
|
||||
|
||||
@@ -116,8 +116,8 @@ type AddAddress struct {
|
||||
IsPrimary interface{} `url:"is_primary" json:"is_primary" validate:"required,isBool"`
|
||||
|
||||
// MAC address
|
||||
// Required: false
|
||||
MAC string `url:"mac,omitempty" json:"mac,omitempty"`
|
||||
// Required: true
|
||||
MAC string `url:"mac" json:"mac" validate:"required"`
|
||||
}
|
||||
|
||||
// Update updates a logical port
|
||||
|
||||
@@ -711,7 +711,7 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
getResult("Node list", bytes, node_cb.ListNodes{}, t)
|
||||
// Get
|
||||
listNode, _ := client.CloudBroker().Node().List(context.Background(), node_cb.ListRequest{})
|
||||
if len(listLB.Data) > 0 {
|
||||
if listNode != nil && len(listNode.Data) > 0 {
|
||||
id := listNode.Data[0].ID
|
||||
bytes, err = client.CloudBroker().Node().GetRaw(context.Background(), node_cb.GetRequest{NID: id})
|
||||
if err != nil {
|
||||
@@ -725,11 +725,11 @@ func TestGetListCloudbroker(t *testing.T) {
|
||||
}
|
||||
getResult("Node get_network_info", bytes, node_cb.RecordNodeNetworkInfo{}, t)
|
||||
} else {
|
||||
t.Errorf("Can not test Node get because LB list is empty")
|
||||
t.Errorf("Can not test Node get because node list is empty")
|
||||
}
|
||||
|
||||
// Node GetPCIDevices
|
||||
if len(listNode.Data) > 0 {
|
||||
if listNode != nil && len(listNode.Data) > 0 {
|
||||
id := listNode.Data[0].ID
|
||||
bytes, err = client.CloudBroker().Node().GetPCIDevicesRaw(context.Background(), node_cb.GetPCIDevicesRequest{NodeID: id})
|
||||
if err != nil {
|
||||
|
||||
@@ -912,6 +912,7 @@ func getRequestsMapCloudbroker() map[string]interface{} {
|
||||
"/restmachine/cloudbroker/node/get_pci_devices": node_cb.GetPCIDevicesRequest{},
|
||||
"/restmachine/cloudbroker/node/pci_device_driver_to_vfio": node_cb.PCIDeviceDriverToVFIORequest{},
|
||||
"/restmachine/cloudbroker/node/pci_device_driver_to_kernel": node_cb.PCIDeviceDriverToKernelRequest{},
|
||||
"/restmachine/cloudbroker/node/install": node_cb.InstallRequest{},
|
||||
|
||||
// pcidevice
|
||||
"/restmachine/cloudbroker/pcidevice/create": pcidevice_cb.CreateRequest{},
|
||||
|
||||
@@ -183,6 +183,9 @@ func GetMapFromBytes(bytes []byte) (map[string]interface{}, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(unmarshalSlice) == 0 {
|
||||
return map[string]interface{}{}, nil
|
||||
}
|
||||
t, ok := unmarshalSlice[0].(map[string]interface{})
|
||||
if !ok {
|
||||
return nil, err
|
||||
@@ -228,10 +231,20 @@ func getMapBytes(value map[string]interface{}) map[string]interface{} {
|
||||
func GetMapFromStructure(structure any) map[string]interface{} {
|
||||
typ := reflect.TypeOf(structure)
|
||||
|
||||
return getMapStruct(typ)
|
||||
for typ.Kind() == reflect.Slice || typ.Kind() == reflect.Ptr {
|
||||
typ = typ.Elem()
|
||||
}
|
||||
|
||||
return getMapStruct(typ, make(map[reflect.Type]bool))
|
||||
}
|
||||
|
||||
func getMapStruct(t reflect.Type) map[string]interface{} {
|
||||
func getMapStruct(t reflect.Type, visited map[reflect.Type]bool) map[string]interface{} {
|
||||
if visited[t] {
|
||||
return map[string]interface{}{}
|
||||
}
|
||||
visited[t] = true
|
||||
defer func() { visited[t] = false }()
|
||||
|
||||
temporary := make(map[string]interface{})
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
tag := t.Field(i).Tag.Get("json")
|
||||
@@ -243,16 +256,16 @@ func getMapStruct(t reflect.Type) map[string]interface{} {
|
||||
elem := t.Field(i).Type.Elem()
|
||||
switch elem.Kind() {
|
||||
case reflect.Struct:
|
||||
temporary[tag] = getMapStruct(elem)
|
||||
temporary[tag] = getMapStruct(elem, visited)
|
||||
default:
|
||||
temporary[tag] = map[string]interface{}{}
|
||||
}
|
||||
|
||||
case reflect.Struct:
|
||||
if tag == "" {
|
||||
return getMapStruct(t.Field(i).Type)
|
||||
return getMapStruct(t.Field(i).Type, visited)
|
||||
} else {
|
||||
temporary[tag] = getMapStruct(t.Field(i).Type)
|
||||
temporary[tag] = getMapStruct(t.Field(i).Type, visited)
|
||||
}
|
||||
// в этом месте работает некорректно для вложенных структур без json тегов (scope - все в cloudbroker)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user