From dca445b69a35e1561ba7eed0caad733c3f162c89 Mon Sep 17 00:00:00 2001 From: Alexey Fetisov Date: Mon, 28 Sep 2026 13:20:06 +0300 Subject: [PATCH] v16.5.0 --- CHANGELOG.md | 104 ++--- pkg/cloudapi/audit/audit.go | 4 +- pkg/cloudapi/audit/models.go | 36 ++ pkg/cloudapi/compute/affinity_rule_add.go | 28 +- .../compute/anti_affinity_rule_add.go | 28 +- .../compute/create_template_from_blank.go | 4 - pkg/cloudapi/compute/models.go | 50 +++ pkg/cloudapi/disks/from_platform_disk.go | 4 - pkg/cloudapi/extnet/models.go | 9 + pkg/cloudapi/kvmx86/create.go | 8 + pkg/cloudapi/kvmx86/create_blank.go | 8 + pkg/cloudbroker/apiaccess/update.go | 2 +- pkg/cloudbroker/audit/audit.go | 4 +- pkg/cloudbroker/audit/models.go | 36 ++ pkg/cloudbroker/compute/affinity_rule_add.go | 28 +- .../compute/anti_affinity_rule_add.go | 28 +- pkg/cloudbroker/compute/migrate_v2.go | 83 ++++ pkg/cloudbroker/compute/migrate_v2_abort.go | 47 +++ pkg/cloudbroker/compute/migrate_v2_cleanup.go | 41 ++ pkg/cloudbroker/compute/migrate_v2_get.go | 46 +++ pkg/cloudbroker/compute/migrate_v2_list.go | 67 ++++ pkg/cloudbroker/compute/migrate_v2_resolve.go | 51 +++ pkg/cloudbroker/compute/models.go | 379 ++++++++++++++++++ pkg/cloudbroker/extnet/models.go | 15 +- pkg/cloudbroker/grid/models.go | 6 + pkg/cloudbroker/k8ci/access_add.go | 2 +- pkg/cloudbroker/k8ci/access_remove.go | 2 +- pkg/cloudbroker/kvmx86/create.go | 8 + pkg/cloudbroker/kvmx86/create_blank.go | 8 + 29 files changed, 1005 insertions(+), 131 deletions(-) create mode 100644 pkg/cloudbroker/compute/migrate_v2.go create mode 100644 pkg/cloudbroker/compute/migrate_v2_abort.go create mode 100644 pkg/cloudbroker/compute/migrate_v2_cleanup.go create mode 100644 pkg/cloudbroker/compute/migrate_v2_get.go create mode 100644 pkg/cloudbroker/compute/migrate_v2_list.go create mode 100644 pkg/cloudbroker/compute/migrate_v2_resolve.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c452737..d3a2a0c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,9 @@ -## Version 16.4.0 +## Version 16.5.0 ### Deprecated -Перечисленные методы будут удалены в `v1.17` +Перечисленные методы будут удалены в `v17.0.0` | Метод | CloudAPI | CloudBroker | | --- | --- | --- | @@ -18,98 +18,62 @@ | `rg/AccessRevoke` | :heavy_check_mark: | :heavy_check_mark: | | `sep/ConfigFieldEdit` | :x: | :heavy_check_mark: | + ### Добавлено -#### apiaccess +#### audit | Идентификатор задачи | Описание | | --- | --- | -| BGOS-1055 | Структура `SDNEndpoints` и опциональное поле `SDN` в структуру `APIsEndpoints` в cloudbroker/apiaccess | -| BGOS-1055 | Опциональные поля `Audit`, `DPDKNet`, `SecurityGroup`, `SEP`, `StoragePolicy`, `Trunk`, `VFPool`, `VMFolder`, `Zone` в структуру `CloudAPIEndpoints` в cloudbroker/apiaccess | -| BGOS-1055 | Опциональные поля `Backup`, `DPDKNet`, `SecurityGroup`, `StoragePolicy`, `Trunk`, `VFPool`, `VMFolder`, `Zone` в структуру `CloudBrokerEndpoints` в cloudbroker/apiaccess | -| BGOS-1055 | Опциональные поля `Cache`, `InfoWellknown` в структуру `SystemEndpoints` в cloudbroker/apiaccess | +| BGOS-1072 | Вычисляемые поля `ResgroupID`, `AccountID`, `ComputeID`, `VINSID`, `ServiceID`, `K8SID`, `FLIPGroupID`, `LBID`, `SEPID`, `NodeIDs`, `DiskIDs` и `APITask` в структуру ответа `ItemAudit` в cloudapi/audit | +| BGOS-1072 | Вычисляемые поля `ResgroupID`, `AccountID`, `ComputeID`, `VINSID`, `ServiceID`, `K8SID`, `FLIPGroupID`, `LBID`, `SEPID`, `NodeIDs`, `DiskIDs` и `APITask` в структуру ответа `ItemAudit` в cloudbroker/audit | #### compute | Идентификатор задачи | Описание | | --- | --- | -| BGOS-1043 | Опциональное поле `AsyncMode` в структуру запроса `SnapshotEvictDiskRequest` в cloudbroker/compute | -| BGOS-1044 | Методы `AsyncAffinityRuleAdd` и `AsyncAntiAffinityRuleAdd` в cloudapi/compute и cloudbroker/compute | -| BGOS-1054 | Опциональные поля `FolderID` и `IncludeDescendants` в структуру запроса `ListRequest` в cloudapi/compute | -| BGOS-1054 | Опциональные поля `FolderID` и `IncludeDescendants` в структуру запроса `ListRequest` в cloudbroker/compute | -| BGOS-1046 | Опциональное поле `Migrate` в структуры запросов `AffinityRuleAddRequest` и `AntiAffinityRuleAddRequest` в cloudapi/compute | -| BGOS-1046 | Опциональное поле `Migrate` в структуры запросов `AffinityRuleAddRequest` и `AntiAffinityRuleAddRequest` в cloudbroker/compute | - -#### session -| Идентификатор задачи | Описание | -| --- | --- | -| BGOS-1048 | Опциональное поле `IncludeArchive` в структуру запроса `ListRequest` в cloudbroker/session | - -#### stpolicy -| Идентификатор задачи | Описание | -| --- | --- | -| BGOS-1047 | Вычисляемое поле `ReplicationProfileID` в структуры ответа `InfoStoragePolicy` и `ItemStoragePolicy` в cloudapi/stpolicy и в cloudbroker/stpolicy | -| BGOS-1047 | Вычисляемое поле `ReplicationProfileID` в структуру ответа `InfoStoragePolicyWithID` в cloudbroker/stpolicy | -| BGOS-1047 | Методы `GetReplicationProfile`, `ListReplicationProfile`, структуры запроса `GetReplicationProfileRequest`, `ListReplicationProfileRequest` и структуры ответа `InfoReplicationProfile`, `ListReplicationProfiles`, `ItemReplicationProfile`, `ListSchedules`, `Schedule`, `Calendar` в cloudapi/stpolicy и в cloudbroker/stpolicy | -| BGOS-1047 | Метод `CreateReplicationProfile`, структуры запроса `CreateReplicationProfileRequest`, `SchedulesRequest`, `CalendarRequest` в cloudbroker/stpolicy | -| BGOS-1047 | Метод `UpdateReplicationProfile`, структуры запроса `UpdateReplicationProfileRequest`, `ConfigRequest` в cloudbroker/stpolicy | -| BGOS-1047 | Метод `DeleteReplicationProfile` и структура запроса `DeleteReplicationProfileRequest` в cloudbroker/stpolicy | -| BGOS-1047 | Методы `AddAccessReplicationProfile`, `RevokeAccessReplicationProfile` и структуры запроса `AddAccessReplicationProfileRequest`, `RevokeAccessReplicationProfileRequest` в cloudbroker/stpolicy | - -#### vmfolder -| Идентификатор задачи | Описание | -| --- | --- | -| BGOS-1049 | Группа апи методов vmfolder в cloudapi и cloudbroker | - -### Изменено - -#### backup -| Идентификатор задачи | Описание | -| --- | --- | -| BGOS-1045 | JSON-тэг опционального поля `AsyncMode` с `asyncMode` на `async_mode` в структурах запроса `CreateDiskBackupRequest`, `CreateDisksBackupRequest`, `DeleteDiskBackupRequest`, `RestoreDiskFromBackupRequest` и `RestoreDisksFromBackupRequest` в cloudbroker/backup | - -#### compute -| Идентификатор задачи | Описание | -| --- | --- | -| BGOS-1043 | JSON-тэг опционального поля `AsyncMode` с `asyncMode` на `async_mode` в структурах запроса `AbortSharedSnapshotMergeRequest`, `CDEjectRequest`, `CDInsertRequest`, `ChangeIPRequest`, `ChangeLinkStateRequest`, `ChangeMTURequest`, `ChangeQoSPoliciesRequest`, `ChangeSecGroupsRequest`, `CloneRequest`, `CreateTemplateRequest`, `CreateTemplateFromBlankRequest`, `DeleteRequest`, `DisableRequest`, `DiskAddRequest`, `DiskAttachRequest`, `DiskDelRequest`, `DiskDetachRequest`, `DiskQOSRequest`, `DiskResizeRequest`, `DiskSwitchToReplicationRequest`, `GuestAgentDisableRequest`, `GuestAgentEnableRequest`, `GuestAgentExecuteRequest`, `GuestAgentFeatureUpdateRequest`, `MigrateToZoneRequest`, `MoveToRGRequest`, `NetAttachRequest`, `NetDetachRequest`, `PauseRequest`, `PFWAddRequest`, `PFWDelRequest`, `PinToNodeRequest`, `PowerCycleRequest`, `RebootRequest`, `RedeployRequest`, `ResetRequest`, `ResizeRequest`, `RestoreRequest`, `ResumeRequest`, `SnapshotCreateRequest`, `SnapshotDeleteRequest`, `SnapshotRollbackRequest`, `StartRequest` и `StopRequest` в cloudapi/compute | -| BGOS-1043 | JSON-тэг опционального поля `AsyncMode` с `asyncMode` на `async_mode` в структурах запроса `AbortSharedSnapshotMergeRequest`, `CDEjectRequest`, `CDInsertRequest`, `ChangeIPRequest`, `ChangeLinkStateRequest`, `ChangeMTURequest`, `ChangeQoSPoliciesRequest`, `ChangeSecGroupsRequest`, `CloneRequest`, `CreateTemplateRequest`, `CreateTemplateFromBlankRequest`, `DeleteRequest`, `DisableRequest`, `DiskAddRequest`, `DiskAttachRequest`, `DiskDelRequest`, `DiskDetachRequest`, `DiskQOSRequest`, `DiskResizeRequest`, `DiskSwitchToReplicationRequest`, `GuestAgentDisableRequest`, `GuestAgentEnableRequest`, `GuestAgentExecuteRequest`, `GuestAgentFeatureUpdateRequest`, `MassDeleteRequest`, `MassRebootRequest`, `MassStartRequest`, `MassStopRequest`, `MigrateAbortRequest`, `MigrateStorageAbortRequest`, `MigrateStorageCleanUpRequest`, `MigrateToZoneRequest`, `MoveToRGRequest`, `NetAttachRequest`, `NetDetachRequest`, `NetQOSRequest`, `PauseRequest`, `PFWAddRequest`, `PFWDelRequest`, `PinToNodeRequest`, `PowerCycleRequest`, `RaiseDownRequest`, `RebootRequest`, `RedeployRequest`, `ResetRequest`, `ResizeRequest`, `RestoreRequest`, `ResumeRequest`, `SnapshotCreateRequest`, `SnapshotDeleteRequest`, `SnapshotRollbackRequest`, `StartRequest` и `StopRequest` в cloudbroker/compute | -| BGOS-1043 | Опциональное поле `SyncMode` на `AsyncMode` в структуре запроса `MigrateRequest` в cloudbroker/compute | -| BGOS-1043 | Опциональное поле `Sync` на `Async` в структуре запроса `MigrateStorageRequest` в cloudbroker/compute | +| BGOS-1069 | Вычисляемое поле `FolderID` в структуры ответа `RecordCompute` и `ItemCompute` в cloudapi/compute | +| BGOS-1069 | Вычисляемое поле `FolderID` в структуры ответа `RecordCompute` и `InfoCompute` в cloudapi/compute | +| BGOS-1068 | Структуры ответа `MigrationReport`, `MigrationReportItem`, `AffinityRuleAddResult` и `AntiAffinityRuleAddResult` в cloudapi/compute | +| BGOS-1068 | Структуры ответа `MigrationReport`, `MigrationReportItem`, `AffinityRuleAddResult` и `AntiAffinityRuleAddResult` в cloudbroker/compute | +| BGOS-1063 | Структуры запроса `MigrateV2Request`, `MigrateV2AbortRequest`, `MigrateV2CleanupRequest`, `MigrateV2GetRequest`, `MigrateV2ListRequest` и `MigrateV2ResolveRequest` и методы `MigrateV2`, `MigrateV2Abort`, `MigrateV2Cleanup`, `MigrateV2Get`, `MigrateV2List` и `MigrateV2ResolveRequest` в cloudbroker/compute | +| BGOS-1080 | Опциональное поле `AccountID` из структуры запроса `CreateTemplateFromBlankRequest` в cloudapi/compute | #### disks | Идентификатор задачи | Описание | | --- | --- | -| BGOS-1045 | JSON-тэг опционального поля `AsyncMode` с `asyncMode` на `async_mode` в структуре запроса `FromPlatformDiskRequest` в cloudapi/disks и в cloudbroker/disks | +| BGOS-1080 | Опциональное поле `AccountID` из структуры запроса `FromPlatformDiskRequest` в cloudapi/disks | -#### image +#### extnet | Идентификатор задачи | Описание | | --- | --- | -| BGOS-1045 | JSON-тэг опционального поля `AsyncMode` с `asyncMode` на `async_mode` в структуре запроса `CreateRequest` в cloudapi/image и в cloudbroker/image | -| BGOS-1045 | JSON-тэг опционального поля `AsyncMode` с `asyncMode` на `async_mode` в структуре запроса `CreateCDROMImageRequest` в cloudbroker/image | +| BGOS-1073 | Вычисляемое поле `AutoAssignable` в структуру ответа `ItemReservation` в cloudapi/extnet | +| BGOS-1073 | Вычисляемые поля `AccountID` и `AutoAssignable` в структуру ответа `Excluded` в cloudapi/extnet | +| BGOS-1073 | Вычисляемое поле `AutoAssignable` в структуру ответа `ItemReservation` в cloudbroker/extnet | + +#### grid +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-1074 | Вычисляемое поле `VMFoldersEnabled` в структуры ответа `RecordGrid` и `ItemGridList` в cloudbroker/grid | #### kvmx86 | Идентификатор задачи | Описание | | --- | --- | -| BGOS-1045 | JSON-тэг опционального поля `AsyncMode` с `asyncMode` на `async_mode` в структуре запроса `MassCreateRequest` в cloudbroker/kvmx86 | +| BGOS-1067 | Опциональное поле `PCIdevices` в структуры запросов `CreateRequest` и `CreateBlankRequest` в cloudapi/kvmx86 | +| BGOS-1067 | Опциональное поле `PCIdevices` в структуры запросов `CreateRequest` и `CreateBlankRequest` в cloudbroker/kvmx86 | +| BGOS-1081 | Опциональное поле `VGPUs` в структуры запросов `CreateRequest` и `CreateBlankRequest` в cloudapi/kvmx86 | +| BGOS-1081 | Опциональное поле `VGPUs` в структуры запросов `CreateRequest` и `CreateBlankRequest` в cloudbroker/kvmx86 | -#### node -| Идентификатор задачи | Описание | -| --- | --- | -| BGOS-1045 | JSON-тэг опционального поля `AsyncMode` с `asyncMode` на `async_mode` в структуре запроса `EnableRequest` в cloudbroker/node | - -### Исправлено +### Изменено #### apiaccess | Идентификатор задачи | Описание | | --- | --- | -| BGOS-1055 | Ошибка при вызове метода `Update` в cloudbroker/apiaccess | -| BGOS-1055 | Исправлен тип ответа метода `DescUpdate` в cloudbroker/apiaccess | +| BGOS-1082 | Тип поля `APIs` с опционального на обязательный в структуре запроса `UpdateRequest` в cloudbroker/apiaccess | - -#### Удалено - -#### apiaccess +#### compute | Идентификатор задачи | Описание | | --- | --- | -| BGOS-1055 | Структура `LibCloudEndpoints` и опциональное поле `LibCloud` из структуры `APIsEndpoints` в cloudbroker/apiaccess | -| BGOS-1055 | Опциональные поля `CloudSpace`, `ComputeCI`, `DPDK`, `Machine`, `Openshift`, `OpenshiftCI`, `PortForwarding`, `Sizes` из структуры `CloudAPIEndpoints` в cloudbroker/apiaccess | -| BGOS-1055 | Опциональные поля `CloudSpace`, `ComputeCI`, `Desnode`, `Diagnostics`, `DPDK`, `IaaS`, `Machine`, `Openshift`, `OpenshiftCI`, `Ovsnode`, `QOS` из структуры `CloudBrokerEndpoints` в cloudbroker/apiaccess | -| BGOS-1055 | Опциональные поля `AgentController`, `Alerts`, `ErrorConditionHandler`, `Job`, `Log`, `Logo` из структуры `SystemEndpoints` в cloudbroker/apiaccess | +| BGOS-1068 | Тип ответа метода `AffinityRuleAdd` с `bool` на структуру `AffinityRuleAddResult` в cloudapi/compute | +| BGOS-1068 | Тип ответа метода `AffinityRuleAdd` с `bool` на структуру `AffinityRuleAddResult` в cloudbroker/compute | +| BGOS-1068 | Тип ответа метода `AntiAffinityRuleAdd` с `bool` на структуру `AntiAffinityRuleAddResult` в cloudapi/compute | +| BGOS-1068 | Тип ответа метода `AntiAffinityRuleAdd` с `bool` на структуру `AntiAffinityRuleAddResult` в cloudbroker/compute | + diff --git a/pkg/cloudapi/audit/audit.go b/pkg/cloudapi/audit/audit.go index 3f1fbf0e..5e6cc30d 100644 --- a/pkg/cloudapi/audit/audit.go +++ b/pkg/cloudapi/audit/audit.go @@ -8,8 +8,8 @@ type Audit struct { } // Builder for audit endpoint -func New(client interfaces.Caller) *Audit { +func New(client interfaces.Caller) *Audit{ return &Audit{ client: client, } -} +} \ No newline at end of file diff --git a/pkg/cloudapi/audit/models.go b/pkg/cloudapi/audit/models.go index 7bf866f9..ef99fdb0 100644 --- a/pkg/cloudapi/audit/models.go +++ b/pkg/cloudapi/audit/models.go @@ -88,6 +88,42 @@ type ItemAudit struct { // TTL TTL string `json:"_ttl"` + + // Resource group ID + ResgroupID uint64 `json:"resgroup_id"` + + // Account ID + AccountID uint64 `json:"account_id"` + + // Compute ID + ComputeID uint64 `json:"compute_id"` + + // VINS ID + VINSID uint64 `json:"vins_id"` + + // Service ID + ServiceID uint64 `json:"service_id"` + + // K8S ID + K8SID uint64 `json:"k8s_id"` + + // FLIPGroup ID + FLIPGroupID uint64 `json:"flipgroup_id"` + + // Load balancer ID + LBID uint64 `json:"lb_id"` + + // SEP ID + SEPID uint64 `json:"sep_id"` + + // Node IDs + NodeIDs []uint64 `json:"node_ids"` + + // Persistent disk IDs associated with the operation + DiskIDs []uint64 `json:"disk_ids"` + + // API task ID for asynchronous calls + APITask string `json:"apitask"` } // List of audits diff --git a/pkg/cloudapi/compute/affinity_rule_add.go b/pkg/cloudapi/compute/affinity_rule_add.go index 002a05d2..b9f5d8b2 100644 --- a/pkg/cloudapi/compute/affinity_rule_add.go +++ b/pkg/cloudapi/compute/affinity_rule_add.go @@ -6,6 +6,7 @@ import ( "net/http" "strconv" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants" "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" ) @@ -51,14 +52,14 @@ type AffinityRuleAddRequest struct { type wrapperAffinityRuleAddRequest struct { AffinityRuleAddRequest - AsyncMode bool `url:"async_mode"` + AsyncMode bool `url:"async_mode" json:"async_mode"` } // AffinityRuleAdd add affinity rule -func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest) (bool, error) { +func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest) (AffinityRuleAddResult, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return AffinityRuleAddResult{}, validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudapi/compute/affinityRuleAdd" @@ -68,17 +69,24 @@ func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest AsyncMode: false, } - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq) + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, aReq) if err != nil { - return false, err + return AffinityRuleAddResult{}, err } - result, err := strconv.ParseBool(string(res)) - if err != nil { - return false, err + if !req.Migrate { + result, err := strconv.ParseBool(string(res)) + return AffinityRuleAddResult{Ok: result}, err } - return result, nil + var report MigrationReport + + err = json.Unmarshal(res, &report) + if err != nil { + return AffinityRuleAddResult{}, err + } + + return AffinityRuleAddResult{Ok: report.Applied, MigrationReport: &report}, nil } // AsyncAffinityRuleAdd add affinity rule in async mode @@ -95,7 +103,7 @@ func (c Compute) AsyncAffinityRuleAdd(ctx context.Context, req AffinityRuleAddRe AsyncMode: true, } - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq) + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, aReq) if err != nil { return "", err } diff --git a/pkg/cloudapi/compute/anti_affinity_rule_add.go b/pkg/cloudapi/compute/anti_affinity_rule_add.go index 159bfa89..679ecb63 100644 --- a/pkg/cloudapi/compute/anti_affinity_rule_add.go +++ b/pkg/cloudapi/compute/anti_affinity_rule_add.go @@ -6,6 +6,7 @@ import ( "net/http" "strconv" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants" "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" ) @@ -51,14 +52,14 @@ type AntiAffinityRuleAddRequest struct { type wrapperAntiAffinityRuleAddRequest struct { AntiAffinityRuleAddRequest - AsyncMode bool `url:"async_mode"` + AsyncMode bool `url:"async_mode" json:"async_mode"` } // AntiAffinityRuleAdd add anti affinity rule -func (c Compute) AntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAddRequest) (bool, error) { +func (c Compute) AntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAddRequest) (AntiAffinityRuleAddResult, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return AntiAffinityRuleAddResult{}, validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudapi/compute/antiAffinityRuleAdd" @@ -68,17 +69,24 @@ func (c Compute) AntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAd AsyncMode: false, } - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq) + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, aReq) if err != nil { - return false, err + return AntiAffinityRuleAddResult{}, err } - result, err := strconv.ParseBool(string(res)) - if err != nil { - return false, err + if !req.Migrate { + result, err := strconv.ParseBool(string(res)) + return AntiAffinityRuleAddResult{Ok: result}, err } - return result, nil + var report MigrationReport + + err = json.Unmarshal(res, &report) + if err != nil { + return AntiAffinityRuleAddResult{}, err + } + + return AntiAffinityRuleAddResult{Ok: report.Applied, MigrationReport: &report}, nil } // AsyncAntiAffinityRuleAdd add anti affinity rule in async mode @@ -95,7 +103,7 @@ func (c Compute) AsyncAntiAffinityRuleAdd(ctx context.Context, req AntiAffinityR AsyncMode: true, } - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq) + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, aReq) if err != nil { return "", err } diff --git a/pkg/cloudapi/compute/create_template_from_blank.go b/pkg/cloudapi/compute/create_template_from_blank.go index 491431dc..3df24966 100644 --- a/pkg/cloudapi/compute/create_template_from_blank.go +++ b/pkg/cloudapi/compute/create_template_from_blank.go @@ -39,10 +39,6 @@ type CreateTemplateFromBlankRequest struct { // Required: false Password string `url:"password,omitempty" json:"password,omitempty"` - // Account ID to make the image exclusive - // Required: false - AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"` - // Pool for image create // Required: false PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"` diff --git a/pkg/cloudapi/compute/models.go b/pkg/cloudapi/compute/models.go index f3a89b02..1d248f8d 100644 --- a/pkg/cloudapi/compute/models.go +++ b/pkg/cloudapi/compute/models.go @@ -575,6 +575,9 @@ type RecordCompute struct { // Zone ID // Required: false ZoneID uint64 `json:"zoneId"` + + // Folder ID + FolderID uint64 `json:"folder_id"` } // Detailed information about ACL Access in a compute @@ -1564,6 +1567,9 @@ type ItemCompute struct { // Zone ID ZoneID uint64 `json:"zoneId"` + + // Folder ID + FolderID uint64 `json:"folder_id"` } // ListInfoDisks @@ -1743,3 +1749,47 @@ type CloneStatus struct { // Progress percent ProgressPercent int `json:"progress_percent"` } + +type MigrationReportItem struct { + // ID of the compute instance + ComputeID uint64 `json:"compute_id"` + + // Per-VM action result, not workflow status + // Should be one of: + // - migrated: migration completed; the rule may still be unsatisfied + // - skipped: migration was not needed or applicable + // - not_started: submission was not attempted + // - not_completed: completion is unconfirmed; the VM may have moved + Status string `json:"status"` + + // Action details, errors and final rule-placement warnings + Message string `json:"message"` + + // Workflow ID for tracking, or nil if submission was not attempted. + // A non-nil ID does not confirm job acceptance + WorkflowJobID *string `json:"workflow_job_id"` +} + +type MigrationReport struct { + // Rules were saved; does not confirm migration success or rule satisfaction + Applied bool `json:"applied"` + + // Per-compute migration results + Migrations []MigrationReportItem `json:"migrations"` +} + +type AffinityRuleAddResult struct { + // Result of the rule addition + Ok bool + + // Migration report. Populated only when the request was made with Migrate=true, nil otherwise + MigrationReport *MigrationReport +} + +type AntiAffinityRuleAddResult struct { + // Result of the rule addition + Ok bool + + // Migration report. Populated only when the request was made with Migrate=true, nil otherwise + MigrationReport *MigrationReport +} diff --git a/pkg/cloudapi/disks/from_platform_disk.go b/pkg/cloudapi/disks/from_platform_disk.go index 3cb7d400..4eede7da 100644 --- a/pkg/cloudapi/disks/from_platform_disk.go +++ b/pkg/cloudapi/disks/from_platform_disk.go @@ -35,10 +35,6 @@ type FromPlatformDiskRequest struct { // Required: false Password string `url:"password,omitempty" json:"password,omitempty"` - // Account ID to make the image exclusive - // Required: false - AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"` - // Pool for image create // Required: false PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"` diff --git a/pkg/cloudapi/extnet/models.go b/pkg/cloudapi/extnet/models.go index 4474d607..6162eed9 100644 --- a/pkg/cloudapi/extnet/models.go +++ b/pkg/cloudapi/extnet/models.go @@ -93,6 +93,9 @@ type ItemReservation struct { // Account ID AccountID uint64 `json:"account_id"` + // Auto assignable + AutoAssignable bool `json:"auto_assignable"` + // ClientType ClientType string `json:"clientType"` @@ -127,6 +130,12 @@ type VNFs struct { } type Excluded struct { + // Account ID + AccountID uint64 `json:"account_id"` + + // Auto assignable + AutoAssignable bool `json:"auto_assignable"` + // ClientType ClientType string `json:"clientType"` diff --git a/pkg/cloudapi/kvmx86/create.go b/pkg/cloudapi/kvmx86/create.go index d3c2bb13..bb1464f0 100644 --- a/pkg/cloudapi/kvmx86/create.go +++ b/pkg/cloudapi/kvmx86/create.go @@ -230,6 +230,10 @@ type CreateRequest struct { // Required: false PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"` + // List of PCI device IDs to attach to this VM + // Required: false + PCIdevices []uint64 `url:"pcidevices,omitempty" json:"pcidevices,omitempty"` + // Zone ID // Required: false ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` @@ -252,6 +256,10 @@ type CreateRequest struct { // Required: false // Default: "auto" MemoryBalloonMode string `url:"memory_balloon_mode,omitempty" json:"memory_balloon_mode,omitempty" validate:"omitempty,memoryBalloonMode"` + + // List of vGPU IDs to attach to the VM + // Required: false + VGPUs []uint64 `url:"vgpus,omitempty" json:"vgpus,omitempty"` } // GetRAM returns RAM field values diff --git a/pkg/cloudapi/kvmx86/create_blank.go b/pkg/cloudapi/kvmx86/create_blank.go index 531e33c9..10216c0a 100644 --- a/pkg/cloudapi/kvmx86/create_blank.go +++ b/pkg/cloudapi/kvmx86/create_blank.go @@ -92,6 +92,10 @@ type CreateBlankRequest struct { // Required: false PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"` + // List of PCI device IDs to attach to this VM + // Required: false + PCIdevices []uint64 `url:"pcidevices,omitempty" json:"pcidevices,omitempty"` + // VM type linux, windows or unknown // Required: false LoaderType string `url:"loaderType,omitempty" json:"loaderType,omitempty" validate:"omitempty,loaderType"` @@ -134,6 +138,10 @@ type CreateBlankRequest struct { // Required: false // Default: "auto" MemoryBalloonMode string `url:"memory_balloon_mode,omitempty" json:"memory_balloon_mode,omitempty" validate:"omitempty,memoryBalloonMode"` + + // List of vGPU IDs to attach to the VM + // Required: false + VGPUs []uint64 `url:"vgpus,omitempty" json:"vgpus,omitempty"` } // GetRAM returns RAM field values diff --git a/pkg/cloudbroker/apiaccess/update.go b/pkg/cloudbroker/apiaccess/update.go index ca9246e3..a91d7e8f 100644 --- a/pkg/cloudbroker/apiaccess/update.go +++ b/pkg/cloudbroker/apiaccess/update.go @@ -15,7 +15,7 @@ type UpdateRequest struct { APIAccessID uint64 `url:"apiaccess_id" json:"apiaccess_id" validate:"required"` // APIs to remove from APIAccess group - // Required: false + // Required: true APIs APIsEndpoints `url:"-" json:"-"` } diff --git a/pkg/cloudbroker/audit/audit.go b/pkg/cloudbroker/audit/audit.go index 3f1fbf0e..5e6cc30d 100644 --- a/pkg/cloudbroker/audit/audit.go +++ b/pkg/cloudbroker/audit/audit.go @@ -8,8 +8,8 @@ type Audit struct { } // Builder for audit endpoint -func New(client interfaces.Caller) *Audit { +func New(client interfaces.Caller) *Audit{ return &Audit{ client: client, } -} +} \ No newline at end of file diff --git a/pkg/cloudbroker/audit/models.go b/pkg/cloudbroker/audit/models.go index 556514ed..cbf67292 100644 --- a/pkg/cloudbroker/audit/models.go +++ b/pkg/cloudbroker/audit/models.go @@ -43,6 +43,42 @@ type ItemAudit struct { // TTL TTL string `json:"_ttl"` + + // Resource group ID + ResgroupID uint64 `json:"resgroup_id"` + + // Account ID + AccountID uint64 `json:"account_id"` + + // Compute ID + ComputeID uint64 `json:"compute_id"` + + // VINS ID + VINSID uint64 `json:"vins_id"` + + // Service ID + ServiceID uint64 `json:"service_id"` + + // K8S ID + K8SID uint64 `json:"k8s_id"` + + // FLIPGroup ID + FLIPGroupID uint64 `json:"flipgroup_id"` + + // Load balancer ID + LBID uint64 `json:"lb_id"` + + // SEP ID + SEPID uint64 `json:"sep_id"` + + // Node IDs + NodeIDs []uint64 `json:"node_ids"` + + // Persistent disk IDs associated with the operation + DiskIDs []uint64 `json:"disk_ids"` + + // API task ID for asynchronous calls + APITask string `json:"apitask"` } // List of audits diff --git a/pkg/cloudbroker/compute/affinity_rule_add.go b/pkg/cloudbroker/compute/affinity_rule_add.go index a10691c5..0d64fedd 100644 --- a/pkg/cloudbroker/compute/affinity_rule_add.go +++ b/pkg/cloudbroker/compute/affinity_rule_add.go @@ -6,6 +6,7 @@ import ( "net/http" "strconv" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants" "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" ) @@ -53,14 +54,14 @@ type AffinityRuleAddRequest struct { type wrapperAffinityRuleAddRequest struct { AffinityRuleAddRequest - AsyncMode bool `url:"async_mode"` + AsyncMode bool `url:"async_mode" json:"async_mode"` } // AffinityRuleAdd adds affinity rule -func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest) (bool, error) { +func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest) (AffinityRuleAddResult, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return AffinityRuleAddResult{}, validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/compute/affinityRuleAdd" @@ -70,17 +71,24 @@ func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest AsyncMode: false, } - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq) + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, aReq) if err != nil { - return false, err + return AffinityRuleAddResult{}, err } - result, err := strconv.ParseBool(string(res)) - if err != nil { - return false, err + if !req.Migrate { + result, err := strconv.ParseBool(string(res)) + return AffinityRuleAddResult{Ok: result}, err } - return result, nil + var report MigrationReport + + err = json.Unmarshal(res, &report) + if err != nil { + return AffinityRuleAddResult{}, err + } + + return AffinityRuleAddResult{Ok: report.Applied, MigrationReport: &report}, nil } // AsyncAffinityRuleAdd add affinity rule in async mode @@ -97,7 +105,7 @@ func (c Compute) AsyncAffinityRuleAdd(ctx context.Context, req AffinityRuleAddRe AsyncMode: true, } - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq) + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, aReq) if err != nil { return "", err } diff --git a/pkg/cloudbroker/compute/anti_affinity_rule_add.go b/pkg/cloudbroker/compute/anti_affinity_rule_add.go index 1aeb710d..39bc6451 100644 --- a/pkg/cloudbroker/compute/anti_affinity_rule_add.go +++ b/pkg/cloudbroker/compute/anti_affinity_rule_add.go @@ -6,6 +6,7 @@ import ( "net/http" "strconv" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants" "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" ) @@ -51,14 +52,14 @@ type AntiAffinityRuleAddRequest struct { type wrapperAntiAffinityRuleAddRequest struct { AntiAffinityRuleAddRequest - AsyncMode bool `url:"async_mode"` + AsyncMode bool `url:"async_mode" json:"async_mode"` } // AntiAffinityRuleAdd adds anti affinity rule -func (c Compute) AntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAddRequest) (bool, error) { +func (c Compute) AntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAddRequest) (AntiAffinityRuleAddResult, error) { err := validators.ValidateRequest(req) if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) + return AntiAffinityRuleAddResult{}, validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/compute/antiAffinityRuleAdd" @@ -68,17 +69,24 @@ func (c Compute) AntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAd AsyncMode: false, } - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq) + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, aReq) if err != nil { - return false, err + return AntiAffinityRuleAddResult{}, err } - result, err := strconv.ParseBool(string(res)) - if err != nil { - return false, err + if !req.Migrate { + result, err := strconv.ParseBool(string(res)) + return AntiAffinityRuleAddResult{Ok: result}, err } - return result, nil + var report MigrationReport + + err = json.Unmarshal(res, &report) + if err != nil { + return AntiAffinityRuleAddResult{}, err + } + + return AntiAffinityRuleAddResult{Ok: report.Applied, MigrationReport: &report}, nil } // AsyncAntiAffinityRuleAdd add anti affinity rule in async mode @@ -95,7 +103,7 @@ func (c Compute) AsyncAntiAffinityRuleAdd(ctx context.Context, req AntiAffinityR AsyncMode: true, } - res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq) + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, aReq) if err != nil { return "", err } diff --git a/pkg/cloudbroker/compute/migrate_v2.go b/pkg/cloudbroker/compute/migrate_v2.go new file mode 100644 index 00000000..92c981b6 --- /dev/null +++ b/pkg/cloudbroker/compute/migrate_v2.go @@ -0,0 +1,83 @@ +package compute + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" +) + +// Target describes a target for migration +type Target struct { + // SEP ID + // Required: true + SepID uint64 `url:"sep_id" json:"sep_id" validate:"required"` + + // Name of a pool + // Required: true + PoolName string `url:"pool_name" json:"pool_name" validate:"required"` + + // Storage policy ID + // Required: false + StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"` + + // Disk IDs + // Required: false + DiskIDs []uint64 `url:"disk_ids,omitempty" json:"disk_ids,omitempty"` +} + +// Storage describes a destination for a disk +type Storage struct { + // Target for migration + // Required: false + Targets []Target `url:"targets,omitempty" json:"targets,omitempty"` + + // Whether a separate source-disk cleanup job should be started after full success + // Required: false + AutoCleanup interface{} `url:"auto_cleanup,omitempty" json:"auto_cleanup,omitempty" validate:"omitempty,isBool"` +} + +// MigrateV2Request to start a migration of a compute or a disk +type MigrateV2Request struct { + // ID of compute to migrate + // Required: true + ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` + + // Stateless load balancers support only compute mode, including their local system disk. + // Required: false + Mode string `url:"mode,omitempty" json:"mode,omitempty" validate:"omitempty,migrateV2Mode"` + + // ID of node to migrate to + // Required: false + TargetNodeID uint64 `url:"target_node_id,omitempty" json:"target_node_id,omitempty"` + + // Destination for a disk + // Required: false + Storage Storage `url:"storage,omitempty" json:"storage,omitempty"` +} + +// MigrateV2 starts a migration of a compute or a disk +func (c Compute) MigrateV2(ctx context.Context, req MigrateV2Request) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/migrate_v2" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(res, &resp) + if err != nil { + return "", err + } + + return resp, nil +} diff --git a/pkg/cloudbroker/compute/migrate_v2_abort.go b/pkg/cloudbroker/compute/migrate_v2_abort.go new file mode 100644 index 00000000..556f85a4 --- /dev/null +++ b/pkg/cloudbroker/compute/migrate_v2_abort.go @@ -0,0 +1,47 @@ +package compute + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" +) + +// MigrateV2AbortRequest to abort a migration of a compute +type MigrateV2AbortRequest struct { + // Original migration workflow IDs, not agent, cleanup or recovery job IDs + // Required: true + WorkflowJobIDs []string `url:"workflow_job_ids" json:"workflow_job_ids" validate:"required"` +} + +// MigrateV2Abort aborts a migration of a compute +func (c Compute) MigrateV2Abort(ctx context.Context, req MigrateV2AbortRequest) (*MigrateV2AbortRecord, error) { + res, err := c.MigrateV2AbortRaw(ctx, req) + if err != nil { + return nil, err + } + + info := MigrateV2AbortRecord{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +// MigrateV2AbortRaw aborts a migration of a compute and returns an array of bytes +func (c Compute) MigrateV2AbortRaw(ctx context.Context, req MigrateV2AbortRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/migrate_v2_abort" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + return res, err +} diff --git a/pkg/cloudbroker/compute/migrate_v2_cleanup.go b/pkg/cloudbroker/compute/migrate_v2_cleanup.go new file mode 100644 index 00000000..6849c1b7 --- /dev/null +++ b/pkg/cloudbroker/compute/migrate_v2_cleanup.go @@ -0,0 +1,41 @@ +package compute + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" +) + +// MigrateV2CleanupRequest to clean up after a migration of a compute +type MigrateV2CleanupRequest struct { + // Original migration workflow IDs, not agent, cleanup or recovery job IDs + // Required: true + WorkflowJobID string `url:"workflow_job_id" json:"workflow_job_id" validate:"required"` +} + +// MigrateV2Cleanup cleans up after a migration of a compute +func (c Compute) MigrateV2Cleanup(ctx context.Context, req MigrateV2CleanupRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/migrate_v2_cleanup" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(res, &resp) + if err != nil { + return "", err + } + + return resp, nil +} diff --git a/pkg/cloudbroker/compute/migrate_v2_get.go b/pkg/cloudbroker/compute/migrate_v2_get.go new file mode 100644 index 00000000..60e76bd6 --- /dev/null +++ b/pkg/cloudbroker/compute/migrate_v2_get.go @@ -0,0 +1,46 @@ +package compute + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" +) + +// MigrateV2GetRequest to get the information about a workflow job +type MigrateV2GetRequest struct { + // Original migration workflow IDs + // Required: true + WorkflowJobID string `url:"workflow_job_id" json:"workflow_job_id" validate:"required"` +} + +// MigrateV2Get gets information about a workflow job as a MigrateV2Record struct +func (c Compute) MigrateV2Get(ctx context.Context, req MigrateV2GetRequest) (*MigrateV2Record, error) { + res, err := c.MigrateV2GetRaw(ctx, req) + if err != nil { + return nil, err + } + + info := MigrateV2Record{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +// GetRaw gets information about a workflow job as an array of bytes +func (c Compute) MigrateV2GetRaw(ctx context.Context, req MigrateV2GetRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/migrate_v2_get" + + res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) + return res, err +} diff --git a/pkg/cloudbroker/compute/migrate_v2_list.go b/pkg/cloudbroker/compute/migrate_v2_list.go new file mode 100644 index 00000000..156141bb --- /dev/null +++ b/pkg/cloudbroker/compute/migrate_v2_list.go @@ -0,0 +1,67 @@ +package compute + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" +) + +// MigrateV2ListRequest to list migrations +type MigrateV2ListRequest struct { + // Exact APIServer migration workflow job ID + // Required: false + WorkflowJobID string `url:"workflow_job_id,omitempty" json:"workflow_job_id,omitempty"` + + // Compute ID + // Required: false + ComputeID uint64 `url:"compute_id,omitempty" json:"compute_id,omitempty"` + + // Exact business migration status + // Required: false + Status string `url:"status,omitempty" json:"status,omitempty"` + + // Source node ID + // Required: false + SourceNodeID uint64 `url:"source_node_id,omitempty" json:"source_node_id,omitempty"` + + // Target node ID + // Required: false + TargetNodeID uint64 `url:"target_node_id,omitempty" json:"target_node_id,omitempty"` + + // Whether retained source disks still require cleanup + // Required: false + CleanupRequired interface{} `url:"cleanup_required,omitempty" json:"cleanup_required,omitempty" validate:"omitempty,isBool"` + + // Page number + // Required: false + Page uint64 `url:"page,omitempty" json:"page,omitempty"` + + // Page size + // Required: false + Size uint64 `url:"size,omitempty" json:"size,omitempty"` +} + +// MigrateV2List gets list of the jobs +func (c Compute) MigrateV2List(ctx context.Context, req MigrateV2ListRequest) (*ListMigrateV2, error) { + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/migrate_v2_list" + + res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) + if err != nil { + return nil, err + } + + list := ListMigrateV2{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} diff --git a/pkg/cloudbroker/compute/migrate_v2_resolve.go b/pkg/cloudbroker/compute/migrate_v2_resolve.go new file mode 100644 index 00000000..5f0468eb --- /dev/null +++ b/pkg/cloudbroker/compute/migrate_v2_resolve.go @@ -0,0 +1,51 @@ +package compute + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" +) + +// MigrateResolveRequest to resolve a migration +type MigrateV2ResolveRequest struct { + // Workflow job ID + // Required: true + WorkflowJobID string `url:"workflow_job_id" json:"workflow_job_id" validate:"required"` + + // Take over cleanup + // Required: false + TakeOverCleanup interface{} `url:"take_over_cleanup,omitempty" json:"take_over_cleanup,omitempty" validate:"omitempty,isBool"` +} + +// MigrateV2Resolve resolves a migration of a compute +func (c Compute) MigrateV2Resolve(ctx context.Context, req MigrateV2ResolveRequest) (*MigrateV2ResolveRecord, error) { + res, err := c.MigrateV2ResolveRaw(ctx, req) + if err != nil { + return nil, err + } + + info := MigrateV2ResolveRecord{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} + +// MigrateV2ResolveRaw resolves a migration of a compute and returns an array of bytes +func (c Compute) MigrateV2ResolveRaw(ctx context.Context, req MigrateV2ResolveRequest) ([]byte, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/compute/migrate_v2_resolve" + + res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + return res, err +} diff --git a/pkg/cloudbroker/compute/models.go b/pkg/cloudbroker/compute/models.go index b7adc8c0..a7d10aa2 100644 --- a/pkg/cloudbroker/compute/models.go +++ b/pkg/cloudbroker/compute/models.go @@ -938,6 +938,9 @@ type InfoCompute struct { // Zone ID ZoneID uint64 `json:"zoneId"` + + // Folder ID + FolderID uint64 `json:"folder_id"` } type QemuQuest struct { @@ -1252,6 +1255,9 @@ type RecordCompute struct { //todo _ uint64 `json:"nodeId"` + + // Folder ID + FolderID uint64 `json:"folder_id"` } // Detailed information about ACL Access in a compute @@ -2272,3 +2278,376 @@ type CheckComputePlacementItem struct { } type CheckComputePlacementResult map[uint64]CheckComputePlacementItem + +type Result struct { + // Workflow ID + WorkflowJobID string `json:"workflow_job_id"` + + // Compute ID + ComputeID uint64 `json:"compute_id"` + + // Status + Status string `json:"status"` + + // Job ID + JobID string `json:"job_id"` + + // Message + Message string `json:"message"` +} + +// MigrateV2 abort record +type MigrateV2AbortRecord struct { + // Results + Results []Result `json:"results"` +} + +type Origin struct { + // Type + Type string `json:"type"` + + // Correlation ID + CorrelationID string `json:"correlation_id"` +} + +type Observation struct { + // Updated at + UpdatedAt uint64 `json:"updated_at"` + + // Agent job ID + AgentJobID string `json:"agent_job_id"` + + // Attempt + Attempt uint64 `json:"attempt"` + + // Operation + Operation string `json:"operation"` +} + +type Memory struct { + // Sampled at + SampledAt uint64 `json:"sampled_at"` + + // Percent + Percent uint64 `json:"percent"` + + // Bytes per second + BytesPerSecond uint64 `json:"bytes_per_second"` + + // Processed bytes + ProcessedBytes uint64 `json:"processed_bytes"` + + // Remaining bytes + RemainingBytes uint64 `json:"remaining_bytes"` +} + +type ProgressDisks struct { + // Scope + Scope string `json:"scope"` + + // Target devs + TargetDevs []string `json:"target_devs"` + + // Sampled at + SampledAt uint64 `json:"sampled_at"` + + // Percent + Percent uint64 `json:"percent"` + + // Bytes per second + BytesPerSecond uint64 `json:"bytes_per_second"` + + // Processed bytes + ProcessedBytes uint64 `json:"processed_bytes"` + + // Remaining bytes + RemainingBytes uint64 `json:"remaining_bytes"` +} + +type SystemDisk struct { + // Target dev + TargetDev string `json:"target_dev"` + + // Sampled at + SampledAt uint64 `json:"sampled_at"` + + // Percent + Percent uint64 `json:"percent"` + + // Bytes per second + BytesPerSecond uint64 `json:"bytes_per_second"` + + // Processed bytes + ProcessedBytes uint64 `json:"processed_bytes"` + + // Remaining bytes + RemainingBytes uint64 `json:"remaining_bytes"` +} + +type Progress struct { + // Observation + Observation Observation `json:"observation"` + + // Memory + Memory Memory `json:"memory"` + + // Disks + Disks ProgressDisks `json:"disks"` + + // System disk + SystemDisk SystemDisk `json:"system_disk"` +} + +type Disk struct { + // Source disk ID + SourceDiskID uint64 `json:"source_disk_id"` + + // Target disk ID + TargetDiskID uint64 `json:"target_disk_id"` + + // Target dev + TargetDev string `json:"target_dev"` + + // SEP ID + SEPID uint64 `json:"sep_id"` + + // Pool name + PoolName string `json:"pool_name"` + + // Storage policy ID + StoragePolicyID uint64 `json:"storage_policy_id"` + + // State + State string `json:"state"` +} + +type Cleanup struct { + // Job ID + JobID string `json:"job_id"` + + // Status + Status string `json:"status"` + + // Error + Error string `json:"error"` +} + +type Resolution struct { + // Resolved at + ResolvedAt string `json:"resolved_at"` + + // Resolved by + ResolvedBy string `json:"resolved_by"` + + // RequestID + RequestId string `json:"request_id"` + + // Take over cleanup + TakeOverCleanup bool `json:"take_over_cleanup"` + + // Previous status + PreviousStatus string `json:"previous_status"` + + // Previous cleanup required + PreviousCleanupRequired bool `json:"previous_cleanup_required"` + + // Previous error + PreviousError string `json:"previous_error"` +} + +type MigrateV2Item struct { + // Workflow Job ID + WorkflowJobID string `json:"workflow_job_id"` + + // Mode + Mode string `json:"mode"` + + // Origin + Origin Origin `json:"origin"` + + // Compute ID + ComputeID uint64 `json:"compute_id"` + + // Progress + Progress Progress `json:"progress"` + + // Domain name + DomainName string `json:"domain_name"` + + // Domain UUID + DomainUUID string `json:"domain_uuid"` + + // Source node ID + SourceNodeID uint64 `json:"source_node_id"` + + // Target node ID + TargetNodeID uint64 `json:"target_node_id"` + + // Source tech status + SourceTechStatus string `json:"source_tech_status"` + + // Status + Status string `json:"status"` + + // Migration result confirmed + MigrationResultConfirmed bool `json:"migration_result_confirmed"` + + // Disks + Disks []Disk `json:"disks"` + + // Disk IDs not copied + DiskIDsNotCopied []uint64 `json:"disk_ids_not_copied"` + + // Error + Error string `json:"error"` + + // Cleanup required + CleanupRequired bool `json:"cleanup_required"` + + // Cleanup + Cleanup Cleanup `json:"cleanup"` + + // Resolution + Resolution Resolution `json:"resolution"` + + // Created at + CreatedAt string `json:"created_at"` + + // Updated at + UpdatedAt string `json:"updated_at"` +} + +type ListMigrateV2 struct { + // Entry count + EntryCount uint64 `json:"entry_count"` + + // Data + Data []MigrateV2Item `json:"data"` +} + +type MigrateV2Record struct { + // Workflow Job ID + WorkflowJobID string `json:"workflow_job_id"` + + // Mode + Mode string `json:"mode"` + + // Origin + Origin Origin `json:"origin"` + + // Compute ID + ComputeID uint64 `json:"compute_id"` + + // Progress + Progress Progress `json:"progress"` + + // Domain name + DomainName string `json:"domain_name"` + + // Domain UUID + DomainUUID string `json:"domain_uuid"` + + // Source node ID + SourceNodeID uint64 `json:"source_node_id"` + + // Target node ID + TargetNodeID uint64 `json:"target_node_id"` + + // Source tech status + SourceTechStatus string `json:"source_tech_status"` + + // Status + Status string `json:"status"` + + // Migration result confirmed + MigrationResultConfirmed bool `json:"migration_result_confirmed"` + + // Disks + Disks []Disk `json:"disks"` + + // Disk IDs not copied + DiskIDsNotCopied []uint64 `json:"disk_ids_not_copied"` + + // Error + Error string `json:"error"` + + // Cleanup required + CleanupRequired bool `json:"cleanup_required"` + + // Cleanup + Cleanup Cleanup `json:"cleanup"` + + // Resolution + Resolution Resolution `json:"resolution"` + + // Created at + CreatedAt string `json:"created_at"` + + // Updated at + UpdatedAt string `json:"updated_at"` + + // Logs + Logs []string `json:"logs"` +} + +// Migrate V2 resolve record +type MigrateV2ResolveRecord struct { + // Workflow job ID + WorkflowJobID string `json:"workflow_job_id"` + + // Compute ID + ComputeID uint64 `json:"compute_id"` + + // Status + Status string `json:"status"` + + // Cleanup required + CleanupRequired bool `json:"cleanup_required"` + + // Resolution + Resolution Resolution `json:"resolution"` +} + +type MigrationReportItem struct { + // ID of the compute instance + ComputeID uint64 `json:"compute_id"` + + // Per-VM action result, not workflow status + // Should be one of: + // - migrated: migration completed; the rule may still be unsatisfied + // - skipped: migration was not needed or applicable + // - not_started: submission was not attempted + // - not_completed: completion is unconfirmed; the VM may have moved + Status string `json:"status"` + + // Action details, errors and final rule-placement warnings + Message string `json:"message"` + + // Workflow ID for tracking, or nil if submission was not attempted. + // A non-nil ID does not confirm job acceptance + WorkflowJobID *string `json:"workflow_job_id"` +} + +type MigrationReport struct { + // Rules were saved; does not confirm migration success or rule satisfaction + Applied bool `json:"applied"` + + // Per-compute migration results + Migrations []MigrationReportItem `json:"migrations"` +} + +type AffinityRuleAddResult struct { + // Result of the rule addition + Ok bool + + // Migration report. Populated only when the request was made with Migrate=true, nil otherwise + MigrationReport *MigrationReport +} + +type AntiAffinityRuleAddResult struct { + // Result of the rule addition + Ok bool + + // Migration report. Populated only when the request was made with Migrate=true, nil otherwise + MigrationReport *MigrationReport +} diff --git a/pkg/cloudbroker/extnet/models.go b/pkg/cloudbroker/extnet/models.go index 01d7f8cc..63d11b14 100644 --- a/pkg/cloudbroker/extnet/models.go +++ b/pkg/cloudbroker/extnet/models.go @@ -20,12 +20,21 @@ type ItemReservation struct { // Account ID AccountID uint64 `json:"account_id"` + // Auto assignable + AutoAssignable bool `json:"auto_assignable"` + // Client type ClientType string `json:"clientType"` // Description Description string `json:"desc"` + // Domain name + DomainName string `json:"domainname"` + + // Hostname + Hostname string `json:"hostname"` + // IP IP string `json:"ip"` @@ -37,12 +46,6 @@ type ItemReservation struct { // Virtual machine ID VMID uint64 `json:"vmId"` - - // Domain name - DomainName string `json:"domainname"` - - // Hostname - Hostname string `json:"hostname"` } // List reservations diff --git a/pkg/cloudbroker/grid/models.go b/pkg/cloudbroker/grid/models.go index d71fd104..9475df77 100644 --- a/pkg/cloudbroker/grid/models.go +++ b/pkg/cloudbroker/grid/models.go @@ -117,6 +117,9 @@ type RecordGrid struct { // Budget Budget bool `json:"budget"` + + // Whether VM folders are enabled + VMFoldersEnabled bool `json:"vm_folders_enabled"` } // Information about grid @@ -165,6 +168,9 @@ type ItemGridList struct { // Budget Budget bool `json:"budget"` + + // Whether VM folders are enabled + VMFoldersEnabled bool `json:"vm_folders_enabled"` } // List Grids diff --git a/pkg/cloudbroker/k8ci/access_add.go b/pkg/cloudbroker/k8ci/access_add.go index 810bdbbf..a3ac3991 100644 --- a/pkg/cloudbroker/k8ci/access_add.go +++ b/pkg/cloudbroker/k8ci/access_add.go @@ -19,7 +19,7 @@ type AccessAddRequest struct { } // Add accountId to sharedWith access list for k8ci. -func (k K8CI) AccessAdd(ctx context.Context, req AccessAddRequest) (string, error) { +func (k K8CI) AccessAdd (ctx context.Context, req AccessAddRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { return "", validators.ValidationErrors(validators.GetErrors(err)) diff --git a/pkg/cloudbroker/k8ci/access_remove.go b/pkg/cloudbroker/k8ci/access_remove.go index d811f6ca..8038e85d 100644 --- a/pkg/cloudbroker/k8ci/access_remove.go +++ b/pkg/cloudbroker/k8ci/access_remove.go @@ -19,7 +19,7 @@ type AccessRemoveRequest struct { } // Remove accountId from sharedWith access list for k8ci. -func (k K8CI) AccessRemove(ctx context.Context, req AccessRemoveRequest) (string, error) { +func (k K8CI) AccessRemove (ctx context.Context, req AccessRemoveRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { return "", validators.ValidationErrors(validators.GetErrors(err)) diff --git a/pkg/cloudbroker/kvmx86/create.go b/pkg/cloudbroker/kvmx86/create.go index a5d09f9b..0814e3c1 100644 --- a/pkg/cloudbroker/kvmx86/create.go +++ b/pkg/cloudbroker/kvmx86/create.go @@ -240,6 +240,10 @@ type CreateRequest struct { // Required: false PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"` + // List of PCI device IDs to attach to this VM + // Required: false + PCIdevices []uint64 `url:"pcidevices,omitempty" json:"pcidevices,omitempty"` + // Zone ID // Required: false ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"` @@ -275,6 +279,10 @@ type CreateRequest struct { // Required: false // Default: "auto" MemoryBalloonMode string `url:"memory_balloon_mode,omitempty" json:"memory_balloon_mode,omitempty" validate:"omitempty,memoryBalloonMode"` + + // List of vGPU IDs to attach to the VM + // Required: false + VGPUs []uint64 `url:"vgpus,omitempty" json:"vgpus,omitempty"` } // GetRAM returns RAM field values diff --git a/pkg/cloudbroker/kvmx86/create_blank.go b/pkg/cloudbroker/kvmx86/create_blank.go index 840dcc4e..99e710cc 100644 --- a/pkg/cloudbroker/kvmx86/create_blank.go +++ b/pkg/cloudbroker/kvmx86/create_blank.go @@ -92,6 +92,10 @@ type CreateBlankRequest struct { // Required: false PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"` + // List of PCI device IDs to attach to this VM + // Required: false + PCIdevices []uint64 `url:"pcidevices,omitempty" json:"pcidevices,omitempty"` + // VM type linux, windows or unknown // Required: false LoaderType string `url:"loaderType,omitempty" json:"loaderType,omitempty" validate:"omitempty,loaderType"` @@ -147,6 +151,10 @@ type CreateBlankRequest struct { // Required: false // Default: "auto" MemoryBalloonMode string `url:"memory_balloon_mode,omitempty" json:"memory_balloon_mode,omitempty" validate:"omitempty,memoryBalloonMode"` + + // List of vGPU IDs to attach to the VM + // Required: false + VGPUs []uint64 `url:"vgpus,omitempty" json:"vgpus,omitempty"` } // GetRAM returns RAM field values