From db594a9d81400fbf300103fc5e0ba1e5c15f751f Mon Sep 17 00:00:00 2001 From: Arseniy Volkov Date: Fri, 26 Jun 2026 16:56:08 +0400 Subject: [PATCH] v15.3.0 --- CHANGELOG.md | 73 +++-- pkg/cloudapi/compute/boot_order_get.go | 1 + pkg/cloudapi/compute/boot_order_set.go | 1 + pkg/cloudapi/compute/models.go | 269 +++++++++++++++++- pkg/cloudapi/compute/net_attach.go | 5 + pkg/cloudapi/kvmx86/create.go | 5 + pkg/cloudapi/pcidevice/serialize.go | 1 + pkg/cloudapi/vins/create_in_account.go | 34 +-- pkg/cloudapi/vins/create_in_rg.go | 34 +-- pkg/cloudapi/vins/models.go | 3 + pkg/cloudapi/zone/models.go | 12 + .../account/set_cpu_allocation_parameter.go | 3 +- pkg/cloudbroker/compute/models.go | 6 + pkg/cloudbroker/compute/net_attach.go | 5 + pkg/cloudbroker/disks/depresent.go | 3 +- pkg/cloudbroker/disks/models.go | 3 + pkg/cloudbroker/disks/present.go | 3 +- .../grid/set_cpu_allocation_parameter.go | 3 +- .../grid/set_cpu_allocation_ratio_for_vm.go | 3 +- pkg/cloudbroker/grid/set_resources_limit.go | 44 +++ pkg/cloudbroker/kvmx86/create.go | 5 + pkg/cloudbroker/kvmx86/mass_create.go | 5 + pkg/cloudbroker/node/models.go | 12 + pkg/cloudbroker/node/set_resources_limit.go | 42 +++ pkg/cloudbroker/pcidevice/delete.go | 3 +- pkg/cloudbroker/pcidevice/disable.go | 3 +- pkg/cloudbroker/pcidevice/enable.go | 3 +- pkg/cloudbroker/pcidevice/serialize.go | 1 + .../rg/set_cpu_allocation_parameter.go | 3 +- .../rg/set_cpu_allocation_ratio.go | 3 +- pkg/cloudbroker/vgpu/allocate.go | 3 +- pkg/cloudbroker/vgpu/create.go | 3 +- pkg/cloudbroker/vgpu/deallocate.go | 3 +- pkg/cloudbroker/vgpu/destroy.go | 3 +- pkg/cloudbroker/vins/create_in_account.go | 34 +-- pkg/cloudbroker/vins/create_in_rg.go | 33 +-- pkg/cloudbroker/vins/models.go | 6 + pkg/cloudbroker/vins/update.go | 4 + pkg/cloudbroker/zone/models.go | 12 + pkg/cloudbroker/zone/set_resources_limit.go | 42 +++ .../zone/update_cpu_alignment_profile.go | 46 +++ samples/client/client.go | 1 - 42 files changed, 629 insertions(+), 152 deletions(-) create mode 100644 pkg/cloudbroker/grid/set_resources_limit.go create mode 100644 pkg/cloudbroker/node/set_resources_limit.go create mode 100644 pkg/cloudbroker/zone/set_resources_limit.go create mode 100644 pkg/cloudbroker/zone/update_cpu_alignment_profile.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 56f0af7..cdc636e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,41 +1,64 @@ -## Version 15.2.0 +## Version 15.3.0 -Методы `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 и в следующих версиях будут удалены -Методы `ComputeCISet`, `ComputeCIUnset`, `GetAudits` в cloudbroker/compute и `GetAudits` в cloudapi/compute стали deprecated и будут удалены в следующих версиях -Методы `ComputeCISet`, `ComputeCIUnset` в cloudbroker/image стали deprecated и будут удалены в следующих версиях +Методы `Audits` в cloudapi/compute, cloudbroker/compute, cloudapi/account, cloudbroker/account, cloudapi/vins, cloudbroker/vins, cloudapi/rg и cloudbroker/rg стали deprecated и будут удалены в версии 16.0, вместо них необходимо использовать метод `List` в cloudapi/audit и cloudbroker/audit с соответствующими фильтрами +Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и будут удалены в версии 16.0 +Методы `ComputeCISet`, `ComputeCIUnset`, `GetAudits` в cloudbroker/compute и `GetAudits` в cloudapi/compute стали deprecated и будут удалены в версии 16.0 +Методы `ComputeCISet`, `ComputeCIUnset` в cloudbroker/image стали deprecated и будут удалены в версии 16.0 +Методы `Delete`, `Disable`, `Enable`, `GetConsumedCloudUnitsByType`, `GetReservedAccountUnits` в cloudapi/account стали deprecated и будут удалены в версии 16.0 +Методы `Disable`, `Enable` в cloudbroker/account стали deprecated и будут удалены в версии 16.0 +Метод `IsValidInviteUserToken` в cloudapi/user стал deprecated и будет удален в версии 16.0 +Метод `GetLog` в cloudbroker/compute стал deprecated и будет удален в версии 16.0 +Методы `ExecuteMaintenanceScript`, `ListEmails`, `ServicesRestart` в cloudbroker/grid стали deprecated и будут удалены в версии 16.0 +Метод `Get` в cloudbroker/group стал deprecated и будет удален в версии 16.0 Все методы группы `.SDN()` находятся в альфа-версии. ### Добавлено -#### image +#### compute | Идентификатор задачи | Описание | | --- | --- | -| BGOS-916 | Вычисляемые поля `Compute` и `MemoryDumpImage` в структуру ответа `ItemSnapSet` в cloudapi/image | +| BGOS-922 | Опциональное поле `EnableDefaultGateway` в структуру запроса `NetAttachRequest` в cloudapi/compute и cloudbroker/compute | +| BGOS-922 | Вычисляемое поле `EnableDefaultGateway` в структуру ответа `RecordNetAttach` в cloudapi/compute и cloudbroker/compute | +| BGOS-922 | Вычисляемое поле `EnableDefaultGateway` в структуру ответа `ItemInterface` в cloudbroker/compute | +| BGOS-922 | Вычисляемое поле `EnableDefaultGateway` в структуру ответа `ItemVNFInterface` в cloudapi/compute | +| BGOS-931 | Структура ответа `SnapRecordCompute` в cloudapi/compute | +| BGOS-936 | Вычисляемое поле `NodeID` в структуры ответа `RecordCompute` и `ItemCompute` в cloudapi/compute | -#### node +#### disks | Идентификатор задачи | Описание | | --- | --- | -| BGOS-919 | Вычисляемое поле `MaxSupportedGeneration` в структуру ответа `CpuInfo` в cloudbroker/node | +| BGOS-924 | Вычисляемое поле `Ready` в структуру ответа `MigrateStatus` в cloudbroker/disks | + +#### grid +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-926 | Метод `SetResourcesLimit` и структура запроса `SetResourcesLimitRequest` в cloudbroker/grid | + +#### kvmx86 +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-937 | Опциональное поле `EnableDefaultGateway` в структуру `Interface` в cloudapi/kvmx86 и cloudbroker/kvmx86 | +| BGOS-937 | Опциональное поле `EnableDefaultGateway` в структуру `InterfaceMassCreate` в cloudbroker/kvmx86 | + +#### node +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-927 | Вычисляемые поля `ReservedCPU` и `ReservedRAM` в структуры ответа `ItemNode` и `RecordNode` в cloudbroker/node | +| BGOS-928 | Метод `SetResourcesLimit` и структура запроса `SetResourcesLimitRequest` в cloudbroker/node | + +#### vins +| Идентификатор задачи | Описание | +| --- | --- | +| BGOS-923 | Опциональное поле `EnableDefaultGateway` в структуры запросов `CreateInAccountRequest` и `CreateInRGRequest` в cloudapi/vins и cloudbroker/vins | +| BGOS-923 | Опциональное поле `EnableDefaultGateway` в структуру запроса `UpdateRequest` в cloudbroker/vins | +| BGOS-923 | Вычисляемое поле `EnableDefaultGateway` в структуру ответа `RecordVINS` в cloudapi/vins и cloudbroker/vins | +| BGOS-923 | Вычисляемое поле `EnableDefaultGateway` в структуру ответа `ItemVINS` в cloudbroker/vins | #### zone | Идентификатор задачи | Описание | | --- | --- | -| BGOS-914 | Вычисляемые поля `ID`, `Name` и `ConsumedBy` в структуру ответа `RecordConsumption` в cloudbroker/sep | -| BGOS-914 | Структура ответа `ListConsumption` в cloudbroker/sep | - - -### Изменено - -#### account -| Идентификатор задачи | Описание | -| --- | --- | -| BGOS-918 | Тип обязательного поля `Ratio` с `float64` на `uint64` в структуре запроса `SetCPUAllocationRatioRequest` в cloudbroker/account | - -#### SEP -| Идентификатор задачи | Описание | -| --- | --- | -| BGOS-914 | Тип поля `SEPID` с обязательного на опциональный в структуре запроса `ConsumptionRequest` в cloudbroker/sep | -| BGOS-914 | Тип ответа метода `Consumption` с `RecordConsumption` на `ListConsumption` в cloudbroker/sep | +| BGOS-929 | Вычисляемые поля `ReservedCPU` и `ReservedRAM` в структуры ответа `RecordZone` и `ItemZone` в cloudapi/zone и в cloudbroker/zone | +| BGOS-930 | Метод `SetResourcesLimit` и структура запроса `SetResourcesLimitRequest` в cloudbroker/zone | +| BGOS-930 | Метод `UpdateCPUAlignmentProfile` и структура запроса `UpdateCPUAlignmentProfileRequest` в cloudbroker/zone | diff --git a/pkg/cloudapi/compute/boot_order_get.go b/pkg/cloudapi/compute/boot_order_get.go index 6bfb9a7..d7d060c 100644 --- a/pkg/cloudapi/compute/boot_order_get.go +++ b/pkg/cloudapi/compute/boot_order_get.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "net/http" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) diff --git a/pkg/cloudapi/compute/boot_order_set.go b/pkg/cloudapi/compute/boot_order_set.go index bae4bba..38fd93b 100644 --- a/pkg/cloudapi/compute/boot_order_set.go +++ b/pkg/cloudapi/compute/boot_order_set.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "net/http" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) diff --git a/pkg/cloudapi/compute/models.go b/pkg/cloudapi/compute/models.go index 656e137..25e16f3 100644 --- a/pkg/cloudapi/compute/models.go +++ b/pkg/cloudapi/compute/models.go @@ -182,6 +182,9 @@ type RecordNetAttach struct { // Enabled Enabled bool `json:"enabled"` + // Enable default gateway + EnableDefaultGateway bool `json:"enable_default_gateway"` + // Enable security groups EnableSecGroups bool `json:"enable_secgroups"` @@ -479,6 +482,9 @@ type RecordCompute struct { // Natable VINS network name NatableVINSNetworkName string `json:"natableVinsNetworkName"` + // Node ID + NodeID uint64 `json:"node_id"` + // Name of OS OSVersion string `json:"os_version"` @@ -565,6 +571,261 @@ type RecordCompute struct { ZoneID uint64 `json:"zoneId"` } +type SnapRecordCompute struct { + // Access Control List + ACL ListACL `json:"acl"` + + // Account ID + AccountID uint64 `json:"accountId"` + + // Account name + AccountName string `json:"accountName"` + + // Affinity label + AffinityLabel string `json:"affinityLabel"` + + // List affinity rules + AffinityRules ListRules `json:"affinityRules"` + + // Affinity weight + AffinityWeight uint64 `json:"affinityWeight"` + + // List anti affinity rules + AntiAffinityRules ListRules `json:"antiAffinityRules"` + + // Auto start when node restarted + AutoStart bool `json:"autoStart"` + + // Architecture + Architecture string `json:"arch"` + + // Boot image ID + BootImageID uint64 `json:"boot_image_id"` + + // Boot order + BootOrder []string `json:"bootOrder"` + + // Boot type + BootType string `json:"bootType"` + + // Boot disk size + BootDiskSize uint64 `json:"bootdiskSize"` + + // CD Image Id + CdImageId uint64 `json:"cdImageId"` + + // Chipset + Chipset string `json:"chipset"` + + // Clone reference + CloneReference uint64 `json:"cloneReference"` + + // List clone IDs + Clones []uint64 `json:"clones"` + + // Clock + Clock string `json:"clock"` + + // Compute CI ID + ComputeCIID uint64 `json:"computeciId"` + + // CPU Pin + CPUPin bool `json:"cpupin"` + + // Number of cores + CPU uint64 `json:"cpus"` + + // Created by + CreatedBy string `json:"createdBy"` + + // Created time + CreatedTime uint64 `json:"createdTime"` + + // Custom fields items + CustomFields map[string]interface{} `json:"customFields"` + + // Deleted by + DeletedBy string `json:"deletedBy"` + + // Deleted time + DeletedTime uint64 `json:"deletedTime"` + + // Description + Description string `json:"desc"` + + // Devices + Devices interface{} `json:"devices"` + + // List disks in compute + Disks ListComputeDisks `json:"disks"` + + // Driver + Driver string `json:"driver"` + + // Grid ID + GID uint64 `json:"gid"` + + // GUID + GUID uint64 `json:"guid"` + + // HPBacked + HPBacked bool `json:"hpBacked"` + + // Hot resize + HotResize bool `json:"hotResize"` + + // ID + ID uint64 `json:"id"` + + // Image ID + ImageID uint64 `json:"imageId"` + + // Image name + ImageName string `json:"imageName"` + + // List interfaces + Interfaces ListInterfaces `json:"interfaces"` + + // Loader meta iso information + LoaderMetaIso LoaderMetaIso `json:"loaderMetaIso"` + + // Live migration job ID + LiveMigrationJobID uint64 `json:"live_migration_job_id"` + + // Loader type + LoaderType string `json:"loaderType"` + + // Lock status + LockStatus string `json:"lockStatus"` + + // Manager ID + ManagerID uint64 `json:"managerId"` + + // Manager type + ManagerType string `json:"managerType"` + + // Migration job + MigrationJob uint64 `json:"migrationjob"` + + // Milestones + Milestones uint64 `json:"milestones"` + + // Name + Name string `json:"name"` + + // NeedReboot + NeedReboot bool `json:"needReboot"` + + // Network interface naming + NetworkInterfaceNaming string `json:"networkInterfaceNaming"` + + // Numa Affinity + NumaAffinity string `json:"numaAffinity"` + + //NumaNodeId + NumaNodeId int64 `json:"numaNodeId"` + + // Natable VINS ID + NatableVINSID uint64 `json:"natableVinsId"` + + // Natable VINS IP + NatableVINSIP string `json:"natableVinsIp"` + + // Natable VINS Name + NatableVINSName string `json:"natableVinsName"` + + // Natable VINS network + NatableVINSNetwork string `json:"natableVinsNetwork"` + + // Natable VINS network name + NatableVINSNetworkName string `json:"natableVinsNetworkName"` + + // Name of OS + OSVersion string `json:"os_version"` + + // List OS Users + OSUsers ListOSUser `json:"osUsers"` + + // Pinned to node + PinnedToNode int64 `json:"pinnedToNode"` + + // PreferredCPU + PreferredCPU []int64 `json:"preferredCpu"` + + // CPU alignment profile + CPUAlignmentProfile CPUAlignmentProfile `json:"cpu_alignment_profile"` + + // Qemu_quest + QemuQuest QemuQuest `json:"qemu_guest"` + + // ReadOnly indicates read-only mode state + ReadOnly bool `json:"read_only"` + + // Number of RAM + RAM uint64 `json:"ram"` + + // Reference ID + ReferenceID string `json:"referenceId"` + + // Registered or not + Registered bool `json:"registered"` + + // Resource name + ResName string `json:"resName"` + + // Reserved Node Cpus + ReservedNodeCpus []uint64 `json:"reservedNodeCpus"` + + // Resource group ID + RGID uint64 `json:"rgId"` + + // Resource group name + RGName string `json:"rgName"` + + // List snapsets + SnapSets ListSnapSets `json:"snapSets"` + + // Stateless SepID + StatelessSepID int64 `json:"statelessSepId"` + + // Stateless SepType + StatelessSepType string `json:"statelessSepType"` + + // Status + Status string `json:"status"` + + // Tags + Tags map[string]string `json:"tags"` + + // Tech status + TechStatus string `json:"techStatus"` + + // Updated by + UpdatedBy string `json:"updatedBy"` + + // Updated time + UpdatedTime uint64 `json:"updatedTime"` + + // User Managed or not + UserManaged bool `json:"userManaged"` + + // Userdata + Userdata interface{} `json:"userdata"` + + // vGPUs list + VGPUs []VGPUItem `json:"vgpus"` + + // VNC password + VNCPassword string `json:"vncPasswd"` + + // Weight + Weight uint64 `json:"weight"` + + // Zone ID + // Required: false + ZoneID uint64 `json:"zoneId"` +} + type LoaderMetaIso struct { // Name DeviceName string `json:"devicename"` @@ -691,7 +952,7 @@ type ListOSUser []ItemOSUser // Main information about snapsets type ItemSnapSet struct { // Compute info - Compute RecordCompute `json:"compute"` + Compute SnapRecordCompute `json:"compute"` // List disk ID Disks []uint64 `json:"disks"` @@ -729,6 +990,9 @@ type ItemVNFInterface struct { // Enabled Enabled bool `json:"enabled"` + // Enable default gateway + EnableDefaultGateway bool `json:"enable_default_gateway"` + // Enable security groups EnableSecGroups bool `json:"enable_secgroups"` @@ -1191,6 +1455,9 @@ type ItemCompute struct { // Name Name string `json:"name"` + // Node ID + NodeID uint64 `json:"node_id"` + // NeedReboot NeedReboot bool `json:"needReboot"` diff --git a/pkg/cloudapi/compute/net_attach.go b/pkg/cloudapi/compute/net_attach.go index 8b3d680..b9d0cd0 100644 --- a/pkg/cloudapi/compute/net_attach.go +++ b/pkg/cloudapi/compute/net_attach.go @@ -81,6 +81,11 @@ type NetAttachRequest struct { // Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK) // Required: false Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"` + + // Flag indicating whether default gateway is enabled for this interface + // Required: false + // Default: true + EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` } type wrapperNetAttachRequest struct { diff --git a/pkg/cloudapi/kvmx86/create.go b/pkg/cloudapi/kvmx86/create.go index e6c373d..93ccbc0 100644 --- a/pkg/cloudapi/kvmx86/create.go +++ b/pkg/cloudapi/kvmx86/create.go @@ -76,6 +76,11 @@ type Interface struct { // Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK) // Required: false Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"` + + // Flag indicating whether default gateway are enabled for this interface, not applicable to netType EXTNET, VFNIC, TRUNK, or SDN + // Default: true + // Required: false + EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` } // DataDisk detailed struct for DataDisks field in CreateRequest and CreateBlankRequest diff --git a/pkg/cloudapi/pcidevice/serialize.go b/pkg/cloudapi/pcidevice/serialize.go index 46fcb09..062bd2e 100644 --- a/pkg/cloudapi/pcidevice/serialize.go +++ b/pkg/cloudapi/pcidevice/serialize.go @@ -2,6 +2,7 @@ package pcidevice import ( "encoding/json" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/serialization" ) diff --git a/pkg/cloudapi/vins/create_in_account.go b/pkg/cloudapi/vins/create_in_account.go index 6efd32e..4fc10fd 100644 --- a/pkg/cloudapi/vins/create_in_account.go +++ b/pkg/cloudapi/vins/create_in_account.go @@ -2,10 +2,10 @@ package vins import ( "context" - "encoding/json" "net/http" "strconv" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants" "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) @@ -62,11 +62,11 @@ type CreateInAccountRequest struct { // Required: false // Default: false EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"` -} -type wrapperCreateRequestInAcc struct { - CreateInAccountRequest - Routes []string `url:"routes,omitempty"` + // Flag indicating whether default gateway is enabled for this VINS + // Required: false + // Default: true + EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` } // CreateInAccount creates VINS in account level @@ -76,31 +76,9 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) ( return 0, validators.ValidationErrors(validators.GetErrors(err)) } - var routes []string - - if len(req.Routes) != 0 { - routes = make([]string, 0, len(req.Routes)) - - for r := range req.Routes { - b, err := json.Marshal(req.Routes[r]) - if err != nil { - return 0, err - } - - routes = append(routes, string(b)) - } - } else { - routes = []string{} - } - - reqWrapped := wrapperCreateRequestInAcc{ - CreateInAccountRequest: req, - Routes: routes, - } - url := "/cloudapi/vins/createInAccount" - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) + res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { return 0, err } diff --git a/pkg/cloudapi/vins/create_in_rg.go b/pkg/cloudapi/vins/create_in_rg.go index ec6b14b..b59b037 100644 --- a/pkg/cloudapi/vins/create_in_rg.go +++ b/pkg/cloudapi/vins/create_in_rg.go @@ -2,10 +2,10 @@ package vins import ( "context" - "encoding/json" "net/http" "strconv" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants" "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) @@ -56,11 +56,11 @@ type CreateInRGRequest struct { // Required: false // Default: false EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"` -} -type wrapperCreateRequestInRG struct { - CreateInRGRequest - Routes []string `url:"routes,omitempty"` + // Flag indicating whether default gateway is enabled for this VINS + // Required: false + // Default: true + EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` } // CreateInRG creates VINS in resource group level @@ -70,31 +70,9 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er return 0, validators.ValidationErrors(validators.GetErrors(err)) } - var routes []string - - if len(req.Routes) != 0 { - routes = make([]string, 0, len(req.Routes)) - - for r := range req.Routes { - b, err := json.Marshal(req.Routes[r]) - if err != nil { - return 0, err - } - - routes = append(routes, string(b)) - } - } else { - routes = []string{} - } - - reqWrapped := wrapperCreateRequestInRG{ - CreateInRGRequest: req, - Routes: routes, - } - url := "/cloudapi/vins/createInRG" - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) + res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { return 0, err } diff --git a/pkg/cloudapi/vins/models.go b/pkg/cloudapi/vins/models.go index 2c48ca3..86851c1 100644 --- a/pkg/cloudapi/vins/models.go +++ b/pkg/cloudapi/vins/models.go @@ -694,6 +694,9 @@ type RecordVINS struct { // Description Description string `json:"desc"` + // Enable Default Gateway + EnableDefaultGateway bool `json:"enable_default_gateway"` + // Enable Security Groups EnableSecGroups bool `json:"enable_secgroups"` diff --git a/pkg/cloudapi/zone/models.go b/pkg/cloudapi/zone/models.go index bffd048..34eda0f 100644 --- a/pkg/cloudapi/zone/models.go +++ b/pkg/cloudapi/zone/models.go @@ -111,6 +111,12 @@ type RecordZone struct { // CPU alignment profiles CpuAlignmentProfiles []CpuAlignmentProfile `json:"cpu_alignment_profiles"` + + // Reserved CPU + ReservedCPU uint64 `json:"reserved_cpu"` + + // Reserved RAM + ReservedRAM uint64 `json:"reserved_ram"` } // A zone item from a list @@ -183,4 +189,10 @@ type ItemZone struct { // CPU alignment profiles CpuAlignmentProfiles []CpuAlignmentProfile `json:"cpu_alignment_profiles"` + + // Reserved CPU + ReservedCPU uint64 `json:"reserved_cpu"` + + // Reserved RAM + ReservedRAM uint64 `json:"reserved_ram"` } diff --git a/pkg/cloudbroker/account/set_cpu_allocation_parameter.go b/pkg/cloudbroker/account/set_cpu_allocation_parameter.go index b9bf90d..f22efb9 100644 --- a/pkg/cloudbroker/account/set_cpu_allocation_parameter.go +++ b/pkg/cloudbroker/account/set_cpu_allocation_parameter.go @@ -3,8 +3,9 @@ package account import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) // SetCPUAllocationParameterRequest struct for setting CPU allocation parameter diff --git a/pkg/cloudbroker/compute/models.go b/pkg/cloudbroker/compute/models.go index 2d489d7..a1f5141 100644 --- a/pkg/cloudbroker/compute/models.go +++ b/pkg/cloudbroker/compute/models.go @@ -148,6 +148,9 @@ type RecordNetAttach struct { // Enabled Enabled bool `json:"enabled"` + // Enable default gateway + EnableDefaultGateway bool `json:"enable_default_gateway"` + // Enable security groups EnableSecGroups bool `json:"enable_secgroups"` @@ -597,6 +600,9 @@ type ItemInterface struct { // Enabled Enabled bool `json:"enabled"` + // Enable default gateway + EnableDefaultGateway bool `json:"enable_default_gateway"` + // Enable security groups EnableSecGroups bool `json:"enable_secgroups"` diff --git a/pkg/cloudbroker/compute/net_attach.go b/pkg/cloudbroker/compute/net_attach.go index 42ce426..6dd4375 100644 --- a/pkg/cloudbroker/compute/net_attach.go +++ b/pkg/cloudbroker/compute/net_attach.go @@ -81,6 +81,11 @@ type NetAttachRequest struct { // Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK) // Required: false Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"` + + // Flag indicating whether default gateway is enabled for this interface + // Required: false + // Default: true + EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` } type wrapperNetAttachRequest struct { diff --git a/pkg/cloudbroker/disks/depresent.go b/pkg/cloudbroker/disks/depresent.go index 511d595..feb04d2 100644 --- a/pkg/cloudbroker/disks/depresent.go +++ b/pkg/cloudbroker/disks/depresent.go @@ -3,8 +3,9 @@ package disks import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) // DepresentRequest struct to depresent disk from node diff --git a/pkg/cloudbroker/disks/models.go b/pkg/cloudbroker/disks/models.go index 1a4c973..694652d 100644 --- a/pkg/cloudbroker/disks/models.go +++ b/pkg/cloudbroker/disks/models.go @@ -343,4 +343,7 @@ type MigrateStatus struct { // Progress percent ProgressPercent int `json:"progress_percent"` + + // Operation status + Ready bool `json:"ready"` } diff --git a/pkg/cloudbroker/disks/present.go b/pkg/cloudbroker/disks/present.go index fe2149e..d9cd2ea 100644 --- a/pkg/cloudbroker/disks/present.go +++ b/pkg/cloudbroker/disks/present.go @@ -3,8 +3,9 @@ package disks import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) // PresentRequest struct to present disk to node diff --git a/pkg/cloudbroker/grid/set_cpu_allocation_parameter.go b/pkg/cloudbroker/grid/set_cpu_allocation_parameter.go index d035608..45e478f 100644 --- a/pkg/cloudbroker/grid/set_cpu_allocation_parameter.go +++ b/pkg/cloudbroker/grid/set_cpu_allocation_parameter.go @@ -3,8 +3,9 @@ package grid import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) // SetCPUAllocationParameterRequest for setting CPU allocation parameter diff --git a/pkg/cloudbroker/grid/set_cpu_allocation_ratio_for_vm.go b/pkg/cloudbroker/grid/set_cpu_allocation_ratio_for_vm.go index 9196f22..1fbf369 100644 --- a/pkg/cloudbroker/grid/set_cpu_allocation_ratio_for_vm.go +++ b/pkg/cloudbroker/grid/set_cpu_allocation_ratio_for_vm.go @@ -3,8 +3,9 @@ package grid import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) // SetCPUAllocationRatioForVMRequest for setting CPU allocation ratio for computes diff --git a/pkg/cloudbroker/grid/set_resources_limit.go b/pkg/cloudbroker/grid/set_resources_limit.go new file mode 100644 index 0000000..546e360 --- /dev/null +++ b/pkg/cloudbroker/grid/set_resources_limit.go @@ -0,0 +1,44 @@ +package grid + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" +) + +// SetResourcesLimitRequest struct to set resources limit +type SetResourcesLimitRequest struct { + // ID of the grid + // Required: true + GID uint64 `url:"grid_id" json:"grid_id" validate:"required"` + + // Number of CPU cores reserved + // Default: 0 + // Required: true + ReservedCPU uint64 `url:"reserved_cpu" json:"reserved_cpu"` + + // Amount of RAM in MB reserved + // Default: 0 + // Required: true + ReservedRAM uint64 `url:"reserved_ram" json:"reserved_ram"` +} + +// SetResourcesLimit sets reserved CPU and RAM limits for the grid +func (g Grid) SetResourcesLimit(ctx context.Context, req SetResourcesLimitRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/grid/set_resources_limit" + + res, err := g.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + return strconv.ParseBool(string(res)) +} diff --git a/pkg/cloudbroker/kvmx86/create.go b/pkg/cloudbroker/kvmx86/create.go index 8791cf6..26846e1 100644 --- a/pkg/cloudbroker/kvmx86/create.go +++ b/pkg/cloudbroker/kvmx86/create.go @@ -59,6 +59,11 @@ type Interface struct { // Required: false Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"` + // Flag indicating whether default gateway are enabled for this interface, not applicable to netType EXTNET, VFNIC, TRUNK, or SDN + // Default: true + // Required: false + EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` + // SDN Segment ID // Required: false SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"` diff --git a/pkg/cloudbroker/kvmx86/mass_create.go b/pkg/cloudbroker/kvmx86/mass_create.go index f380717..3cf0cc9 100644 --- a/pkg/cloudbroker/kvmx86/mass_create.go +++ b/pkg/cloudbroker/kvmx86/mass_create.go @@ -56,6 +56,11 @@ type InterfaceMassCreate struct { // Required: false Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"` + // Flag indicating whether default gateway are enabled for this interface, not applicable to netType EXTNET, VFNIC, TRUNK, or SDN + // Default: true + // Required: false + EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` + // SDN Segment ID // Required: false SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"` diff --git a/pkg/cloudbroker/node/models.go b/pkg/cloudbroker/node/models.go index 51901d6..7939cd8 100644 --- a/pkg/cloudbroker/node/models.go +++ b/pkg/cloudbroker/node/models.go @@ -50,6 +50,12 @@ type RecordNode struct { // ReservedCPUs ReservedCPUs []interface{} `json:"reservedCpus"` + // Reserved CPU + ReservedCPU uint64 `json:"reserved_cpu"` + + // Reserved RAM + ReservedRAM uint64 `json:"reserved_ram"` + // Roles Roles []string `json:"roles"` @@ -260,6 +266,12 @@ type ItemNode struct { // ReservedCPUs ReservedCPUs []interface{} `json:"reservedCpus"` + // Reserved CPU + ReservedCPU uint64 `json:"reserved_cpu"` + + // Reserved RAM + ReservedRAM uint64 `json:"reserved_ram"` + // Roles Roles []string `json:"roles"` diff --git a/pkg/cloudbroker/node/set_resources_limit.go b/pkg/cloudbroker/node/set_resources_limit.go new file mode 100644 index 0000000..367ae83 --- /dev/null +++ b/pkg/cloudbroker/node/set_resources_limit.go @@ -0,0 +1,42 @@ +package node + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" +) + +// SetResourcesLimitRequest struct to set resources limit for node +type SetResourcesLimitRequest struct { + // Node ID + // Required: true + NodeID uint64 `url:"node_id" json:"node_id" validate:"required"` + + // Number of CPU cores reserved + // Required: true + ReservedCPU uint64 `url:"reserved_cpu" json:"reserved_cpu"` + + // Amount of RAM in MB reserved + // Required: true + ReservedRAM uint64 `url:"reserved_ram" json:"reserved_ram"` +} + +// SetResourcesLimit sets reserved CPU and RAM limits for the node +func (n Node) SetResourcesLimit(ctx context.Context, req SetResourcesLimitRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/node/set_resources_limit" + + res, err := n.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + return strconv.ParseBool(string(res)) +} diff --git a/pkg/cloudbroker/pcidevice/delete.go b/pkg/cloudbroker/pcidevice/delete.go index e2bb29e..941f204 100644 --- a/pkg/cloudbroker/pcidevice/delete.go +++ b/pkg/cloudbroker/pcidevice/delete.go @@ -3,8 +3,9 @@ package pcidevice import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) // DeleteRequest struct to deleting PCI device diff --git a/pkg/cloudbroker/pcidevice/disable.go b/pkg/cloudbroker/pcidevice/disable.go index ecaa75a..a806a85 100644 --- a/pkg/cloudbroker/pcidevice/disable.go +++ b/pkg/cloudbroker/pcidevice/disable.go @@ -3,8 +3,9 @@ package pcidevice import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) // DisableRequest struct for disabling PCI device diff --git a/pkg/cloudbroker/pcidevice/enable.go b/pkg/cloudbroker/pcidevice/enable.go index 705ad37..7a8bbf3 100644 --- a/pkg/cloudbroker/pcidevice/enable.go +++ b/pkg/cloudbroker/pcidevice/enable.go @@ -3,8 +3,9 @@ package pcidevice import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) // EnableRequest struct for enabling PCI device diff --git a/pkg/cloudbroker/pcidevice/serialize.go b/pkg/cloudbroker/pcidevice/serialize.go index 46fcb09..062bd2e 100644 --- a/pkg/cloudbroker/pcidevice/serialize.go +++ b/pkg/cloudbroker/pcidevice/serialize.go @@ -2,6 +2,7 @@ package pcidevice import ( "encoding/json" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/serialization" ) diff --git a/pkg/cloudbroker/rg/set_cpu_allocation_parameter.go b/pkg/cloudbroker/rg/set_cpu_allocation_parameter.go index 9676240..f44395e 100644 --- a/pkg/cloudbroker/rg/set_cpu_allocation_parameter.go +++ b/pkg/cloudbroker/rg/set_cpu_allocation_parameter.go @@ -3,8 +3,9 @@ package rg import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) // SetCPUAllocationParameterRequest struct for setting CPU allocation parameter diff --git a/pkg/cloudbroker/rg/set_cpu_allocation_ratio.go b/pkg/cloudbroker/rg/set_cpu_allocation_ratio.go index 09dc8f9..cd102a1 100644 --- a/pkg/cloudbroker/rg/set_cpu_allocation_ratio.go +++ b/pkg/cloudbroker/rg/set_cpu_allocation_ratio.go @@ -3,8 +3,9 @@ package rg import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) // SetCPUAllocationRatioRequest struct for setting CPU allocation ratio diff --git a/pkg/cloudbroker/vgpu/allocate.go b/pkg/cloudbroker/vgpu/allocate.go index 621231b..751b5cc 100644 --- a/pkg/cloudbroker/vgpu/allocate.go +++ b/pkg/cloudbroker/vgpu/allocate.go @@ -3,8 +3,9 @@ package vgpu import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) // AllocateRequest struct for allocating VGPU diff --git a/pkg/cloudbroker/vgpu/create.go b/pkg/cloudbroker/vgpu/create.go index d1d3e0b..a33c989 100644 --- a/pkg/cloudbroker/vgpu/create.go +++ b/pkg/cloudbroker/vgpu/create.go @@ -3,8 +3,9 @@ package vgpu import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) // CreateRequest struct for creating VGPU diff --git a/pkg/cloudbroker/vgpu/deallocate.go b/pkg/cloudbroker/vgpu/deallocate.go index 8ba9c25..1c917b5 100644 --- a/pkg/cloudbroker/vgpu/deallocate.go +++ b/pkg/cloudbroker/vgpu/deallocate.go @@ -3,8 +3,9 @@ package vgpu import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) // DeallocateRequest struct for deallocating VGPU diff --git a/pkg/cloudbroker/vgpu/destroy.go b/pkg/cloudbroker/vgpu/destroy.go index 50bd40f..e3a972a 100644 --- a/pkg/cloudbroker/vgpu/destroy.go +++ b/pkg/cloudbroker/vgpu/destroy.go @@ -3,8 +3,9 @@ package vgpu import ( "context" "net/http" - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) // DestroyRequest struct for destroying VGPU diff --git a/pkg/cloudbroker/vins/create_in_account.go b/pkg/cloudbroker/vins/create_in_account.go index 27db973..6bed17d 100644 --- a/pkg/cloudbroker/vins/create_in_account.go +++ b/pkg/cloudbroker/vins/create_in_account.go @@ -2,10 +2,10 @@ package vins import ( "context" - "encoding/json" "net/http" "strconv" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants" "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) @@ -62,11 +62,11 @@ type CreateInAccountRequest struct { // Required: false // Default: false EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"` -} -type wrapperCreateRequestInAcc struct { - CreateInAccountRequest - Routes []string `url:"routes,omitempty"` + // Flag indicating whether default gateway is enabled for this VINS + // Required: false + // Default: true + EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` } // CreateInAccount creates VINS in account level @@ -76,31 +76,9 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) ( return 0, validators.ValidationErrors(validators.GetErrors(err)) } - var routes []string - - if len(req.Routes) != 0 { - routes = make([]string, 0, len(req.Routes)) - - for r := range req.Routes { - b, err := json.Marshal(req.Routes[r]) - if err != nil { - return 0, err - } - - routes = append(routes, string(b)) - } - } else { - routes = []string{"[]"} - } - - reqWrapped := wrapperCreateRequestInAcc{ - CreateInAccountRequest: req, - Routes: routes, - } - url := "/cloudbroker/vins/createInAccount" - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) + res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { return 0, err } diff --git a/pkg/cloudbroker/vins/create_in_rg.go b/pkg/cloudbroker/vins/create_in_rg.go index 513475d..5c7394c 100644 --- a/pkg/cloudbroker/vins/create_in_rg.go +++ b/pkg/cloudbroker/vins/create_in_rg.go @@ -2,10 +2,10 @@ package vins import ( "context" - "encoding/json" "net/http" "strconv" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants" "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" ) @@ -56,11 +56,11 @@ type CreateInRGRequest struct { // Required: false // Default: false EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"` -} -type wrapperCreateRequestInRG struct { - CreateInRGRequest - Routes []string `url:"routes,omitempty"` + // Flag indicating whether default gateway is enabled for this VINS + // Required: false + // Default: true + EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` } // CreateInRG creates VINS in resource group level @@ -69,31 +69,10 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er if err != nil { return 0, validators.ValidationErrors(validators.GetErrors(err)) } - var routes []string - - if len(req.Routes) != 0 { - routes = make([]string, 0, len(req.Routes)) - - for r := range req.Routes { - b, err := json.Marshal(req.Routes[r]) - if err != nil { - return 0, err - } - - routes = append(routes, string(b)) - } - } else { - routes = []string{"[]"} - } - - reqWrapped := wrapperCreateRequestInRG{ - CreateInRGRequest: req, - Routes: routes, - } url := "/cloudbroker/vins/createInRG" - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) + res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { return 0, err } diff --git a/pkg/cloudbroker/vins/models.go b/pkg/cloudbroker/vins/models.go index c261fa6..d52376d 100644 --- a/pkg/cloudbroker/vins/models.go +++ b/pkg/cloudbroker/vins/models.go @@ -523,6 +523,9 @@ type RecordVINS struct { // Description Description string `json:"desc"` + // Enable Default Gateway + EnableDefaultGateway bool `json:"enable_default_gateway"` + // Enable Security Groups EnableSecGroups bool `json:"enable_secgroups"` @@ -736,6 +739,9 @@ type ItemVINS struct { // Description Description string `json:"desc"` + // Enable Default Gateway + EnableDefaultGateway bool `json:"enable_default_gateway"` + // Enable Security Groups EnableSecGroups bool `json:"enable_secgroups"` diff --git a/pkg/cloudbroker/vins/update.go b/pkg/cloudbroker/vins/update.go index 94c85e4..7571347 100644 --- a/pkg/cloudbroker/vins/update.go +++ b/pkg/cloudbroker/vins/update.go @@ -25,6 +25,10 @@ type UpdateRequest struct { // Flag indicating whether security groups are enabled for this network // Required: false EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"` + + // Flag indicating whether default gateway is enabled for this VINS + // Required: false + EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` } // Update updates a vins parameters diff --git a/pkg/cloudbroker/zone/models.go b/pkg/cloudbroker/zone/models.go index 50dc179..61e83a0 100644 --- a/pkg/cloudbroker/zone/models.go +++ b/pkg/cloudbroker/zone/models.go @@ -177,6 +177,12 @@ type RecordZone struct { // CPU alignment profiles CpuAlignmentProfiles []CpuAlignmentProfile `json:"cpu_alignment_profiles"` + + // Reserved CPU + ReservedCPU uint64 `json:"reserved_cpu"` + + // Reserved RAM + ReservedRAM uint64 `json:"reserved_ram"` } // A zone item from a list @@ -249,4 +255,10 @@ type ItemZone struct { // CPU alignment profiles CpuAlignmentProfiles []CpuAlignmentProfile `json:"cpu_alignment_profiles"` + + // Reserved CPU + ReservedCPU uint64 `json:"reserved_cpu"` + + // Reserved RAM + ReservedRAM uint64 `json:"reserved_ram"` } diff --git a/pkg/cloudbroker/zone/set_resources_limit.go b/pkg/cloudbroker/zone/set_resources_limit.go new file mode 100644 index 0000000..1cc410c --- /dev/null +++ b/pkg/cloudbroker/zone/set_resources_limit.go @@ -0,0 +1,42 @@ +package zone + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" +) + +// SetResourcesLimitRequest struct to set resources limit +type SetResourcesLimitRequest struct { + // ID of the zone + // Required: true + ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"` + + // Number of CPU cores reserved + // Required: true + ReservedCPU uint64 `url:"reserved_cpu" json:"reserved_cpu"` + + // Amount of RAM in MB reserved + // Required: true + ReservedRAM uint64 `url:"reserved_ram" json:"reserved_ram"` +} + +// SetResourcesLimit sets reserved CPU and RAM limits for the zone +func (e Zone) SetResourcesLimit(ctx context.Context, req SetResourcesLimitRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/zone/set_resources_limit" + + res, err := e.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return false, err + } + + return strconv.ParseBool(string(res)) +} diff --git a/pkg/cloudbroker/zone/update_cpu_alignment_profile.go b/pkg/cloudbroker/zone/update_cpu_alignment_profile.go new file mode 100644 index 0000000..d623cd1 --- /dev/null +++ b/pkg/cloudbroker/zone/update_cpu_alignment_profile.go @@ -0,0 +1,46 @@ +package zone + +import ( + "context" + "encoding/json" + "net/http" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants" + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators" +) + +// UpdateCPUAlignmentProfileRequest struct to update CPU alignment profile of zone +type UpdateCPUAlignmentProfileRequest struct { + // ID of zone + // Required: true + ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"` + + // Minimum percentage of hypervisors that must support the selected CPU model for the balanced profile + // Default: 70 + // Required: false + HypervisorSimilarityInPercentage uint64 `url:"hypervisor_similarity_in_percentage,omitempty" json:"hypervisor_similarity_in_percentage,omitempty" validate:"omitempty,max=100"` +} + +// UpdateCPUAlignmentProfile updates CPU alignment profile of zone +func (e Zone) UpdateCPUAlignmentProfile(ctx context.Context, req UpdateCPUAlignmentProfileRequest) ([]CpuAlignmentProfile, error) { + err := validators.ValidateRequest(req) + if err != nil { + return nil, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/zone/update_cpu_alignment_profile" + + res, err := e.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + if err != nil { + return nil, err + } + + var profiles []CpuAlignmentProfile + + err = json.Unmarshal(res, &profiles) + if err != nil { + return nil, err + } + + return profiles, nil +} diff --git a/samples/client/client.go b/samples/client/client.go index 8048596..b7eadee 100644 --- a/samples/client/client.go +++ b/samples/client/client.go @@ -30,7 +30,6 @@ func (m *migrator) Migrate(ctxOrigin context.Context, dxVMID, nodeID uint64) (bo req := compute.MigrateRequest{ ComputeID: dxVMID, TargetNodeID: nodeID, - Force: false, } ctx, cancel := context.WithTimeout(ctxOrigin, m.cfg.QueryTimeout) ok, err := m.client.CloudBroker().Compute().Migrate(ctx, req)