diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cfa517..4a34d5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## Version 1.15.1 +## Version 1.15.2 Методы `Audits` в cloudapi/compute, cloudbroker/compute, cloudapi/account, cloudbroker/account, cloudapi/vins, cloudbroker/vins, cloudapi/rg и cloudbroker/rg стали deprecated и в следующих версиях будут удалены, вместо них необходимо использовать метод `List` в cloudapi/audit и cloudbroker/audit с соответствующими фильтрами Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и в следующих версиях будут удалены @@ -7,52 +7,35 @@ Все методы группы `.SDN()` находятся в альфа-версии. + ### Добавлено -#### Общее +#### image | Идентификатор задачи | Описание | | --- | --- | -| BGOS-899 | Добавлена валидация полей `ssoUrl` и `decortUrl` в конфигах `Config`, `BVSConfig` и `LegacyConfig`, а также поля `domain` в конфиге `BVSConfig` при вызове конструкторов `New`, `NewBVS`, `NewLegacy` | - -#### kvmx86 -| Идентификатор задачи | Описание | -| --- | --- | -| BGOS-903 | Структура ответа `MassCreateError` в cloudbroker/kvmx86 | +| BGOS-916 | Вычисляемые поля `Compute` и `MemoryDumpImage` в структуру ответа `ItemSnapSet` в cloudapi/image | #### node | Идентификатор задачи | Описание | | --- | --- | -| BGOS-906 | Метод `Install` и структура запроса `InstallRequest` в cloudbroker/node | +| BGOS-919 | Вычисляемое поле `MaxSupportedGeneration` в структуру ответа `CpuInfo` в cloudbroker/node | #### zone | Идентификатор задачи | Описание | | --- | --- | -| BGOS-902 | Вычисляемое поле `SupportedCpuModels` в структуру ответа `TestCPUAlignmentProfileResult` в cloudbroker/zone | -| BGOS-902 | Структура ответа `SupportedCpuModel` в cloudbroker/zone | +| BGOS-914 | Вычисляемые поля `ID`, `Name` и `ConsumedBy` в структуру ответа `RecordConsumption` в cloudbroker/sep | +| BGOS-914 | Структура ответа `ListConsumption` в cloudbroker/sep | + ### Изменено -#### compute +#### account | Идентификатор задачи | Описание | | --- | --- | -| BGOS-905 | Тип полей `Login` и `Password` с опциональных на обязательные в структуре `OSUser` в cloudbroker/compute | +| BGOS-918 | Тип обязательного поля `Ratio` с `float64` на `uint64` в структуре запроса `SetCPUAllocationRatioRequest` в cloudbroker/account | -#### zone -| Идентификатор
задачи | Описание | -| --- | --- | -| BGOS-902 | Тип поля `Percentage` с `uint64` на `float64` в структуре ответа `CpuAlignmentProfileCandidate` в cloudbroker/zone | - -#### SDN logicalports +#### SEP | Идентификатор задачи | Описание | | --- | --- | -| BGOS-907 | Тип поля `MAC` с опционального на обязательное в структуре `AddAddress` в sdn/logicalports | - - -### Удалено - -#### compute -| Идентификатор задачи | Описание | -| --- | --- | -| BGOS-904 | Опциональное поле `Force` из структуры запроса `MigrateRequest` в cloudbroker/compute | - - +| BGOS-914 | Тип поля `SEPID` с обязательного на опциональный в структуре запроса `ConsumptionRequest` в cloudbroker/sep | +| BGOS-914 | Тип ответа метода `Consumption` с `RecordConsumption` на `ListConsumption` в cloudbroker/sep | diff --git a/pkg/cloudapi/compute/models.go b/pkg/cloudapi/compute/models.go index 4bd21b9..656e137 100644 --- a/pkg/cloudapi/compute/models.go +++ b/pkg/cloudapi/compute/models.go @@ -86,7 +86,7 @@ type ItemSnapshot struct { // Compute info Compute RecordCompute `json:"compute"` - // List disk ID + // List of disk IDs Disks []uint64 `json:"disks"` // GUID @@ -690,7 +690,10 @@ type ListOSUser []ItemOSUser // Main information about snapsets type ItemSnapSet struct { - // List disk IDs + // Compute info + Compute RecordCompute `json:"compute"` + + // List disk ID Disks []uint64 `json:"disks"` // GUID @@ -699,6 +702,9 @@ type ItemSnapSet struct { // Label Label string `json:"label"` + // Memory dump image ID + MemoryDumpImage uint64 `json:"memory_dump_image"` + // Timestamp Timestamp uint64 `json:"timestamp"` } diff --git a/pkg/cloudapi/image/list.go b/pkg/cloudapi/image/list.go index f466b81..c316d8d 100644 --- a/pkg/cloudapi/image/list.go +++ b/pkg/cloudapi/image/list.go @@ -5,6 +5,7 @@ import ( "encoding/json" "net/http" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" ) @@ -102,6 +103,6 @@ func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { url := "/cloudapi/image/list" - res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) return res, err } diff --git a/pkg/cloudbroker/account/set_cpu_allocation_ratio.go b/pkg/cloudbroker/account/set_cpu_allocation_ratio.go index 7bb42f6..8948f58 100644 --- a/pkg/cloudbroker/account/set_cpu_allocation_ratio.go +++ b/pkg/cloudbroker/account/set_cpu_allocation_ratio.go @@ -16,7 +16,7 @@ type SetCPUAllocationRatioRequest struct { // CPU allocation ratio, i.e. one pCPU = ratio*vCPU // Required: true - Ratio float64 `url:"ratio" json:"ratio" validate:"required"` + Ratio uint64 `url:"ratio" json:"ratio" validate:"required"` } // SetCPUAllocationRatio sets CPU allocation ratio diff --git a/pkg/cloudbroker/image/list.go b/pkg/cloudbroker/image/list.go index 830279b..0f619de 100644 --- a/pkg/cloudbroker/image/list.go +++ b/pkg/cloudbroker/image/list.go @@ -5,6 +5,7 @@ import ( "encoding/json" "net/http" + "repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" ) @@ -102,6 +103,6 @@ func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { url := "/cloudbroker/image/list" - res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req) + res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) return res, err } diff --git a/pkg/cloudbroker/node/models.go b/pkg/cloudbroker/node/models.go index e35e502..51901d6 100644 --- a/pkg/cloudbroker/node/models.go +++ b/pkg/cloudbroker/node/models.go @@ -161,8 +161,11 @@ type CpuInfo struct { // Flags Flags []string `json:"flags"` - // Mddel name + // Model name ModelName string `json:"model_name"` + + // Max supported generation + MaxSupportedGeneration string `json:"max_supported_generation"` } // Main information about node diff --git a/pkg/cloudbroker/sep/consumption.go b/pkg/cloudbroker/sep/consumption.go index 8963d21..3356ed1 100644 --- a/pkg/cloudbroker/sep/consumption.go +++ b/pkg/cloudbroker/sep/consumption.go @@ -11,12 +11,12 @@ import ( // ConsumptionRequest struct to get consumption info type ConsumptionRequest struct { // Storage endpoint provider ID - // Required: true - SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"` + // Required: false + SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"` } // Consumption gets SEP consumption info -func (s SEP) Consumption(ctx context.Context, req ConsumptionRequest) (*RecordConsumption, error) { +func (s SEP) Consumption(ctx context.Context, req ConsumptionRequest) (*ListConsumption, error) { err := validators.ValidateRequest(req) if err != nil { return nil, validators.ValidationErrors(validators.GetErrors(err)) @@ -29,7 +29,7 @@ func (s SEP) Consumption(ctx context.Context, req ConsumptionRequest) (*RecordCo return nil, err } - info := RecordConsumption{} + info := ListConsumption{} err = json.Unmarshal(res, &info) if err != nil { diff --git a/pkg/cloudbroker/sep/models.go b/pkg/cloudbroker/sep/models.go index 936f7c0..4127214 100644 --- a/pkg/cloudbroker/sep/models.go +++ b/pkg/cloudbroker/sep/models.go @@ -47,8 +47,22 @@ type ByPool struct { UsageLimit uint64 `json:"usage_limit"` } +// List of Resource groups +type ListConsumption struct { + // Data + Data []RecordConsumption `json:"data"` + + // Enrtry count + EntryCount uint64 `json:"entryCount"` +} + // Main information about consumption type RecordConsumption struct { + // ID + ID uint64 `json:"id"` + + // Name + Name string `json:"name"` // By pool ByPool map[string]ByPool `json:"byPool"` @@ -57,6 +71,9 @@ type RecordConsumption struct { // Type Type string `json:"type"` + + // Consumed by + ConsumedBy []uint64 `json:"consumedBy"` } // Main information about URI diff --git a/tests/platform_upgrade/cloud_test.go b/tests/platform_upgrade/cloud_test.go index 0c7b8f9..a643b03 100644 --- a/tests/platform_upgrade/cloud_test.go +++ b/tests/platform_upgrade/cloud_test.go @@ -711,7 +711,7 @@ func TestGetListCloudbroker(t *testing.T) { getResult("Node list", bytes, node_cb.ListNodes{}, t) // Get listNode, _ := client.CloudBroker().Node().List(context.Background(), node_cb.ListRequest{}) - if len(listLB.Data) > 0 { + if listNode != nil && len(listNode.Data) > 0 { id := listNode.Data[0].ID bytes, err = client.CloudBroker().Node().GetRaw(context.Background(), node_cb.GetRequest{NID: id}) if err != nil { @@ -725,11 +725,11 @@ func TestGetListCloudbroker(t *testing.T) { } getResult("Node get_network_info", bytes, node_cb.RecordNodeNetworkInfo{}, t) } else { - t.Errorf("Can not test Node get because LB list is empty") + t.Errorf("Can not test Node get because node list is empty") } // Node GetPCIDevices - if len(listNode.Data) > 0 { + if listNode != nil && len(listNode.Data) > 0 { id := listNode.Data[0].ID bytes, err = client.CloudBroker().Node().GetPCIDevicesRaw(context.Background(), node_cb.GetPCIDevicesRequest{NodeID: id}) if err != nil { diff --git a/tests/platform_upgrade/utils_get_list.go b/tests/platform_upgrade/utils_get_list.go index 82a1694..f57835c 100644 --- a/tests/platform_upgrade/utils_get_list.go +++ b/tests/platform_upgrade/utils_get_list.go @@ -183,6 +183,9 @@ func GetMapFromBytes(bytes []byte) (map[string]interface{}, error) { if err != nil { return nil, err } + if len(unmarshalSlice) == 0 { + return map[string]interface{}{}, nil + } t, ok := unmarshalSlice[0].(map[string]interface{}) if !ok { return nil, err @@ -228,10 +231,20 @@ func getMapBytes(value map[string]interface{}) map[string]interface{} { func GetMapFromStructure(structure any) map[string]interface{} { typ := reflect.TypeOf(structure) - return getMapStruct(typ) + for typ.Kind() == reflect.Slice || typ.Kind() == reflect.Ptr { + typ = typ.Elem() + } + + return getMapStruct(typ, make(map[reflect.Type]bool)) } -func getMapStruct(t reflect.Type) map[string]interface{} { +func getMapStruct(t reflect.Type, visited map[reflect.Type]bool) map[string]interface{} { + if visited[t] { + return map[string]interface{}{} + } + visited[t] = true + defer func() { visited[t] = false }() + temporary := make(map[string]interface{}) for i := 0; i < t.NumField(); i++ { tag := t.Field(i).Tag.Get("json") @@ -243,16 +256,16 @@ func getMapStruct(t reflect.Type) map[string]interface{} { elem := t.Field(i).Type.Elem() switch elem.Kind() { case reflect.Struct: - temporary[tag] = getMapStruct(elem) + temporary[tag] = getMapStruct(elem, visited) default: temporary[tag] = map[string]interface{}{} } case reflect.Struct: if tag == "" { - return getMapStruct(t.Field(i).Type) + return getMapStruct(t.Field(i).Type, visited) } else { - temporary[tag] = getMapStruct(t.Field(i).Type) + temporary[tag] = getMapStruct(t.Field(i).Type, visited) } // в этом месте работает некорректно для вложенных структур без json тегов (scope - все в cloudbroker)