From c7a2c4ed5a0d58a236a48ca2982aaf2c70ab9379 Mon Sep 17 00:00:00 2001 From: asteam Date: Wed, 7 May 2025 13:15:39 +0300 Subject: [PATCH] v1.11.3 --- CHANGELOG.md | 50 ++++- pkg/cloudapi/bservice/group_add.go | 2 +- .../compute/create_template_from_blank.go | 4 - pkg/cloudapi/compute/models.go | 2 +- pkg/cloudapi/compute/update.go | 19 +- pkg/cloudapi/disks/from_platform_disk.go | 4 - pkg/cloudapi/locations/models.go | 3 + pkg/cloudapi/rg/filter_test.go | 81 ++++---- pkg/cloudapi/rg/models.go | 6 - pkg/cloudbroker/account/delete.go | 8 + pkg/cloudbroker/apiaccess/api_find.go | 4 +- pkg/cloudbroker/apiaccess/list.go | 3 + pkg/cloudbroker/bservice/create.go | 50 +++++ pkg/cloudbroker/bservice/delete.go | 42 +++++ pkg/cloudbroker/bservice/disable.go | 40 ++++ pkg/cloudbroker/bservice/enable.go | 41 ++++ pkg/cloudbroker/bservice/group_add.go | 112 +++++++++++ .../bservice/group_compute_remove.go | 46 +++++ pkg/cloudbroker/bservice/group_get.go | 44 +++++ .../bservice/group_parent_remove.go | 48 +++++ pkg/cloudbroker/bservice/group_parrent_add.go | 46 +++++ pkg/cloudbroker/bservice/group_remove.go | 43 +++++ pkg/cloudbroker/bservice/group_resize.go | 59 ++++++ pkg/cloudbroker/bservice/group_start.go | 42 +++++ pkg/cloudbroker/bservice/group_stop.go | 46 +++++ pkg/cloudbroker/bservice/group_update.go | 76 ++++++++ .../bservice/group_update_extnet.go | 46 +++++ pkg/cloudbroker/bservice/group_update_vins.go | 46 +++++ pkg/cloudbroker/bservice/list_deleted.go | 56 ++++++ pkg/cloudbroker/bservice/models.go | 144 ++++++++++++++ pkg/cloudbroker/bservice/restore.go | 38 ++++ pkg/cloudbroker/bservice/snapshot_create.go | 42 +++++ pkg/cloudbroker/bservice/snapshot_delete.go | 42 +++++ pkg/cloudbroker/bservice/snapshot_list.go | 40 ++++ pkg/cloudbroker/bservice/snapshot_rollback.go | 42 +++++ pkg/cloudbroker/bservice/start.go | 40 ++++ pkg/cloudbroker/bservice/stop.go | 40 ++++ .../compute/create_template_from_blank.go | 4 - pkg/cloudbroker/compute/models.go | 2 +- pkg/cloudbroker/compute/update.go | 21 +-- pkg/cloudbroker/disks/filter_test.go | 18 +- pkg/cloudbroker/disks/from_platform_disk.go | 4 - pkg/cloudbroker/node/enable_nodes.go | 4 +- pkg/cloudbroker/node/models.go | 2 +- pkg/cloudbroker/rg/filter_test.go | 81 ++++---- pkg/cloudbroker/rg/models.go | 3 - tests/platform_upgrade/README.md | 2 +- tests/platform_upgrade/cloud_test.go | 178 ++++++++++-------- tests/platform_upgrade/request_map.go | 139 +++++++++----- tests/platform_upgrade/utils_log.go | 119 ------------ tests/platform_upgrade/utils_requests.go | 4 - tests/platform_upgrade/utils_urls.go | 2 - 52 files changed, 1680 insertions(+), 400 deletions(-) create mode 100644 pkg/cloudbroker/bservice/create.go create mode 100644 pkg/cloudbroker/bservice/delete.go create mode 100644 pkg/cloudbroker/bservice/disable.go create mode 100644 pkg/cloudbroker/bservice/enable.go create mode 100644 pkg/cloudbroker/bservice/group_add.go create mode 100644 pkg/cloudbroker/bservice/group_compute_remove.go create mode 100644 pkg/cloudbroker/bservice/group_get.go create mode 100644 pkg/cloudbroker/bservice/group_parent_remove.go create mode 100644 pkg/cloudbroker/bservice/group_parrent_add.go create mode 100644 pkg/cloudbroker/bservice/group_remove.go create mode 100644 pkg/cloudbroker/bservice/group_resize.go create mode 100644 pkg/cloudbroker/bservice/group_start.go create mode 100644 pkg/cloudbroker/bservice/group_stop.go create mode 100644 pkg/cloudbroker/bservice/group_update.go create mode 100644 pkg/cloudbroker/bservice/group_update_extnet.go create mode 100644 pkg/cloudbroker/bservice/group_update_vins.go create mode 100644 pkg/cloudbroker/bservice/list_deleted.go create mode 100644 pkg/cloudbroker/bservice/restore.go create mode 100644 pkg/cloudbroker/bservice/snapshot_create.go create mode 100644 pkg/cloudbroker/bservice/snapshot_delete.go create mode 100644 pkg/cloudbroker/bservice/snapshot_list.go create mode 100644 pkg/cloudbroker/bservice/snapshot_rollback.go create mode 100644 pkg/cloudbroker/bservice/start.go create mode 100644 pkg/cloudbroker/bservice/stop.go delete mode 100644 tests/platform_upgrade/utils_log.go diff --git a/CHANGELOG.md b/CHANGELOG.md index dff7588..499965d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,21 +1,59 @@ -## Version 1.11.2 +## Version 1.11.3 ### Добавлено +### account +| Идентификатор
задачи | Описание | +| --- | --- | +| BGOS-467 | Опциональные поля `Name` и `Reason` в структуре запроса `DeleteRequest` в cloudbroker/account | + +### apiaccess +| Идентификатор
задачи | Описание | +| --- | --- | +| BGOS-470 | Опциональное поле `Desc` в структуре запроса `ListRequest` в cloudbroker/apiaccess | + #### bservice | Идентификатор
задачи | Описание | | --- | --- | -| BGOS-366 | Метод `Get` структура запроса `GetRequest` и структура ответа `RecordBasicService` в cloudbroker/bservice | -| BGOS-366 | Метод `List` структура запроса `ListRequest` и структура ответа `ListBasicServices` в cloudbroker/bservice | +| BGOS-361 | Группа ручек `bservice` в cloudbroker/bservice | -#### prometheus +#### location | Идентификатор
задачи | Описание | | --- | --- | -| BGOS-406 | Добавлена группа ручек `prometheus` в cloudapi | +| BGOS-471 | Поле `SDNSupport` в возвращаемой модели `ItemLocation` в cloudbroker/location | ### Исправлено -#### compute +#### disks +| Идентификатор
задачи | Описание | +| --- | --- | +| BGOS-468 | Исправлен тип поля `UpdatedBy` c uint64 на string в структурах ответа `ItemComputeDisk` в cloudapi/disks и `ItemDisk` в cloudbroker/disks | + +#### kvmvm | Идентификатор
задачи | Описание | | --- | --- | | BGOS-433 | Исправлена ошибка валидации поля LoaderType для всех структур в cloudapi/compute и в cloudbroker/compute | +| BGOS-458 | Изменен тип параметров `CPUPin`, `HPBacked`, `AutoStart`, `HotResize` с bool на interface в структуре `UpdateRequest` cloudapi/compute и в cloudbroker/compute | + +#### node +| Идентификатор
задачи | Описание | +| --- | --- | +| BGOS-472 | Исправлен тип поля `NumaNode` c uint64 на int в структуре ответа `Backplane1` в cloudbroker/node | +| BGOS-428 | Поле `Message` заменено на `Reason` в структуре запроса `EnableNodesRequest` в cloudbroker/node | + +### Удалено + +### compute +| Идентификатор
задачи | Описание | +| --- | --- | +| BGOS-469 | Опциональное поле `SepID` в структуре запроса `CreateTemplateFromBlankRequest` в cloudapi/compute и cloudbroker/compute | + +### disks +| Идентификатор
задачи | Описание | +| --- | --- | +| BGOS-469 | Опциональное поле `SepID` в структуре запроса `FromPlatformDiskRequest` в cloudapi/disks и cloudbroker/disks | + +#### rg +| Идентификатор
задачи | Описание | +| --- | --- | +| BGOS-427 | Поле `RegisterComputes` в структурах ответа `RecordResourceGroup`, `ItemResourceGroup` в cloudapi/rg и `ItemRG` в cloudbroker/rg | diff --git a/pkg/cloudapi/bservice/group_add.go b/pkg/cloudapi/bservice/group_add.go index 045ba46..5b5630e 100644 --- a/pkg/cloudapi/bservice/group_add.go +++ b/pkg/cloudapi/bservice/group_add.go @@ -74,7 +74,7 @@ type GroupAddRequest struct { //Chipset "i440fx" or "Q35 //Required: false - Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"chipset"` + Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"chipset,omitempty"` } // GetRAM returns RAM field values diff --git a/pkg/cloudapi/compute/create_template_from_blank.go b/pkg/cloudapi/compute/create_template_from_blank.go index 71294f7..a1c0be7 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 AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"` - // SEP ID - // Required: false - SepID uint64 `url:"sepId,omitempty" json:"sepId,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 b4fc543..4c89254 100644 --- a/pkg/cloudapi/compute/models.go +++ b/pkg/cloudapi/compute/models.go @@ -775,7 +775,7 @@ type ItemComputeDisk struct { Type string `json:"type"` // Updated by - UpdatedBy uint64 `json:"updatedBy"` + UpdatedBy string `json:"updatedBy"` // Virtual machine ID VMID uint64 `json:"vmid"` diff --git a/pkg/cloudapi/compute/update.go b/pkg/cloudapi/compute/update.go index 21afc89..ba7b29f 100644 --- a/pkg/cloudapi/compute/update.go +++ b/pkg/cloudapi/compute/update.go @@ -30,24 +30,21 @@ type UpdateRequest struct { // Default: none NumaAffinity string `url:"numaAffinity,omitempty" json:"numaAffinity,omitempty" validate:"omitempty,numaAffinity"` - // Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node + // Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node, true or false // Required: false - // Default: false - CPUPin bool `url:"cpupin" json:"cpupin"` + CPUPin interface{} `url:"cpupin,omitempty" json:"cpupin,omitempty" validate:"omitempty,isBool"` // Type of the emulated system, Q35 or i440fx // Required: false Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` - // Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node + // Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node, true or false // Required: false - // Default: false - HPBacked bool `url:"hpBacked" json:"hpBacked"` + HPBacked interface{} `url:"hpBacked,omitempty" json:"hpBacked,omitempty" validate:"omitempty,isBool"` - // Auto start when node restarted + // Auto start when node restarted, true or false // Required: false - // Default: false - AutoStart bool `url:"autoStart" json:"autoStart"` + AutoStart interface{} `url:"autoStart,omitempty" json:"autoStart,omitempty" validate:"omitempty,isBool"` // Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False // Required: false @@ -65,9 +62,9 @@ type UpdateRequest struct { // Required: false NetworkInterfaceNaming string `url:"networkInterfaceNaming,omitempty" json:"networkInterfaceNaming,omitempty" validate:"omitempty,networkInterfaceNaming"` - // Does this machine supports hot resize + // Does this machine supports hot resize, true or false // Required: false - HotResize bool `url:"hotResize,omitempty" json:"hotResize,omitempty"` + HotResize interface{} `url:"hotResize,omitempty" json:"hotResize,omitempty" validate:"omitempty,isBool"` } // Update updates some properties of the compute diff --git a/pkg/cloudapi/disks/from_platform_disk.go b/pkg/cloudapi/disks/from_platform_disk.go index 9268834..a8fa29e 100644 --- a/pkg/cloudapi/disks/from_platform_disk.go +++ b/pkg/cloudapi/disks/from_platform_disk.go @@ -45,10 +45,6 @@ type FromPlatformDiskRequest struct { // Required: false AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"` - // SEP ID - // Required: false - SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"` - // Pool for image create // Required: false PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"` diff --git a/pkg/cloudapi/locations/models.go b/pkg/cloudapi/locations/models.go index 87f7b3c..fd0526e 100644 --- a/pkg/cloudapi/locations/models.go +++ b/pkg/cloudapi/locations/models.go @@ -28,6 +28,9 @@ type ItemLocation struct { // CKey CKey string `json:"_ckey"` + + // Support of SDN + SDNSupport bool `json:"sdn_support"` } // List of locations diff --git a/pkg/cloudapi/rg/filter_test.go b/pkg/cloudapi/rg/filter_test.go index 5caab07..a97dad2 100644 --- a/pkg/cloudapi/rg/filter_test.go +++ b/pkg/cloudapi/rg/filter_test.go @@ -17,20 +17,19 @@ var rgs = ListResourceGroups{ UserGroupID: "sample_user_1@decs3o", }, }, - CreatedBy: "sample_user_1@decs3o", - CreatedTime: 1676645305, - DefNetID: 1, - DefNetType: "NONE", - DeletedBy: "", - DeletedTime: 0, - Description: "", - GID: 212, - GUID: 7971, - ID: 7971, - LockStatus: "UNLOCKED", - Milestones: 363459, - Name: "rg_1", - RegisterComputes: false, + CreatedBy: "sample_user_1@decs3o", + CreatedTime: 1676645305, + DefNetID: 1, + DefNetType: "NONE", + DeletedBy: "", + DeletedTime: 0, + Description: "", + GID: 212, + GUID: 7971, + ID: 7971, + LockStatus: "UNLOCKED", + Milestones: 363459, + Name: "rg_1", ResourceLimits: ResourceLimits{ CUC: -1, CUI: -1, @@ -60,20 +59,19 @@ var rgs = ListResourceGroups{ UserGroupID: "sample_user_1@decs3o", }, }, - CreatedBy: "sample_user_1@decs3o", - CreatedTime: 1676645461, - DefNetID: 2, - DefNetType: "NONE", - DeletedBy: "", - DeletedTime: 0, - Description: "", - GID: 212, - GUID: 7972, - ID: 7972, - LockStatus: "UNLOCKED", - Milestones: 363468, - Name: "rg_2", - RegisterComputes: false, + CreatedBy: "sample_user_1@decs3o", + CreatedTime: 1676645461, + DefNetID: 2, + DefNetType: "NONE", + DeletedBy: "", + DeletedTime: 0, + Description: "", + GID: 212, + GUID: 7972, + ID: 7972, + LockStatus: "UNLOCKED", + Milestones: 363468, + Name: "rg_2", ResourceLimits: ResourceLimits{ CUC: -1, CUI: -1, @@ -103,20 +101,19 @@ var rgs = ListResourceGroups{ UserGroupID: "sample_user_2@decs3o", }, }, - CreatedBy: "sample_user_2@decs3o", - CreatedTime: 1676645548, - DefNetID: 3, - DefNetType: "NONE", - DeletedBy: "", - DeletedTime: 0, - Description: "", - GID: 212, - GUID: 7973, - ID: 7973, - LockStatus: "kjLOCKED", - Milestones: 363471, - Name: "rg_3", - RegisterComputes: false, + CreatedBy: "sample_user_2@decs3o", + CreatedTime: 1676645548, + DefNetID: 3, + DefNetType: "NONE", + DeletedBy: "", + DeletedTime: 0, + Description: "", + GID: 212, + GUID: 7973, + ID: 7973, + LockStatus: "kjLOCKED", + Milestones: 363471, + Name: "rg_3", ResourceLimits: ResourceLimits{ CUC: -1, CUI: -1, diff --git a/pkg/cloudapi/rg/models.go b/pkg/cloudapi/rg/models.go index 4f418ab..6232570 100644 --- a/pkg/cloudapi/rg/models.go +++ b/pkg/cloudapi/rg/models.go @@ -128,9 +128,6 @@ type RecordResourceGroup struct { // Name Name string `json:"name"` - // RegisterComputes - RegisterComputes bool `json:"registerComputes"` - // Resource limits ResourceLimits ResourceLimits `json:"resourceLimits"` @@ -224,9 +221,6 @@ type ItemResourceGroup struct { // Name Name string `json:"name"` - // RegisterComputes - RegisterComputes bool `json:"registerComputes"` - // Resource limits ResourceLimits ResourceLimits `json:"resourceLimits"` diff --git a/pkg/cloudbroker/account/delete.go b/pkg/cloudbroker/account/delete.go index 1b17782..fad7b3e 100644 --- a/pkg/cloudbroker/account/delete.go +++ b/pkg/cloudbroker/account/delete.go @@ -16,6 +16,14 @@ type DeleteRequest struct { // Whether to completely delete the account // Required: false Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"` + + // Name of account + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // Reason of deleting + // Required: false + Reason string `url:"reason,omitempty" json:"reason,omitempty"` } // Delete completes delete an account from the system Returns true if account is deleted or was already deleted or never existed diff --git a/pkg/cloudbroker/apiaccess/api_find.go b/pkg/cloudbroker/apiaccess/api_find.go index e27dc8c..f3fdb70 100644 --- a/pkg/cloudbroker/apiaccess/api_find.go +++ b/pkg/cloudbroker/apiaccess/api_find.go @@ -21,9 +21,7 @@ type APIFindRequest struct { //API endpoint to find (delete, create, etc) //Required: true - APIMethod string `url:"api_method" json:"api_method" valudate:"required"` - - + APIMethod string `url:"api_method" json:"api_method" validate:"required"` } // APIFind outputs a list of apiaccess groups that mention the specified API function. diff --git a/pkg/cloudbroker/apiaccess/list.go b/pkg/cloudbroker/apiaccess/list.go index eee1a80..238f2a4 100644 --- a/pkg/cloudbroker/apiaccess/list.go +++ b/pkg/cloudbroker/apiaccess/list.go @@ -22,6 +22,9 @@ type ListRequest struct { // Required: false Status string `url:"status,omitempty" json:"status,omitempty"` + // Find by description + // Required: false + Desc string `url:"desc,omitempty" json:"desc,omitempty"` // Find by created after time (unix timestamp) // Required: false diff --git a/pkg/cloudbroker/bservice/create.go b/pkg/cloudbroker/bservice/create.go new file mode 100644 index 0000000..90b97d9 --- /dev/null +++ b/pkg/cloudbroker/bservice/create.go @@ -0,0 +1,50 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// CreateRequest struct for BasicService +type CreateRequest struct { + // Name of the service + // Required: true + Name string `url:"name" json:"name" validate:"required"` + + // ID of the Resource Group where this service will be placed + // Required: true + RGID uint64 `url:"rgId" json:"rgId" validate:"required"` + + // Name of the user to deploy SSH key for. Pass empty string if no SSH key deployment is required + // Required: false + SSHUser string `url:"sshUser,omitempty" json:"sshUser,omitempty"` + + // SSH key to deploy for the specified user. Same key will be deployed to all computes of the service + // Required: false + SSHKey string `url:"sshKey,omitempty" json:"sshKey,omitempty"` +} + +// Create creates blank BasicService instance +func (b BService) Create(ctx context.Context, req CreateRequest) (uint64, error) { + err := validators.ValidateRequest(req) + if err != nil { + return 0, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/create" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return 0, err + } + + result, err := strconv.ParseUint(string(res), 10, 64) + if err != nil { + return 0, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/delete.go b/pkg/cloudbroker/bservice/delete.go new file mode 100644 index 0000000..9e53e32 --- /dev/null +++ b/pkg/cloudbroker/bservice/delete.go @@ -0,0 +1,42 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// DeleteRequest struct to delete basic service +type DeleteRequest struct { + // ID of the BasicService to be delete + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // If set to False, Basic service will be deleted to recycle bin. Otherwise destroyed immediately + // Required: true + Permanently bool `url:"permanently" json:"permanently"` +} + +// Delete deletes BasicService instance +func (b BService) Delete(ctx context.Context, req DeleteRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/delete" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/disable.go b/pkg/cloudbroker/bservice/disable.go new file mode 100644 index 0000000..5bf69d3 --- /dev/null +++ b/pkg/cloudbroker/bservice/disable.go @@ -0,0 +1,40 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// DisableRequest struct for disable service +type DisableRequest struct { + // ID of the service to disable + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` +} + +// Disable disables service. +// Disabling a service technically means setting model status +// of all computes and service itself to DISABLED and stopping all computes. +func (b BService) Disable(ctx context.Context, req DisableRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/disable" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/enable.go b/pkg/cloudbroker/bservice/enable.go new file mode 100644 index 0000000..1770bcc --- /dev/null +++ b/pkg/cloudbroker/bservice/enable.go @@ -0,0 +1,41 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// EnableRequest struct to disable service +type EnableRequest struct { + // ID of the service to enable + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` +} + +// Enable enables service. +// Enabling a service technically means setting model status of +// all computes and service itself to ENABLED. +// It does not start computes. +func (b BService) Enable(ctx context.Context, req EnableRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/enable" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/group_add.go b/pkg/cloudbroker/bservice/group_add.go new file mode 100644 index 0000000..618276e --- /dev/null +++ b/pkg/cloudbroker/bservice/group_add.go @@ -0,0 +1,112 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GroupAddRequest struct to create new compute group within BasicService +type GroupAddRequest struct { + // ID of the Basic Service to add a group to + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // Name of the Compute Group to add + // Required: true + Name string `url:"name" json:"name" validate:"required"` + + // Computes number. Defines how many computes must be there in the group + // Required: true + Count uint64 `url:"count" json:"count" validate:"required"` + + // Compute CPU number. All computes in the group have the same CPU count + // Required: true + CPU uint64 `url:"cpu" json:"cpu" validate:"required"` + + // Compute RAM volume in MB. All computes in the group have the same RAM volume + // Required: true + RAM uint64 `url:"ram" json:"ram" validate:"required"` + + // Compute boot disk size in GB + // Required: true + Disk uint64 `url:"disk" json:"disk" validate:"required"` + + // OS image ID to create computes from + // Required: true + ImageID uint64 `url:"imageId" json:"imageId" validate:"required"` + + // Compute driver + // should be one of: + // - KVM_X86 + // Required: true + Driver string `url:"driver" json:"driver" validate:"driver"` + + // Storage endpoint provider ID + // Required: false + SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"` + + // Pool to use if sepId is set, can be also empty if needed to be chosen by system + // Required: false + SEPPool string `url:"sepPool,omitempty" json:"sepPool,omitempty"` + + // Group role tag. Can be empty string, does not have to be unique + // Required: false + Role string `url:"role,omitempty" json:"role,omitempty"` + + // List of ViNSes to connect computes to + // Required: false + VINSes []uint64 `url:"vinses,omitempty" json:"vinses,omitempty"` + + // List of external networks to connect computes to + // Required: false + ExtNets []uint64 `url:"extnets,omitempty" json:"extnets,omitempty"` + + // Time of Compute Group readiness + // Required: false + TimeoutStart uint64 `url:"timeoutStart,omitempty" json:"timeoutStart,omitempty"` + + // Meta data for working group computes, format YAML "user_data": 1111 + // Required: false + UserData string `url:"userData,omitempty" json:"userData,omitempty"` + + //Chipset "i440fx" or "Q35 + //Required: false + Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"chipset"` +} + +// GetRAM returns RAM field values +func (r GroupAddRequest) GetRAM() map[string]uint64 { + + res := make(map[string]uint64, 1) + + res["RAM"] = r.RAM + + return res +} + +// GroupAdd creates new Compute Group within BasicService. +// Compute Group is NOT started automatically, +// so you need to explicitly start it +func (b BService) GroupAdd(ctx context.Context, req GroupAddRequest) (uint64, error) { + err := validators.ValidateRequest(req) + if err != nil { + return 0, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/groupAdd" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return 0, err + } + + result, err := strconv.ParseUint(string(res), 10, 64) + if err != nil { + return 0, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/group_compute_remove.go b/pkg/cloudbroker/bservice/group_compute_remove.go new file mode 100644 index 0000000..4be4fdb --- /dev/null +++ b/pkg/cloudbroker/bservice/group_compute_remove.go @@ -0,0 +1,46 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GroupComputeRemoveRequest struct to remove group compute +type GroupComputeRemoveRequest struct { + // ID of the Basic Service + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // ID of the Compute GROUP + // Required: true + CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"` + + // ID of the Compute + // Required: true + ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` +} + +// GroupComputeRemove makes group compute remove of the Basic Service +func (b BService) GroupComputeRemove(ctx context.Context, req GroupComputeRemoveRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/groupComputeRemove" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/group_get.go b/pkg/cloudbroker/bservice/group_get.go new file mode 100644 index 0000000..4adec31 --- /dev/null +++ b/pkg/cloudbroker/bservice/group_get.go @@ -0,0 +1,44 @@ +package bservice + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GroupGetRequest struct to get detailed information about Compute Group +type GroupGetRequest struct { + // ID of the Basic Service of Compute Group + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // ID of the Compute Group + // Required: true + CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"` +} + +// GroupGet gets detailed specifications for the Compute Group +func (b BService) GroupGet(ctx context.Context, req GroupGetRequest) (*RecordGroup, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/groupGet" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return nil, err + } + + info := RecordGroup{} + + err = json.Unmarshal(res, &info) + if err != nil { + return nil, err + } + + return &info, nil +} diff --git a/pkg/cloudbroker/bservice/group_parent_remove.go b/pkg/cloudbroker/bservice/group_parent_remove.go new file mode 100644 index 0000000..2a6a9c1 --- /dev/null +++ b/pkg/cloudbroker/bservice/group_parent_remove.go @@ -0,0 +1,48 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GroupParentRemoveRequest struct to remove parent Compute Group +// relation from the specified Compute Group +type GroupParentRemoveRequest struct { + // ID of the Basic Service of Compute Group + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // ID of the Compute Group + // Required: true + CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"` + + // ID of the parent Compute Group + // to remove from the current Compute Group + // Required: true + ParentID uint64 `url:"parentId" json:"parentId" validate:"required"` +} + +// GroupParentRemove removes parent Compute Group relation to the specified Compute Group +func (b BService) GroupParentRemove(ctx context.Context, req GroupParentRemoveRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/groupParentRemove" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/group_parrent_add.go b/pkg/cloudbroker/bservice/group_parrent_add.go new file mode 100644 index 0000000..db0c5b1 --- /dev/null +++ b/pkg/cloudbroker/bservice/group_parrent_add.go @@ -0,0 +1,46 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GroupParentAddRequest struct to add parent Compute Group relation to the specified Compute Group +type GroupParentAddRequest struct { + // ID of the Basic Service of Compute Group + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // ID of the Compute Group + // Required: true + CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"` + + // ID of the parent Compute Group to register with the current Compute Group + // Required: true + ParentID uint64 `url:"parentId" json:"parentId" validate:"required"` +} + +// GroupParentAdd add parent Compute Group relation to the specified Compute Group +func (b BService) GroupParentAdd(ctx context.Context, req GroupParentAddRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/groupParentAdd" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/group_remove.go b/pkg/cloudbroker/bservice/group_remove.go new file mode 100644 index 0000000..2286ca7 --- /dev/null +++ b/pkg/cloudbroker/bservice/group_remove.go @@ -0,0 +1,43 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GroupRemoveRequest struct for destroy the specified Compute Group +type GroupRemoveRequest struct { + // ID of the Basic Service of Compute Group + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // ID of the Compute Group + // Required: true + CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"` +} + +// GroupRemove destroy the specified Compute Group +func (b BService) GroupRemove(ctx context.Context, req GroupRemoveRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/groupRemove" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/group_resize.go b/pkg/cloudbroker/bservice/group_resize.go new file mode 100644 index 0000000..e266bd2 --- /dev/null +++ b/pkg/cloudbroker/bservice/group_resize.go @@ -0,0 +1,59 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GroupResizeRequest struct to resize the group +type GroupResizeRequest struct { + // ID of the Basic Service of Compute Group + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // ID of the Compute Group to resize + // Required: true + CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"` + + // Either delta or absolute value of computes + // Required: true + Count int64 `url:"count" json:"count" validate:"required"` + + //Chipset for new computes, either i440fx or Q35 (i440fx by default) + //Available values : i440fx, Q35 + //Default value : i440fx + //Required: true + Chipset string `url:"chipset" json:"chipset" validate:"required,chipset"` + + // Either delta or absolute value of computes + // Should be one of: + // - ABSOLUTE + // - RELATIVE + // Required: true + Mode string `url:"mode" json:"mode" validate:"bserviceMode"` +} + +// GroupResize resize the group by changing the number of computes +func (b BService) GroupResize(ctx context.Context, req GroupResizeRequest) (uint64, error) { + err := validators.ValidateRequest(req) + if err != nil { + return 0, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/groupResize" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return 0, err + } + + result, err := strconv.ParseUint(string(res), 10, 64) + if err != nil { + return 0, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/group_start.go b/pkg/cloudbroker/bservice/group_start.go new file mode 100644 index 0000000..509feb2 --- /dev/null +++ b/pkg/cloudbroker/bservice/group_start.go @@ -0,0 +1,42 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GroupStartRequest struct to start the specified Compute Group +type GroupStartRequest struct { + // ID of the Basic Service of Compute Group + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // ID of the Compute Group to start + // Required: true + CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"` +} + +// GroupStart starts the specified Compute Group within BasicService +func (b BService) GroupStart(ctx context.Context, req GroupStartRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/groupStart" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/group_stop.go b/pkg/cloudbroker/bservice/group_stop.go new file mode 100644 index 0000000..00bee1d --- /dev/null +++ b/pkg/cloudbroker/bservice/group_stop.go @@ -0,0 +1,46 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GroupStopRequest struct to stop the specified Compute Group +type GroupStopRequest struct { + // ID of the Basic Service of Compute Group + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // ID of the Compute Group to stop + // Required: true + CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"` + + // Force stop Compute Group + // Required: false + Force bool `url:"force,omitempty" json:"force,omitempty"` +} + +// GroupStop stops the specified Compute Group within BasicService +func (b BService) GroupStop(ctx context.Context, req GroupStopRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/groupStop" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/group_update.go b/pkg/cloudbroker/bservice/group_update.go new file mode 100644 index 0000000..a033e1d --- /dev/null +++ b/pkg/cloudbroker/bservice/group_update.go @@ -0,0 +1,76 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GroupUpdateRequest struct to update existing Compute group +type GroupUpdateRequest struct { + // ID of the Basic Service of Compute Group + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // ID of the Compute Group + // Required: true + CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"` + + // Specify non-empty string to update Compute Group name + // Required: false + Name string `url:"name,omitempty" json:"name,omitempty"` + + // Specify non-empty string to update group role + // Required: false + Role string `url:"role,omitempty" json:"role,omitempty"` + + // Specify positive value to set new compute CPU count + // Required: false + CPU uint64 `url:"cpu,omitempty" json:"cpu,omitempty"` + + // Specify positive value to set new compute RAM volume in MB + // Required: false + RAM uint64 `url:"ram,omitempty" json:"ram,omitempty"` + + // Specify new compute boot disk size in GB + // Required: false + Disk uint64 `url:"disk,omitempty" json:"disk,omitempty"` + + // Force resize Compute Group + // Required: false + Force bool `url:"force,omitempty" json:"force,omitempty"` +} + +// GetRAM returns RAM field values +func (r GroupUpdateRequest) GetRAM() map[string]uint64 { + + res := make(map[string]uint64, 1) + + res["RAM"] = r.RAM + + return res +} + +// GroupUpdate updates existing Compute group within Basic Service and apply new settings to its computes as necessary +func (b BService) GroupUpdate(ctx context.Context, req GroupUpdateRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/groupUpdate" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/group_update_extnet.go b/pkg/cloudbroker/bservice/group_update_extnet.go new file mode 100644 index 0000000..d4ad68c --- /dev/null +++ b/pkg/cloudbroker/bservice/group_update_extnet.go @@ -0,0 +1,46 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GroupUpdateExtNetRequest struct to update External Network settings +type GroupUpdateExtNetRequest struct { + // ID of the Basic Service of Compute Group + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // ID of the Compute Group + // Required: true + CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"` + + // List of Extnets to connect computes + // Required: false + ExtNets []uint64 `url:"extnets,omitempty" json:"extnets,omitempty"` +} + +// GroupUpdateExtNet updates External Network settings for the group according to the new list +func (b BService) GroupUpdateExtNet(ctx context.Context, req GroupUpdateExtNetRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/groupUpdateExtnet" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/group_update_vins.go b/pkg/cloudbroker/bservice/group_update_vins.go new file mode 100644 index 0000000..d52c2e8 --- /dev/null +++ b/pkg/cloudbroker/bservice/group_update_vins.go @@ -0,0 +1,46 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// GroupUpdateVINSRequest struct to update VINS settings +type GroupUpdateVINSRequest struct { + // ID of the Basic Service of Compute Group + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // ID of the Compute Group + // Required: true + CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"` + + // List of ViNSes to connect computes + // Required: false + VINSes []uint64 `url:"vinses,omitempty" json:"vinses,omitempty"` +} + +// GroupUpdateVINS update ViNS settings for the group according to the new list +func (b BService) GroupUpdateVINS(ctx context.Context, req GroupUpdateVINSRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/groupUpdateVins" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/list_deleted.go b/pkg/cloudbroker/bservice/list_deleted.go new file mode 100644 index 0000000..fce9a4e --- /dev/null +++ b/pkg/cloudbroker/bservice/list_deleted.go @@ -0,0 +1,56 @@ +package bservice + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// ListDeletedRequest struct to get list of deleted BasicService instances +type ListDeletedRequest struct { + // ID of the account to query for BasicService instances + // Required: false + AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"` + + // ID of the resource group to query for BasicService instances + // Required: false + RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"` + + // Sort by one of supported fields, format +|-(field) + // Required: false + SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"` + + // Page number + // Required: false + Page uint64 `url:"page,omitempty" json:"page,omitempty"` + + // Page size + // Required: false + Size uint64 `url:"size,omitempty" json:"size,omitempty"` +} + +// ListDeleted gets list of deleted BasicService instances associated with the specified Resource Group +func (b BService) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListBasicServices, error) { + + if err := validators.ValidateRequest(req); err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/listDeleted" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return nil, err + } + + list := ListBasicServices{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} diff --git a/pkg/cloudbroker/bservice/models.go b/pkg/cloudbroker/bservice/models.go index fc176a9..08a0521 100644 --- a/pkg/cloudbroker/bservice/models.go +++ b/pkg/cloudbroker/bservice/models.go @@ -255,3 +255,147 @@ type ItemBasicService struct { // User Managed or not UserManaged bool `json:"userManaged"` } + +// List of Snapshots +type ListInfoSnapshots struct { + // Data + Data ListSnapshots `json:"data"` + + // EntryCount + EntryCount uint64 `json:"entryCount"` +} + +// Main information about Group +type RecordGroup struct { + // Account ID + AccountID uint64 `json:"accountId"` + + // Account Name + AccountName string `json:"accountName"` + + // List of Computes + Computes ListGroupComputes `json:"computes"` + + // Consistency or not + Consistency bool `json:"consistency"` + + // Number of CPU + CPU uint64 `json:"cpu"` + + // Created by + CreatedBy string `json:"createdBy"` + + // Created time + CreatedTime uint64 `json:"createdTime"` + + // Deleted by + DeletedBy string `json:"deletedBy"` + + // Deleted time + DeletedTime uint64 `json:"deletedTime"` + + // Amount of disk + Disk uint64 `json:"disk"` + + // Driver + Driver string `json:"driver"` + + // list of External Network IDs + ExtNets []uint64 `json:"extnets"` + + // Grid ID + GID uint64 `json:"gid"` + + // GUID + GUID uint64 `json:"guid"` + + // ID + ID uint64 `json:"id"` + + // Image ID + ImageID uint64 `json:"imageId"` + + // Milestones + Milestones uint64 `json:"milestones"` + + // Name + Name string `json:"name"` + + // List of Parent IDs + Parents []uint64 `json:"parents"` + + // Pool name + PoolName string `json:"poolName"` + + // Number of RAM, MB + RAM uint64 `json:"ram"` + + // Resource group ID + RGID uint64 `json:"rgId"` + + // Resource group name + RGName string `json:"rgName"` + + // Role + Role string `json:"role"` + + // SEPID + SEPID uint64 `json:"sepId"` + + // Sequence number + SeqNo uint64 `json:"seqNo"` + + // Service ID + ServiceID uint64 `json:"serviceId"` + + // Status + Status string `json:"status"` + + // TechStatus + TechStatus string `json:"techStatus"` + + // Timeout Start + TimeoutStart uint64 `json:"timeoutStart"` + + // Updated by + UpdatedBy string `json:"updatedBy"` + + // Updated time + UpdatedTime uint64 `json:"updatedTime"` + + // List of VINS IDs + VINSes []uint64 `json:"vinses"` +} + +// List of Group Computes +type ListGroupComputes []ItemGroupCompute + +// Main information about Group Compute +type ItemGroupCompute struct { + // ID + ID uint64 `json:"id"` + + // IP Addresses + IPAddresses []string `json:"ipAddresses"` + + // Name + Name string `json:"name"` + + // List of information about OS Users + OSUsers ListOSUsers `json:"osUsers"` + + //Chipset + Chipset string `json:"chipset"` +} + +// List of information about OS Users +type ListOSUsers []ItemOSUser + +// Main information about OS User +type ItemOSUser struct { + // Login + Login string `json:"login"` + + // Password + Password string `json:"password"` +} diff --git a/pkg/cloudbroker/bservice/restore.go b/pkg/cloudbroker/bservice/restore.go new file mode 100644 index 0000000..283f5ac --- /dev/null +++ b/pkg/cloudbroker/bservice/restore.go @@ -0,0 +1,38 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// RestoreRequest struct to restore BasicService instance +type RestoreRequest struct { + // ID of the BasicService to be restored + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` +} + +// Restore restores BasicService instance +func (b BService) Restore(ctx context.Context, req RestoreRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/restore" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/snapshot_create.go b/pkg/cloudbroker/bservice/snapshot_create.go new file mode 100644 index 0000000..dc8e764 --- /dev/null +++ b/pkg/cloudbroker/bservice/snapshot_create.go @@ -0,0 +1,42 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// SnapshotCreateRequest struct to create snapshot +type SnapshotCreateRequest struct { + // ID of the Basic Service + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // Label of the snapshot + // Required: true + Label string `url:"label" json:"label" validate:"required"` +} + +// SnapshotCreate create snapshot of the Basic Service +func (b BService) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/snapshotCreate" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/snapshot_delete.go b/pkg/cloudbroker/bservice/snapshot_delete.go new file mode 100644 index 0000000..66ef152 --- /dev/null +++ b/pkg/cloudbroker/bservice/snapshot_delete.go @@ -0,0 +1,42 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// SnapshotDeleteRequest struct to delete snapshot +type SnapshotDeleteRequest struct { + // ID of the Basic Service + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // Label of the snapshot + // Required: true + Label string `url:"label" json:"label" validate:"required"` +} + +// SnapshotDelete delete snapshot of the Basic Service +func (b BService) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/snapshotDelete" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/snapshot_list.go b/pkg/cloudbroker/bservice/snapshot_list.go new file mode 100644 index 0000000..69333a7 --- /dev/null +++ b/pkg/cloudbroker/bservice/snapshot_list.go @@ -0,0 +1,40 @@ +package bservice + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// SnapshotListRequest struct to get list of existing snapshots +type SnapshotListRequest struct { + // ID of the Basic Service + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` +} + +// SnapshotList gets list existing snapshots of the Basic Service +func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (*ListInfoSnapshots, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/snapshotList" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return nil, err + } + + list := ListInfoSnapshots{} + + err = json.Unmarshal(res, &list) + if err != nil { + return nil, err + } + + return &list, nil +} diff --git a/pkg/cloudbroker/bservice/snapshot_rollback.go b/pkg/cloudbroker/bservice/snapshot_rollback.go new file mode 100644 index 0000000..2908015 --- /dev/null +++ b/pkg/cloudbroker/bservice/snapshot_rollback.go @@ -0,0 +1,42 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// SnapshotRollbackRequest struct to rollback snapshot +type SnapshotRollbackRequest struct { + // ID of the Basic Service + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` + + // Label of the snapshot + // Required: true + Label string `url:"label" json:"label" validate:"required"` +} + +// SnapshotRollback rollback snapshot of the Basic Service +func (b BService) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/snapshotRollback" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/start.go b/pkg/cloudbroker/bservice/start.go new file mode 100644 index 0000000..b0bdcc4 --- /dev/null +++ b/pkg/cloudbroker/bservice/start.go @@ -0,0 +1,40 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// StartRequest struct to start service +type StartRequest struct { + // ID of the service to start + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` +} + +// Start starts service. +// Starting a service technically means starting computes from all +// service groups according to group relations +func (b BService) Start(ctx context.Context, req StartRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/start" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/bservice/stop.go b/pkg/cloudbroker/bservice/stop.go new file mode 100644 index 0000000..55e4947 --- /dev/null +++ b/pkg/cloudbroker/bservice/stop.go @@ -0,0 +1,40 @@ +package bservice + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" +) + +// StopRequest struct to stop service +type StopRequest struct { + // ID of the service to stop + // Required: true + ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` +} + +// Stop stops service. +// Stopping a service technically means stopping computes from +// all service groups +func (b BService) Stop(ctx context.Context, req StopRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/bservice/stop" + + res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} diff --git a/pkg/cloudbroker/compute/create_template_from_blank.go b/pkg/cloudbroker/compute/create_template_from_blank.go index d394976..287f906 100644 --- a/pkg/cloudbroker/compute/create_template_from_blank.go +++ b/pkg/cloudbroker/compute/create_template_from_blank.go @@ -39,10 +39,6 @@ type CreateTemplateFromBlankRequest struct { // Required: false AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"` - // SEP ID - // Required: false - SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"` - // Pool for image create // Required: false PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"` diff --git a/pkg/cloudbroker/compute/models.go b/pkg/cloudbroker/compute/models.go index 7e0018e..eab2bd2 100644 --- a/pkg/cloudbroker/compute/models.go +++ b/pkg/cloudbroker/compute/models.go @@ -485,7 +485,7 @@ type ItemDisk struct { Type string `json:"type"` // Updated by - UpdatedBy uint64 `json:"updatedBy"` + UpdatedBy string `json:"updatedBy"` // Virtual machine ID VMID uint64 `json:"vmid"` diff --git a/pkg/cloudbroker/compute/update.go b/pkg/cloudbroker/compute/update.go index dc3d428..5a2ebfa 100644 --- a/pkg/cloudbroker/compute/update.go +++ b/pkg/cloudbroker/compute/update.go @@ -30,29 +30,26 @@ type UpdateRequest struct { // Default: none NumaAffinity string `url:"numaAffinity,omitempty" json:"numaAffinity,omitempty" validate:"omitempty,numaAffinity"` - // Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node + // Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node, true or false // Required: false - // Default: false - CPUPin bool `url:"cpupin" json:"cpupin"` + CPUPin interface{} `url:"cpupin,omitempty" json:"cpupin,omitempty" validate:"omitempty,isBool"` // Type of the emulated system, Q35 or i440fx // Required: false Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` - // Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node + // Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node, true or false // Required: false - // Default: false - HPBacked bool `url:"hpBacked" json:"hpBacked"` + HPBacked interface{} `url:"hpBacked,omitempty" json:"hpBacked,omitempty" validate:"omitempty,isBool"` - // Auto start when node restarted + // Auto start when node restarted, true or false // Required: false - // Default: false - AutoStart bool `url:"autoStart" json:"autoStart"` + AutoStart interface{} `url:"autoStart,omitempty" json:"autoStart,omitempty" validate:"omitempty,isBool"` // Recommended isolated CPUs. Field is ignored if compute.cpupin=False or compute.pinned=False // Required: false PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"` - + // VM type linux, windows or unknown // Required: false LoaderType string `url:"loaderType,omitempty" json:"loaderType,omitempty" validate:"omitempty,loaderType"` @@ -65,9 +62,9 @@ type UpdateRequest struct { // Required: false NetworkInterfaceNaming string `url:"networkInterfaceNaming,omitempty" json:"networkInterfaceNaming,omitempty" validate:"omitempty,networkInterfaceNaming"` - // Does this machine supports hot resize + // Does this machine supports hot resize, true or false // Required: false - HotResize bool `url:"hotResize,omitempty" json:"hotResize,omitempty"` + HotResize interface{} `url:"hotResize,omitempty" json:"hotResize,omitempty" validate:"omitempty,isBool"` } // Update updates some properties of the compute diff --git a/pkg/cloudbroker/disks/filter_test.go b/pkg/cloudbroker/disks/filter_test.go index 09932ff..c31e65a 100644 --- a/pkg/cloudbroker/disks/filter_test.go +++ b/pkg/cloudbroker/disks/filter_test.go @@ -5,11 +5,12 @@ import "testing" var disks = ListDisks{ Data: []ItemDisk{ { - MachineID: 0, - MachineName: "", + RecordDisk: RecordDisk{ - DeviceName: "vda", - SEPType: "", + MachineID: 0, + MachineName: "", + DeviceName: "vda", + SEPType: "", InfoDisk: InfoDisk{ AccountID: 132847, AccountName: "std_2", @@ -64,11 +65,12 @@ var disks = ListDisks{ }, }, { - MachineID: 0, - MachineName: "", + RecordDisk: RecordDisk{ - DeviceName: "vda", - SEPType: "", + MachineID: 0, + MachineName: "", + DeviceName: "vda", + SEPType: "", InfoDisk: InfoDisk{ AccountID: 132852, AccountName: "std", diff --git a/pkg/cloudbroker/disks/from_platform_disk.go b/pkg/cloudbroker/disks/from_platform_disk.go index 74b8876..690b05c 100644 --- a/pkg/cloudbroker/disks/from_platform_disk.go +++ b/pkg/cloudbroker/disks/from_platform_disk.go @@ -45,10 +45,6 @@ type FromPlatformDiskRequest struct { // Required: false AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"` - // SEP ID - // Required: false - SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"` - // Pool for image create // Required: false PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"` diff --git a/pkg/cloudbroker/node/enable_nodes.go b/pkg/cloudbroker/node/enable_nodes.go index a8dffd4..9602949 100644 --- a/pkg/cloudbroker/node/enable_nodes.go +++ b/pkg/cloudbroker/node/enable_nodes.go @@ -13,9 +13,9 @@ type EnableNodesRequest struct { // Required: true NIDs []uint64 `url:"nids" json:"nids" validate:"required"` - // Message + // Reason // Required: false - Message string `url:"message,omitempty" json:"message,omitempty"` + Reason string `url:"reason,omitempty" json:"reason,omitempty"` } // EnableNodes enables nodes from maintenance status to enabled diff --git a/pkg/cloudbroker/node/models.go b/pkg/cloudbroker/node/models.go index 9835010..6f4c5cf 100644 --- a/pkg/cloudbroker/node/models.go +++ b/pkg/cloudbroker/node/models.go @@ -371,7 +371,7 @@ type Bridges struct { // Backplane1 type Backplane1 struct { Interfaces []string `json:"interfaces"` - NumaNode uint64 `json:"numa_node"` + NumaNode int64 `json:"numa_node"` } // Role diff --git a/pkg/cloudbroker/rg/filter_test.go b/pkg/cloudbroker/rg/filter_test.go index f206af6..f4b3b1f 100644 --- a/pkg/cloudbroker/rg/filter_test.go +++ b/pkg/cloudbroker/rg/filter_test.go @@ -17,20 +17,19 @@ var rgs = ListRG{ UserGroupID: "sample_user_1@decs3o", }, }, - CreatedBy: "sample_user_1@decs3o", - CreatedTime: 1676645305, - DefNetID: 1, - DefNetType: "NONE", - DeletedBy: "", - DeletedTime: 0, - Description: "", - GID: 212, - GUID: 7971, - ID: 7971, - LockStatus: "UNLOCKED", - Milestones: 363459, - Name: "rg_1", - RegisterComputes: false, + CreatedBy: "sample_user_1@decs3o", + CreatedTime: 1676645305, + DefNetID: 1, + DefNetType: "NONE", + DeletedBy: "", + DeletedTime: 0, + Description: "", + GID: 212, + GUID: 7971, + ID: 7971, + LockStatus: "UNLOCKED", + Milestones: 363459, + Name: "rg_1", ResourceLimits: ResourceLimits{ CUC: -1, CuD: -1, @@ -61,20 +60,19 @@ var rgs = ListRG{ UserGroupID: "sample_user_1@decs3o", }, }, - CreatedBy: "sample_user_1@decs3o", - CreatedTime: 1676645461, - DefNetID: 2, - DefNetType: "NONE", - DeletedBy: "", - DeletedTime: 0, - Description: "", - GID: 212, - GUID: 7972, - ID: 7972, - LockStatus: "UNLOCKED", - Milestones: 363468, - Name: "rg_2", - RegisterComputes: false, + CreatedBy: "sample_user_1@decs3o", + CreatedTime: 1676645461, + DefNetID: 2, + DefNetType: "NONE", + DeletedBy: "", + DeletedTime: 0, + Description: "", + GID: 212, + GUID: 7972, + ID: 7972, + LockStatus: "UNLOCKED", + Milestones: 363468, + Name: "rg_2", ResourceLimits: ResourceLimits{ CUC: -1, CuD: -1, @@ -105,20 +103,19 @@ var rgs = ListRG{ UserGroupID: "sample_user_2@decs3o", }, }, - CreatedBy: "sample_user_2@decs3o", - CreatedTime: 1676645548, - DefNetID: 3, - DefNetType: "NONE", - DeletedBy: "", - DeletedTime: 0, - Description: "", - GID: 212, - GUID: 7973, - ID: 7973, - LockStatus: "kjLOCKED", - Milestones: 363471, - Name: "rg_3", - RegisterComputes: false, + CreatedBy: "sample_user_2@decs3o", + CreatedTime: 1676645548, + DefNetID: 3, + DefNetType: "NONE", + DeletedBy: "", + DeletedTime: 0, + Description: "", + GID: 212, + GUID: 7973, + ID: 7973, + LockStatus: "kjLOCKED", + Milestones: 363471, + Name: "rg_3", ResourceLimits: ResourceLimits{ CUC: -1, CuD: -1, diff --git a/pkg/cloudbroker/rg/models.go b/pkg/cloudbroker/rg/models.go index d0d541b..c09ea4e 100644 --- a/pkg/cloudbroker/rg/models.go +++ b/pkg/cloudbroker/rg/models.go @@ -196,9 +196,6 @@ type ItemRG struct { // Name Name string `json:"name"` - // Register computes - RegisterComputes bool `json:"registerComputes"` - // Resource limits ResourceLimits ResourceLimits `json:"resourceLimits"` diff --git a/tests/platform_upgrade/README.md b/tests/platform_upgrade/README.md index bce82df..43d8c4f 100644 --- a/tests/platform_upgrade/README.md +++ b/tests/platform_upgrade/README.md @@ -17,7 +17,7 @@ 1. Тесты находятся по директории `decort-sdk/tests/platform_upgrade` 2. Внутри директории нужно создать и заполнить файл `.env` по аналогии с `.env.template` для доступа к платформе -3. Внутри директории нужно создать и заполнить файл `input.json`, содержащий json с раздела [POST /system/docgenerator/prepareCatalog](https://delta.qa.loc/system/ActorApi?group=system#!/system__docgenerator/post_system_docgenerator_prepareCatalog) (для получения json нажать кнопку Try it Out!) - требуется только для тестов запросов и тестов API методов +3. Внутри директории нужно создать и заполнить файл `input.json`, содержащий json из метода [POST /system/docgenerator/prepareCatalog](https://delta.qa.loc/portal/#/api/system) (для получения json нажать кнопку Try it Out!) - требуется только для тестов запросов и тестов API методов Примечание: тесты можно запускать напрямую методами среды разработки либо из командной строки из нужной директории, например командой `go test -v -run `, где `` - название запускаемого теста. diff --git a/tests/platform_upgrade/cloud_test.go b/tests/platform_upgrade/cloud_test.go index 563d78f..6b01359 100644 --- a/tests/platform_upgrade/cloud_test.go +++ b/tests/platform_upgrade/cloud_test.go @@ -21,10 +21,6 @@ import ( "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stack" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/tasks" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins" - disks_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/disks" - image_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image" - node_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node" - account_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/account" audit_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/audit" bservice_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/bservice" @@ -33,9 +29,11 @@ import ( extnet_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/extnet" flipgroup_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/flipgroup" grid_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/grid" + image_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image" k8ci_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/k8ci" k8s_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/k8s" lb_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/lb" + node_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node" pcidevice_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/pcidevice" rg_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg" sep_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep" @@ -53,8 +51,6 @@ func TestGetListCloudAPI(t *testing.T) { t.Fatalf("Cannot get client: %v", err) } - const logFileName = "test_get_list_cloudAPI.log" - var testLogs []string // Account // List bytes, err = client.CloudAPI().Account().ListRaw(context.Background(), account.ListRequest{}) @@ -62,7 +58,7 @@ func TestGetListCloudAPI(t *testing.T) { t.Error(err) } - testLogs = append(testLogs, getResult("Account list", bytes, account.ListAccounts{}, t)) + getResult("Account list", bytes, account.ListAccounts{}, t) // Get listAcc, _ := client.CloudAPI().Account().List(context.Background(), account.ListRequest{}) if len(listAcc.Data) > 0 { @@ -71,7 +67,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Account get", bytes, account.RecordAccount{}, t)) + getResult("Account get", bytes, account.RecordAccount{}, t) } else { t.Errorf("Can not test Account get because account list is empty") } @@ -82,7 +78,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Bservice list", bytes, bservice.ListBasicServices{}, t)) + getResult("Bservice list", bytes, bservice.ListBasicServices{}, t) // Get listBServ, _ := client.CloudAPI().BService().List(context.Background(), bservice.ListRequest{}) if len(listBServ.Data) > 0 { @@ -91,7 +87,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Bservice get", bytes, bservice.RecordBasicService{}, t)) + getResult("Bservice get", bytes, bservice.RecordBasicService{}, t) } else { t.Errorf("Can not test Bservice get because bservice list is empty") } @@ -102,7 +98,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Compute list", bytes, compute.ListComputes{}, t)) + getResult("Compute list", bytes, compute.ListComputes{}, t) // Get listComp, _ := client.CloudAPI().Compute().List(context.Background(), compute.ListRequest{}) if len(listComp.Data) > 0 { @@ -111,7 +107,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Compute get", bytes, compute.RecordCompute{}, t)) + getResult("Compute get", bytes, compute.RecordCompute{}, t) } else { t.Errorf("Can not test Compute get because compute list is empty") } @@ -122,7 +118,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Disk list", bytes, disks.ListDisks{}, t)) + getResult("Disk list", bytes, disks.ListDisks{}, t) // Get listDisk, _ := client.CloudAPI().Disks().List(context.Background(), disks.ListRequest{}) if len(listDisk.Data) > 0 { @@ -131,7 +127,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Disk get", bytes, disks.RecordDisk{}, t)) + getResult("Disk get", bytes, disks.RecordDisk{}, t) } else { t.Errorf("Can not test Disk get because disk list is empty") } @@ -142,7 +138,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("ExtNet list", bytes, extnet.ListExtNets{}, t)) + getResult("ExtNet list", bytes, extnet.ListExtNets{}, t) // Get listExtNet, _ := client.CloudAPI().ExtNet().List(context.Background(), extnet.ListRequest{}) if len(listExtNet.Data) > 0 { @@ -151,7 +147,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("ExtNet get", bytes, extnet.RecordExtNet{}, t)) + getResult("ExtNet get", bytes, extnet.RecordExtNet{}, t) } else { t.Errorf("Can not test ExtNet get because listExtNet list is empty") } @@ -162,7 +158,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("FLIPGroup list", bytes, flipgroup.ListFLIPGroups{}, t)) + getResult("FLIPGroup list", bytes, flipgroup.ListFLIPGroups{}, t) // Get listFG, _ := client.CloudAPI().FLIPGroup().List(context.Background(), flipgroup.ListRequest{}) if len(listFG.Data) > 0 { @@ -171,7 +167,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("FLIPGroup get", bytes, flipgroup.RecordFLIPGroup{}, t)) + getResult("FLIPGroup get", bytes, flipgroup.RecordFLIPGroup{}, t) } else { t.Errorf("Can not test FLIPGroup get because flipgroup list is empty") } @@ -182,7 +178,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Image list", bytes, image.ListImages{}, t)) + getResult("Image list", bytes, image.ListImages{}, t) // Get listImg, _ := client.CloudAPI().Image().List(context.Background(), image.ListRequest{}) if len(listImg.Data) > 0 { @@ -191,7 +187,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Image get", bytes, image.RecordImage{}, t)) + getResult("Image get", bytes, image.RecordImage{}, t) } else { t.Errorf("Can not test Image get because Image list is empty") } @@ -202,7 +198,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("K8CI list", bytes, k8ci.ListK8CI{}, t)) + getResult("K8CI list", bytes, k8ci.ListK8CI{}, t) // Get listk8ci, _ := client.CloudAPI().K8CI().List(context.Background(), k8ci.ListRequest{}) if len(listk8ci.Data) > 0 { @@ -211,7 +207,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("K8CI get", bytes, k8ci.RecordK8CI{}, t)) + getResult("K8CI get", bytes, k8ci.RecordK8CI{}, t) } else { t.Errorf("Can not test K8CI get because K8CI list is empty") } @@ -222,7 +218,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("K8S list", bytes, k8s.ListK8SClusters{}, t)) + getResult("K8S list", bytes, k8s.ListK8SClusters{}, t) // Get listk8s, _ := client.CloudAPI().K8S().List(context.Background(), k8s.ListRequest{}) if len(listk8s.Data) > 0 { @@ -231,7 +227,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("K8S get", bytes, k8s.RecordK8S{}, t)) + getResult("K8S get", bytes, k8s.RecordK8S{}, t) } else { t.Errorf("Can not test K8S get because K8S list is empty") } @@ -242,7 +238,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("LB list", bytes, lb.ListLB{}, t)) + getResult("LB list", bytes, lb.ListLB{}, t) // Get listLB, _ := client.CloudAPI().LB().List(context.Background(), lb.ListRequest{}) if len(listLB.Data) > 0 { @@ -251,7 +247,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("LB get", bytes, lb.RecordLB{}, t)) + getResult("LB get", bytes, lb.RecordLB{}, t) } else { t.Errorf("Can not test LB get because LB list is empty") } @@ -262,7 +258,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Locations list", bytes, locations.ListLocations{}, t)) + getResult("Locations list", bytes, locations.ListLocations{}, t) // RG // List @@ -270,7 +266,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("RG list", bytes, rg.ListResourceGroups{}, t)) + getResult("RG list", bytes, rg.ListResourceGroups{}, t) // Get listRG, _ := client.CloudAPI().RG().List(context.Background(), rg.ListRequest{}) if len(listRG.Data) > 0 { @@ -279,7 +275,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("RG get", bytes, rg.RecordResourceGroup{}, t)) + getResult("RG get", bytes, rg.RecordResourceGroup{}, t) } else { t.Errorf("Can not test RG get because RG list is empty") } @@ -290,7 +286,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("SEP list", bytes, sep.ListAvailableSEP{}, t)) + getResult("SEP list", bytes, sep.ListAvailableSEP{}, t) // Stack // List @@ -298,7 +294,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Stack list", bytes, stack.ListStacks{}, t)) + getResult("Stack list", bytes, stack.ListStacks{}, t) // Tasks // List @@ -306,7 +302,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Tasks list", bytes, tasks.ListTasks{}, t)) + getResult("Tasks list", bytes, tasks.ListTasks{}, t) // Get listTasks, _ := client.CloudAPI().Tasks().List(context.Background(), tasks.ListRequest{}) if len(listTasks.Data) > 0 { @@ -315,7 +311,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Tasks get", bytes, tasks.RecordAsyncTask{}, t)) + getResult("Tasks get", bytes, tasks.RecordAsyncTask{}, t) } else { t.Errorf("Can not test Tasks get because Tasks list is empty") } @@ -326,7 +322,7 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("VINS list", bytes, vins.ListVINS{}, t)) + getResult("VINS list", bytes, vins.ListVINS{}, t) // Get listVINS, _ := client.CloudAPI().VINS().List(context.Background(), vins.ListRequest{}) if len(listVINS.Data) > 0 { @@ -335,12 +331,11 @@ func TestGetListCloudAPI(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("VINS get", bytes, vins.RecordVINS{}, t)) + getResult("VINS get", bytes, vins.RecordVINS{}, t) } else { t.Errorf("Can not test VINS get because VINS list is empty") } - compareLogs(logFileName, testLogs, t, "get") } // WARNING: not working correctly due to inclusions of tagless structures in cloudbroker @@ -353,15 +348,13 @@ func TestGetListCloudbroker(t *testing.T) { t.Fatalf("Cannot get client: %v", err) } - const logFileName = "test_get_list_cloudbroker.log" - var testLogs = make([]string, 0) // Account // List bytes, err = client.CloudBroker().Account().ListRaw(context.Background(), account_cb.ListRequest{}) if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Account list", bytes, account_cb.ListAccounts{}, t)) + getResult("Account list", bytes, account_cb.ListAccounts{}, t) // Get listAcc, _ := client.CloudBroker().Account().List(context.Background(), account_cb.ListRequest{}) if len(listAcc.Data) > 0 { @@ -370,7 +363,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Account get", bytes, account_cb.RecordAccount{}, t)) + getResult("Account get", bytes, account_cb.RecordAccount{}, t) } else { t.Errorf("Can not test Account get because account list is empty") } @@ -381,7 +374,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Audit list", bytes, audit_cb.ListAudits{}, t)) + getResult("Audit list", bytes, audit_cb.ListAudits{}, t) // Get listAudits, _ := client.CloudBroker().Audit().List(context.Background(), audit_cb.ListRequest{}) if len(listAudits.Data) > 0 { @@ -390,7 +383,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Audit get", bytes, audit_cb.RecordAudit{}, t)) + getResult("Audit get", bytes, audit_cb.RecordAudit{}, t) } else { t.Errorf("Can not test Audit get because Audit list is empty") } @@ -401,7 +394,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Bservice list", bytes, bservice_cb.ListBasicServices{}, t)) + getResult("Bservice list", bytes, bservice_cb.ListBasicServices{}, t) // Get listBServ, _ := client.CloudBroker().BService().List(context.Background(), bservice_cb.ListRequest{}) if len(listBServ.Data) > 0 { @@ -410,7 +403,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Bservice get", bytes, bservice_cb.RecordBasicService{}, t)) + getResult("Bservice get", bytes, bservice_cb.RecordBasicService{}, t) } else { t.Errorf("Can not test Bservice get because bservice list is empty") } @@ -421,7 +414,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Compute list", bytes, compute_cb.ListComputes{}, t)) + getResult("Compute list", bytes, compute_cb.ListComputes{}, t) // Get listComp, _ := client.CloudBroker().Compute().List(context.Background(), compute_cb.ListRequest{}) if len(listComp.Data) > 0 { @@ -430,7 +423,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Compute get", bytes, compute_cb.RecordCompute{}, t)) + getResult("Compute get", bytes, compute_cb.RecordCompute{}, t) } else { t.Errorf("Can not test Compute get because compute list is empty") } @@ -441,7 +434,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Disk list", bytes, disks_cb.ListDisks{}, t)) + getResult("Disk list", bytes, disks_cb.ListDisks{}, t) // Get listDisk, _ := client.CloudBroker().Disks().List(context.Background(), disks_cb.ListRequest{}) if len(listDisk.Data) > 0 { @@ -450,7 +443,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Disk get", bytes, disks_cb.RecordDisk{}, t)) + getResult("Disk get", bytes, disks_cb.RecordDisk{}, t) } else { t.Errorf("Can not test Disk get because disk list is empty") } @@ -461,7 +454,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("ExtNet list", bytes, extnet_cb.ListExtNet{}, t)) + getResult("ExtNet list", bytes, extnet_cb.ListExtNet{}, t) // Get listExtNet, _ := client.CloudBroker().ExtNet().List(context.Background(), extnet_cb.ListRequest{}) if len(listExtNet.Data) > 0 { @@ -470,7 +463,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("ExtNet get", bytes, extnet_cb.RecordExtNet{}, t)) + getResult("ExtNet get", bytes, extnet_cb.RecordExtNet{}, t) } else { t.Errorf("Can not test ExtNet get because listExtNet list is empty") } @@ -481,7 +474,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("FLIPGroup list", bytes, flipgroup_cb.ListFLIPGroups{}, t)) + getResult("FLIPGroup list", bytes, flipgroup_cb.ListFLIPGroups{}, t) // Get listFG, _ := client.CloudBroker().FLIPGroup().List(context.Background(), flipgroup_cb.ListRequest{}) if len(listFG.Data) > 0 { @@ -490,7 +483,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("FLIPGroup get", bytes, flipgroup_cb.RecordFLIPGroup{}, t)) + getResult("FLIPGroup get", bytes, flipgroup_cb.RecordFLIPGroup{}, t) } else { t.Errorf("Can not test FLIPGroup get because flipgroup list is empty") } @@ -501,7 +494,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Grid list", bytes, grid_cb.ListGrids{}, t)) + getResult("Grid list", bytes, grid_cb.ListGrids{}, t) // Get listGrid, _ := client.CloudBroker().Grid().List(context.Background(), grid_cb.ListRequest{}) if len(listGrid.Data) > 0 { @@ -510,7 +503,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Grid get", bytes, grid_cb.RecordGrid{}, t)) + getResult("Grid get", bytes, grid_cb.RecordGrid{}, t) } else { t.Errorf("Can not test Grid get because Grid list is empty") } @@ -521,7 +514,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Image list", bytes, image_cb.ListImages{}, t)) + getResult("Image list", bytes, image_cb.ListImages{}, t) // Get listImg, _ := client.CloudBroker().Image().List(context.Background(), image_cb.ListRequest{}) if len(listImg.Data) > 0 { @@ -530,7 +523,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Image get", bytes, image_cb.RecordImage{}, t)) + getResult("Image get", bytes, image_cb.RecordImage{}, t) } else { t.Errorf("Can not test Image get because Image list is empty") } @@ -541,7 +534,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("K8CI list", bytes, k8ci_cb.ListK8CI{}, t)) + getResult("K8CI list", bytes, k8ci_cb.ListK8CI{}, t) // Get listk8ci, _ := client.CloudBroker().K8CI().List(context.Background(), k8ci_cb.ListRequest{}) if len(listk8ci.Data) > 0 { @@ -550,7 +543,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("K8CI get", bytes, k8ci_cb.RecordK8CI{}, t)) + getResult("K8CI get", bytes, k8ci_cb.RecordK8CI{}, t) } else { t.Errorf("Can not test K8CI get because K8CI list is empty") } @@ -561,7 +554,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("K8S list", bytes, k8s_cb.ListK8S{}, t)) + getResult("K8S list", bytes, k8s_cb.ListK8S{}, t) // Get listk8s, _ := client.CloudBroker().K8S().List(context.Background(), k8s_cb.ListRequest{}) if len(listk8s.Data) > 0 { @@ -570,7 +563,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("K8S get", bytes, k8s_cb.RecordK8S{}, t)) + getResult("K8S get", bytes, k8s_cb.RecordK8S{}, t) } else { t.Errorf("Can not test K8S get because K8S list is empty") } @@ -581,7 +574,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("LB list", bytes, lb_cb.ListLB{}, t)) + getResult("LB list", bytes, lb_cb.ListLB{}, t) // Get listLB, _ := client.CloudBroker().LB().List(context.Background(), lb_cb.ListRequest{}) if len(listLB.Data) > 0 { @@ -590,7 +583,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("LB get", bytes, lb_cb.RecordLB{}, t)) + getResult("LB get", bytes, lb_cb.RecordLB{}, t) } else { t.Errorf("Can not test LB get because LB list is empty") } @@ -601,7 +594,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Node list", bytes, node_cb.ListNodes{}, 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 { @@ -610,7 +603,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Node get", bytes, node_cb.RecordNode{}, t)) + getResult("Node get", bytes, node_cb.RecordNode{}, t) } else { t.Errorf("Can not test Node get because LB list is empty") } @@ -621,7 +614,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Pcidevice list", bytes, pcidevice_cb.ListPCIDevices{}, t)) + getResult("Pcidevice list", bytes, pcidevice_cb.ListPCIDevices{}, t) // RG // List @@ -629,7 +622,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("RG list", bytes, rg_cb.ListRG{}, t)) + getResult("RG list", bytes, rg_cb.ListRG{}, t) // Get listRG, _ := client.CloudBroker().RG().List(context.Background(), rg_cb.ListRequest{}) if len(listRG.Data) > 0 { @@ -638,7 +631,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("RG get", bytes, rg_cb.RecordRG{}, t)) + getResult("RG get", bytes, rg_cb.RecordRG{}, t) } else { t.Errorf("Can not test RG get because RG list is empty") } @@ -649,7 +642,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("SEP list", bytes, sep_cb.ListSEP{}, t)) + getResult("SEP list", bytes, sep_cb.ListSEP{}, t) // Get listSEP, _ := client.CloudBroker().SEP().List(context.Background(), sep_cb.ListRequest{}) if len(listSEP.Data) > 0 { @@ -658,7 +651,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("SEP get", bytes, sep_cb.RecordSEP{}, t)) + getResult("SEP get", bytes, sep_cb.RecordSEP{}, t) } else { t.Errorf("Can not test SEP get because SEP list is empty") } @@ -667,7 +660,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("SEP and pools list", bytes, sep_cb.ListAvailableSEP{}, t)) + getResult("SEP and pools list", bytes, sep_cb.ListAvailableSEP{}, t) // Stack // List @@ -675,7 +668,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Stack list", bytes, stack_cb.ListStacks{}, t)) + getResult("Stack list", bytes, stack_cb.ListStacks{}, t) // Get listStack, _ := client.CloudBroker().Stack().List(context.Background(), stack_cb.ListRequest{}) if len(listStack.Data) > 0 { @@ -684,7 +677,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Stack get", bytes, stack_cb.InfoStack{}, t)) + getResult("Stack get", bytes, stack_cb.InfoStack{}, t) } else { t.Errorf("Can not test Stack get because Stack list is empty") } @@ -695,7 +688,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("Tasks list", bytes, tasks_cb.ListTasks{}, t)) + getResult("Tasks list", bytes, tasks_cb.ListTasks{}, t) // VINS // List @@ -703,7 +696,7 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("VINS list", bytes, vins_cb.ListVINS{}, t)) + getResult("VINS list", bytes, vins_cb.ListVINS{}, t) // Get listVINS, _ := client.CloudBroker().VINS().List(context.Background(), vins_cb.ListRequest{}) if len(listVINS.Data) > 0 { @@ -712,11 +705,10 @@ func TestGetListCloudbroker(t *testing.T) { if err != nil { t.Error(err) } - testLogs = append(testLogs, getResult("VINS get", bytes, vins_cb.RecordVINS{}, t)) + getResult("VINS get", bytes, vins_cb.RecordVINS{}, t) } else { t.Errorf("Can not test VINS get because VINS list is empty") } - compareLogs(logFileName, testLogs, t, "get") } // TestRequestsCloudAPI tests platform requests vs. golang request structures in sdk for cloudapi requests @@ -759,4 +751,38 @@ func TestGetAllPaths(t *testing.T) { } t.Errorf(errorText) } + + caTestUrls := getRequestsMapCloudAPI() + cbTestUrls := getRequestsMapCloudbroker() + + urlsInTest := make([]string, len(caTestUrls)+len(cbTestUrls)) + + i := 0 + for k := range caTestUrls { + urlsInTest[i] = k + i++ + } + for k := range cbTestUrls { + urlsInTest[i] = k + i++ + } + + missingUrls = getMissingDecortUrls(jsonUrls, urlsInTest) + if len(missingUrls) > 0 { + errorText := fmt.Sprintf("Below API handlers (%d in total) need to be added to request map:\n", len(missingUrls)) + for _, r := range missingUrls { + errorText += fmt.Sprintln(r) + } + t.Errorf(errorText) + } + + deprecatedUrls = getDeprecatedDecortUrls(jsonUrls, urlsInTest) + if len(deprecatedUrls) > 0 { + errorText := fmt.Sprintf("Below API handlers (%d in total) need to be delete to request map:\n", len(deprecatedUrls)) + for _, r := range deprecatedUrls { + errorText += fmt.Sprintln(r) + } + t.Errorf(errorText) + } + } diff --git a/tests/platform_upgrade/request_map.go b/tests/platform_upgrade/request_map.go index 382089b..223c341 100644 --- a/tests/platform_upgrade/request_map.go +++ b/tests/platform_upgrade/request_map.go @@ -16,7 +16,9 @@ import ( "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/pcidevice" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/prometheus" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/sep" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stack" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/tasks" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/user" @@ -41,6 +43,7 @@ import ( lb_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/lb" node_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node" pcidevice_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/pcidevice" + prometheus_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/prometheus" rg_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg" sep_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep" stack_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/stack" @@ -188,6 +191,8 @@ func getRequestsMapCloudAPI() map[string]interface{} { "/restmachine/cloudapi/compute/userList": compute.UserListRequest{}, "/restmachine/cloudapi/compute/userRevoke": compute.UserRevokeRequest{}, "/restmachine/cloudapi/compute/userUpdate": compute.UserUpdateRequest{}, + "/restmachine/cloudapi/compute/changeMac": compute.ChangeMACRequest{}, + "/restmachine/cloudapi/compute/changeIp": compute.ChangeIPRequest{}, // disks "/restmachine/cloudapi/disks/create": disks.CreateRequest{}, @@ -315,6 +320,23 @@ func getRequestsMapCloudAPI() map[string]interface{} { // pcidevice "/restmachine/cloudapi/pcidevice/list": pcidevice.ListRequest{}, + // prometheus + "/restmachine/cloudapi/prometheus/computeTransmitPackets": prometheus.ComputeTransmitPacketsRequest{}, + "/restmachine/cloudapi/prometheus/computeWriteRequests": prometheus.ComputeWriteRequestsRequest{}, + "/restmachine/cloudapi/prometheus/computeCPUload": prometheus.ComputeCPULoadRequest{}, + "/restmachine/cloudapi/prometheus/computeTransmitBytes": prometheus.ComputeTransmitBytesRequest{}, + "/restmachine/cloudapi/prometheus/computeMemoryUsed": prometheus.ComputeMemoryUsedRequest{}, + "/restmachine/cloudapi/prometheus/computeMemoryUsable": prometheus.ComputeMemoryUsableRequest{}, + "/restmachine/cloudapi/prometheus/computeMemoryAvailable": prometheus.ComputeMemoryAvailableRequest{}, + "/restmachine/cloudapi/prometheus/computeReceiveBytes": prometheus.ComputeReceiveBytesRequest{}, + "/restmachine/cloudapi/prometheus/computes": prometheus.ComputesRequest{}, + "/restmachine/cloudapi/prometheus/computeReceivePackets": prometheus.ComputeReceivePacketsRequest{}, + "/restmachine/cloudapi/prometheus/computeReadRequests": prometheus.ComputeReadRequestsRequest{}, + "/restmachine/cloudapi/prometheus/computeWriteBytes": prometheus.ComputeWriteBytesRequest{}, + "/restmachine/cloudapi/prometheus/computeReadBytes": prometheus.ComputeReadBytesRequest{}, + "/restmachine/cloudapi/prometheus/computeMemoryUsage": prometheus.ComputeMemoryUsageRequest{}, + "/restmachine/cloudapi/prometheus/computeMemoryUnused": prometheus.ComputeMemoryUnusedRequest{}, + // rg "/restmachine/cloudapi/rg/accessGrant": rg.AccessGrantRequest{}, "/restmachine/cloudapi/rg/accessRevoke": rg.AccessRevokeRequest{}, @@ -339,6 +361,10 @@ func getRequestsMapCloudAPI() map[string]interface{} { "/restmachine/cloudapi/rg/setDefNet": rg.SetDefNetRequest{}, "/restmachine/cloudapi/rg/update": rg.UpdateRequest{}, "/restmachine/cloudapi/rg/usage": rg.UsageRequest{}, + "/restmachine/cloudapi/rg/removeDefNet": rg.RemoveDefNetRequest{}, + + // sep + "/restmachine/cloudapi/sep/listAvailableSepAndPools": sep.ListAvailableSEPAndPoolsRequest{}, // stack, tasks "/restmachine/cloudapi/stack/get": stack.GetRequest{}, @@ -427,27 +453,28 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/account/updateUser": account_cb.UpdateUserRequest{}, // apiaccess_cb - "/restmachine/cloudbroker/apiaccess/apisExclude": apiaccess_cb.APIsExcludeRequest{}, - "/restmachine/cloudbroker/apiaccess/apiFind": apiaccess_cb.APIFindRequest{}, - "/restmachine/cloudbroker/apiaccess/apisInclude": apiaccess_cb.APIsIncludeRequest{}, - "/restmachine/cloudbroker/apiaccess/copy": apiaccess_cb.CopyRequest{}, - "/restmachine/cloudbroker/apiaccess/create": apiaccess_cb.CreateRequest{}, - "/restmachine/cloudbroker/apiaccess/delete": apiaccess_cb.DeleteRequest{}, - "/restmachine/cloudbroker/apiaccess/descUpdate": apiaccess_cb.DescUpdateRequest{}, - "/restmachine/cloudbroker/apiaccess/get": apiaccess_cb.GetRequest{}, - "/restmachine/cloudbroker/apiaccess/getFull": EmptyStruct{}, - "/restmachine/cloudbroker/apiaccess/getPreGroups": EmptyStruct{}, - "/restmachine/cloudbroker/apiaccess/list": apiaccess_cb.ListRequest{}, - "/restmachine/cloudbroker/apiaccess/setDefault": apiaccess_cb.SetDefaultRequest{}, - "/restmachine/cloudbroker/apiaccess/subtract": apiaccess_cb.SubtractRequest{}, - "/restmachine/cloudbroker/apiaccess/union": apiaccess_cb.UnionRequest{}, - "/restmachine/cloudbroker/apiaccess/update": apiaccess_cb.UpdateRequest{}, - "/restmachine/cloudbroker/apiaccess/userList": apiaccess_cb.UserListRequest{}, + "/restmachine/cloudbroker/apiaccess/apisExclude": apiaccess_cb.APIsExcludeRequest{}, + "/restmachine/cloudbroker/apiaccess/apiFind": apiaccess_cb.APIFindRequest{}, + "/restmachine/cloudbroker/apiaccess/apisInclude": apiaccess_cb.APIsIncludeRequest{}, + "/restmachine/cloudbroker/apiaccess/copy": apiaccess_cb.CopyRequest{}, + "/restmachine/cloudbroker/apiaccess/create": apiaccess_cb.CreateRequest{}, + "/restmachine/cloudbroker/apiaccess/delete": apiaccess_cb.DeleteRequest{}, + "/restmachine/cloudbroker/apiaccess/descUpdate": apiaccess_cb.DescUpdateRequest{}, + "/restmachine/cloudbroker/apiaccess/get": apiaccess_cb.GetRequest{}, + "/restmachine/cloudbroker/apiaccess/getFull": EmptyStruct{}, + "/restmachine/cloudbroker/apiaccess/list": apiaccess_cb.ListRequest{}, + "/restmachine/cloudbroker/apiaccess/setDefault": apiaccess_cb.SetDefaultRequest{}, + "/restmachine/cloudbroker/apiaccess/subtract": apiaccess_cb.SubtractRequest{}, + "/restmachine/cloudbroker/apiaccess/union": apiaccess_cb.UnionRequest{}, + "/restmachine/cloudbroker/apiaccess/update": apiaccess_cb.UpdateRequest{}, + "/restmachine/cloudbroker/apiaccess/userList": apiaccess_cb.UserListRequest{}, + "/restmachine/cloudbroker/apiaccess/getDefault": EmptyStruct{}, // audit_cb - "/restmachine/cloudbroker/audit/get": audit_cb.GetRequest{}, - "/restmachine/cloudbroker/audit/linkedJobs": audit_cb.LinkedJobsRequest{}, - "/restmachine/cloudbroker/audit/list": audit_cb.ListRequest{}, + "/restmachine/cloudbroker/audit/get": audit_cb.GetRequest{}, + "/restmachine/cloudbroker/audit/linkedJobs": audit_cb.LinkedJobsRequest{}, + "/restmachine/cloudbroker/audit/list": audit_cb.ListRequest{}, + "/restmachine/cloudbroker/audit/exportAuditsToFile": EmptyStruct{}, // backup_cb "/restmachine/cloudbroker/backup/createDiskBackup": backup_cb.CreateDiskBackupRequest{}, @@ -548,6 +575,9 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/compute/userList": compute_cb.UserListRequest{}, "/restmachine/cloudbroker/compute/userRevoke": compute_cb.UserRevokeRequest{}, "/restmachine/cloudbroker/compute/userUpdate": compute_cb.UserUpdateRequest{}, + "/restmachine/cloudbroker/compute/changeIp": compute_cb.ChangeIPRequest{}, + "/restmachine/cloudbroker/compute/changeMac": compute_cb.ChangeMACRequest{}, + "/restmachine/cloudbroker/compute/setNetConfig": compute_cb.SetNetConfigRequest{}, // disks "/restmachine/cloudbroker/disks/create": disks_cb.CreateRequest{}, @@ -570,7 +600,6 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/disks/replicationStatus": disks_cb.ReplicationStatusRequest{}, "/restmachine/cloudbroker/disks/replicationStop": disks_cb.ReplicationStopRequest{}, "/restmachine/cloudbroker/disks/replicationSuspend": disks_cb.ReplicationSuspendRequest{}, - "/restmachine/cloudbroker/disks/resize": disks_cb.ResizeRequest{}, "/restmachine/cloudbroker/disks/resize2": disks_cb.ResizeRequest{}, "/restmachine/cloudbroker/disks/restore": disks_cb.RestoreRequest{}, "/restmachine/cloudbroker/disks/search": disks_cb.SearchRequest{}, @@ -652,6 +681,7 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/grid/setMemAllocationRatio": grid_cb.SetMemAllocationRatioRequest{}, "/restmachine/cloudbroker/grid/setPasswordPolicy": grid_cb.SetPasswordPolicyRequest{}, "/restmachine/cloudbroker/grid/status": EmptyStruct{}, + "/restmachine/cloudbroker/grid/getSettings": grid_cb.GetSettingsRequest{}, // group "/restmachine/cloudbroker/group/get": group_cb.GetRequest{}, @@ -679,6 +709,7 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/image/share": image_cb.ShareRequest{}, "/restmachine/cloudbroker/image/syncCreateImage": image_cb.SyncCreateRequest{}, "/restmachine/cloudbroker/image/updateNodes": image_cb.UpdateNodesRequest{}, + "/restmachine/cloudbroker/image/uploadImageFile": image_cb.UploadImageFileResponse{}, // k8ci "/restmachine/cloudbroker/k8ci/accessAdd": k8ci_cb.AccessAddRequest{}, @@ -768,6 +799,7 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/node/setsriovstatus": node_cb.SetSRIOVStatusRequest{}, "/restmachine/cloudbroker/node/setVFsNumber": node_cb.SetVFsNumberRequest{}, "/restmachine/cloudbroker/node/update": node_cb.UpdateRequest{}, + "/restmachine/cloudbroker/node/setVFsParams": node_cb.VFParam{}, // pcidevice "/restmachine/cloudbroker/pcidevice/create": pcidevice_cb.CreateRequest{}, @@ -776,6 +808,23 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/pcidevice/enable": pcidevice_cb.EnableRequest{}, "/restmachine/cloudbroker/pcidevice/list": pcidevice_cb.ListRequest{}, + // prometheus + "/restmachine/cloudbroker/prometheus/computeTransmitPackets": prometheus_cb.ComputeTransmitPacketsRequest{}, + "/restmachine/cloudbroker/prometheus/computeWriteRequests": prometheus_cb.ComputeWriteRequestsRequest{}, + "/restmachine/cloudbroker/prometheus/computeCPUload": prometheus_cb.ComputeCPULoadRequest{}, + "/restmachine/cloudbroker/prometheus/computeTransmitBytes": prometheus_cb.ComputeTransmitBytesRequest{}, + "/restmachine/cloudbroker/prometheus/computeMemoryUsed": prometheus_cb.ComputeMemoryUsedRequest{}, + "/restmachine/cloudbroker/prometheus/computeMemoryUsable": prometheus_cb.ComputeMemoryUsableRequest{}, + "/restmachine/cloudbroker/prometheus/computeMemoryAvailable": prometheus_cb.ComputeMemoryAvailableRequest{}, + "/restmachine/cloudbroker/prometheus/computeReceiveBytes": prometheus_cb.ComputeReceiveBytesRequest{}, + "/restmachine/cloudbroker/prometheus/computes": prometheus_cb.ComputesRequest{}, + "/restmachine/cloudbroker/prometheus/computeReceivePackets": prometheus_cb.ComputeReceivePacketsRequest{}, + "/restmachine/cloudbroker/prometheus/computeReadRequests": prometheus_cb.ComputeReadRequestsRequest{}, + "/restmachine/cloudbroker/prometheus/computeWriteBytes": prometheus_cb.ComputeWriteBytesRequest{}, + "/restmachine/cloudbroker/prometheus/computeReadBytes": prometheus_cb.ComputeReadBytesRequest{}, + "/restmachine/cloudbroker/prometheus/computeMemoryUsage": prometheus_cb.ComputeMemoryUsageRequest{}, + "/restmachine/cloudbroker/prometheus/computeMemoryUnused": prometheus_cb.ComputeMemoryUnusedRequest{}, + // rg "/restmachine/cloudbroker/rg/accessGrant": rg_cb.AccessGrantRequest{}, "/restmachine/cloudbroker/rg/accessRevoke": rg_cb.AccessRevokeRequest{}, @@ -807,31 +856,35 @@ func getRequestsMapCloudbroker() map[string]interface{} { "/restmachine/cloudbroker/rg/updateComputeFeatures": rg_cb.UpdateComputeFeaturesRequest{}, "/restmachine/cloudbroker/rg/updateResourceTypes": rg_cb.UpdateResourceTypesRequest{}, "/restmachine/cloudbroker/rg/usage": rg_cb.UsageRequest{}, + "/restmachine/cloudbroker/rg/removeDefNet": rg_cb.RemoveDefNetRequest{}, // sep - "/restmachine/cloudbroker/sep/accessGrant": sep_cb.AccessGrantRequest{}, - "/restmachine/cloudbroker/sep/accessGrantToPool": sep_cb.AccessGrantToPoolRequest{}, - "/restmachine/cloudbroker/sep/accessRevoke": sep_cb.AccessRevokeRequest{}, - "/restmachine/cloudbroker/sep/accessRevokeToPool": sep_cb.AccessRevokeToPoolRequest{}, - "/restmachine/cloudbroker/sep/addConsumerNodes": sep_cb.AddConsumerNodesRequest{}, - "/restmachine/cloudbroker/sep/addPool": sep_cb.AddPoolRequest{}, - "/restmachine/cloudbroker/sep/addProviderNodes": sep_cb.AddProviderNodesRequest{}, - "/restmachine/cloudbroker/sep/configFieldEdit": sep_cb.ConfigFieldEditRequest{}, - "/restmachine/cloudbroker/sep/configInsert": sep_cb.ConfigInsertRequest{}, - "/restmachine/cloudbroker/sep/configValidate": sep_cb.ConfigValidateRequest{}, - "/restmachine/cloudbroker/sep/consumption": sep_cb.ConsumptionRequest{}, - "/restmachine/cloudbroker/sep/create": sep_cb.CreateRequest{}, - "/restmachine/cloudbroker/sep/decommission": sep_cb.DecommissionRequest{}, - "/restmachine/cloudbroker/sep/delConsumerNodes": sep_cb.DelConsumerNodesRequest{}, - "/restmachine/cloudbroker/sep/delete": sep_cb.DeleteRequest{}, - "/restmachine/cloudbroker/sep/delPool": sep_cb.DelPoolRequest{}, - "/restmachine/cloudbroker/sep/disable": sep_cb.DisableRequest{}, - "/restmachine/cloudbroker/sep/diskList": sep_cb.DiskListRequest{}, - "/restmachine/cloudbroker/sep/enable": sep_cb.EnableRequest{}, - "/restmachine/cloudbroker/sep/get": sep_cb.GetRequest{}, - "/restmachine/cloudbroker/sep/getConfig": sep_cb.GetConfigRequest{}, - "/restmachine/cloudbroker/sep/getPool": sep_cb.GetPoolRequest{}, - "/restmachine/cloudbroker/sep/list": sep_cb.ListRequest{}, + "/restmachine/cloudbroker/sep/accessGrant": sep_cb.AccessGrantRequest{}, + "/restmachine/cloudbroker/sep/accessGrantToPool": sep_cb.AccessGrantToPoolRequest{}, + "/restmachine/cloudbroker/sep/accessRevoke": sep_cb.AccessRevokeRequest{}, + "/restmachine/cloudbroker/sep/accessRevokeToPool": sep_cb.AccessRevokeToPoolRequest{}, + "/restmachine/cloudbroker/sep/addConsumerNodes": sep_cb.AddConsumerNodesRequest{}, + "/restmachine/cloudbroker/sep/addPool": sep_cb.AddPoolRequest{}, + "/restmachine/cloudbroker/sep/addProviderNodes": sep_cb.AddProviderNodesRequest{}, + "/restmachine/cloudbroker/sep/configFieldEdit": sep_cb.ConfigFieldEditRequest{}, + "/restmachine/cloudbroker/sep/configInsert": sep_cb.ConfigInsertRequest{}, + "/restmachine/cloudbroker/sep/configValidate": sep_cb.ConfigValidateRequest{}, + "/restmachine/cloudbroker/sep/consumption": sep_cb.ConsumptionRequest{}, + "/restmachine/cloudbroker/sep/create": sep_cb.CreateRequest{}, + "/restmachine/cloudbroker/sep/decommission": sep_cb.DecommissionRequest{}, + "/restmachine/cloudbroker/sep/delConsumerNodes": sep_cb.DelConsumerNodesRequest{}, + "/restmachine/cloudbroker/sep/delete": sep_cb.DeleteRequest{}, + "/restmachine/cloudbroker/sep/delPool": sep_cb.DelPoolRequest{}, + "/restmachine/cloudbroker/sep/disable": sep_cb.DisableRequest{}, + "/restmachine/cloudbroker/sep/diskList": sep_cb.DiskListRequest{}, + "/restmachine/cloudbroker/sep/enable": sep_cb.EnableRequest{}, + "/restmachine/cloudbroker/sep/get": sep_cb.GetRequest{}, + "/restmachine/cloudbroker/sep/getConfig": sep_cb.GetConfigRequest{}, + "/restmachine/cloudbroker/sep/getPool": sep_cb.GetPoolRequest{}, + "/restmachine/cloudbroker/sep/list": sep_cb.ListRequest{}, + "/restmachine/cloudbroker/sep/sharedLockStop": sep_cb.SharedLockStopRequest{}, + "/restmachine/cloudbroker/sep/listAvailableSepAndPools": sep_cb.ListAvailableSEPAndPoolsRequest{}, + "/restmachine/cloudbroker/sep/sharedLockStart": sep_cb.SharedLockStartRequest{}, // stack "/restmachine/cloudbroker/stack/get": stack_cb.GetRequest{}, diff --git a/tests/platform_upgrade/utils_log.go b/tests/platform_upgrade/utils_log.go deleted file mode 100644 index 39eeb84..0000000 --- a/tests/platform_upgrade/utils_log.go +++ /dev/null @@ -1,119 +0,0 @@ -package test - -import ( - "bufio" - "encoding/json" - "io" - "os" - "regexp" - "sort" - "strings" - "testing" -) - -func compareLogs(logFileName string, logsData []string, t *testing.T, testType string) { - if _, err := os.Stat(logFileName); os.IsNotExist(err) { - file, err := os.Create(logFileName) - if err != nil { - t.Errorf("Failed to create log file: %v", err) - } - defer file.Close() - - writer := bufio.NewWriter(file) - - jsonData, err := json.MarshalIndent(logsData, "", " ") - if err != nil { - t.Errorf("Failed to marshal logsData to JSON: %v", err) - } - - _, err = writer.WriteString(string(jsonData)) - if err != nil { - t.Errorf("Failed to write JSON to log file: %v", err) - } - - writer.Flush() - } else { - file, err := os.Open(logFileName) - if err != nil { - t.Errorf("Failed to open log file: %v", err) - } - defer file.Close() - - reader := bufio.NewReader(file) - var sb strings.Builder - for { - line, err := reader.ReadString('\n') - if err != nil { - if err == io.EOF { - sb.WriteString(strings.TrimSpace(line)) - break - } - t.Errorf("Error reading log file: %v", err) - return - } - sb.WriteString(strings.TrimSpace(line)) - } - - var fileContent = sb.String() - - var fileLogsData []string - err = json.Unmarshal([]byte(fileContent), &fileLogsData) - if err != nil { - t.Errorf("Failed to unmarshal JSON from log file: %v", err) - } - - if len(fileLogsData) != len(logsData) { - t.Errorf("Log data length does not match. Got: %d, Expected: %d", len(fileLogsData), len(logsData)) - } - - var allLinesMatch = true - - switch testType { - default: - for i := range logsData { - if sortBracketsContent(fileLogsData[i]) != sortBracketsContent(logsData[i]) { - allLinesMatch = false - t.Errorf("Line %d does not match. Got: %s, Expected: %s", i+1, sortBracketsContent(fileLogsData[i]), sortBracketsContent(logsData[i])) - } - } - if allLinesMatch { - t.Log("\nAll lines match the log file.") - } - case "request": - var tmp = make(map[string]struct{}) - for _, v := range fileLogsData { - if _, ok := tmp[v]; ok { - delete(tmp, v) - } else { - tmp[v] = struct{}{} - } - - } - for _, v := range logsData { - if _, ok := tmp[v]; ok { - delete(tmp, v) - } else { - tmp[v] = struct{}{} - } - - } - if len(tmp) == 0 { - t.Log("\nAll lines match the log file.") - return - } - for i := range tmp { - t.Errorf("Line %s does not match.", i) - } - } - } -} - -func sortBracketsContent(log string) string { - re := regexp.MustCompile(`\[([^\[\]]*)\]`) - return re.ReplaceAllStringFunc(log, func(match string) string { - content := match[1 : len(match)-1] - parts := strings.Split(content, " ") - sort.Strings(parts) - return "[" + strings.Join(parts, " ") + "]" - }) -} diff --git a/tests/platform_upgrade/utils_requests.go b/tests/platform_upgrade/utils_requests.go index 510e435..5545620 100644 --- a/tests/platform_upgrade/utils_requests.go +++ b/tests/platform_upgrade/utils_requests.go @@ -51,15 +51,12 @@ func getBytesFromJSON(fileName string, t *testing.T) []byte { func getErrorsFromJSON(bytes []byte, t *testing.T, cloud string) { var requests map[string]interface{} - var logFileName string switch cloud { case "cloudapi": requests = getRequestsMapCloudAPI() - logFileName = "test_requests_cloudAPI.log" case "cloudbroker": requests = getRequestsMapCloudbroker() - logFileName = "test_requests_cloudbroker.log" default: t.Fatalf("Wrong cloud provided, expected `cloudapi` or `cloudbroker`, got %s", cloud) } @@ -151,7 +148,6 @@ func getErrorsFromJSON(bytes []byte, t *testing.T, cloud string) { t.Error(msg) dataLogs = append(dataLogs, msg) } - compareLogs(logFileName, dataLogs, t, "request") } // checkName checks if name field from platform has the same value as json tag in golang structure (maybe including omitempty) diff --git a/tests/platform_upgrade/utils_urls.go b/tests/platform_upgrade/utils_urls.go index 17943a2..9a7f953 100644 --- a/tests/platform_upgrade/utils_urls.go +++ b/tests/platform_upgrade/utils_urls.go @@ -11,7 +11,6 @@ import ( var DEPRECATED_GROUPS = []string{ "/cloudapi/machine/", "/cloudapi/cloudspace/", - "/cloudapi/prometheus/", "//cloudbroker/pgpu/", "/cloudapi/gpu/", "/cloudapi/portforwarding/", @@ -28,7 +27,6 @@ var DEPRECATED_GROUPS = []string{ "/cloudbroker/account/listCS", "/cloudbroker/machine/", "/cloudbroker/bservice/", - "/cloudbroker/prometheus/", "/cloudbroker/auditcollector/", "/cloudbroker/health/", "/cloudbroker/metering/",