diff --git a/CHANGELOG.md b/CHANGELOG.md index 87d76b6..e98da72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,131 +1,18 @@ -## Version 1.9.0 +## Version 1.9.1 -### Feature - -#### account -- Delete field RecursiveDelete in DeleteUserRequest in cloudapi/account and cloudbroker/account -- Add field UniqPools in UpdateRequest in cloudapi/account -- Add field ClearUniqPools in UpdateRequest in cloudbroker/account -- Add field SortBy in listFlipGroups in cloudapi/account -- Change Ratio field from required to optional in SetCPUAllocationRatioRequest in cloudbroker/compute - -#### audit -- Add endpoint Get in cloudapi/audit -- Add endpoint ExportAuditsToFile in cloudbroker/audit -- Delete field Apitask in model RecordAudit in cloudbroker/audit - -#### compute -- Add support DPDK network net type in NetAttach endpoints in cloudapi/compute and cloudbroker/compute -- Add field Force in CloneRequest in cloudapi/compute and cloudbroker/compute -- Change TargetStackID field from required to optional (add default 0 value) in PinToStackRequest in cloudbroker/compute -- Change return value type from bool to string in SnapshotDelete in cloudbroker/compute and cloudapi/compute -- Add field StatusCheck in MigrateStorageAbortRequest in cloudbroker/compute -- Add function SnapshotDeleteAsync in cloudapi/compute and cloudbroker/compute -- Add field StackID in ListRequest in cloudbroker/compute -- Add field NodeID in model RecordCompute in cloudbroker/compute -- Add function SetNetConfig in cloudbroker/compute -- Add field MTU in model RecordNetAttach in cloudapi/compute and cloudbroker/compute -- Change Mode field from required to optional in DiskMigrateRequest in cloudapi/compute -- Add field Chipset in model RecordCompute in cloudapi/compute and cloudbroker/compute -- Add field BusNumber in model RecordCompute, ItemComputeDisk, ItemDisk, InfoDisk in cloudapi/compute and cloudbroker/compute -- Add field ImageID in ListRequest in cloudbroker/compute -- Change Mode field from required to optional in DiskMigrateRequest in cloudbroker/compute -- Add field Chipset in ListRequest in cloudbroker/compute -- Add endpoints ChangeIP in cloudapi/compute and cloudbroker/compute - -#### disks -- Change drivers field from optional to required in FromPlatformDiskRequest in cloudapi/disks, cloudbroker/disks - -#### dpdknet -- Add endpoints List, Get in cloudapi/dpdk -- Add endpoints Create, Delete, Disable Enable, Get, List, Update in cloudbroker/dpdk - -#### extnet -- Change StackId field from required to optional in DeviceMigrateRequest in cloudbroker/extnet +### Исправлено #### flipgroup -- Change ClientIDs field from []uint64 to []string in ListRequest, cloudapi/flipgroup - -#### grid -- Change PasswordLength field from required to optional (add default 9 value) in SetPasswordPolicyRequest in cloudbroker/grid -- Set Default value (true) in fields Digits and Uppercase in SetPasswordPolicyRequest in cloudbroker/grid -- Add fields ckey, meta in model RecordGrid in cloudbroker/grid -- Change GID field from uint64 to string in ExecuteMaintenanceScriptRequest in cloudbroker/grid -- Add endpoints GetSettings and GetSettingsRaw in cloudbroker/grid - -#### group -- Change StackId field from uint64 to string in ListRequest in cloudbroker/group - -#### image: -- Change Drivers field from required to optional in CreateCDROMImageRequest in cloudbroker/image -- Add field Enabled in ListRequest in cloudapi/image and cloudbroker/image -- Delete field GID in SyncCreateRequest in cloudbroker/image -- Delete field Permanently in DeleteRequest in cloudapi/image and cloudbroker/image -- Delete field Permanently in DeleteImagesRequest in cloudbroker/image +| Идентификатор
задачи | Описание | +| --- | --- | +| BGOS-194 | Изменен тип поля `ClientIDs` c []string на []uint64 в структуре `ListRequest` в cloudapi/flipgroup | #### k8s -- Add fields HighlyAvailableLB, AddressVip, ExtnetOnly, WithLB in model RecordK8S in cloudbroker/k8s and cloudapi/k8s -- Change MasterIds field from a slice of string to a slice of integers in DeleteMasterFromGroupRequest in cloudbroker/k8s and cloudapi/k8s -- Add field Chipset in WorkerAddRequest, WorkersGroupAddRequest in cloudapi/k8s, cloudbroker/k8s -- Add field Chipset in CreateRequest in cloudapi/k8s, cloudbroker/k8s - -#### kvmx86 -- Add support DPDK network interface in Create endpoints in cloudapi/kvmx86 and cloudbroker/kvmx8 -- Add field Chipset in CreateRequest, CreateBlankRequest, MassCreateRequest, CreateBlankRequest in cloudapi/kvmx86 and cloudbroker/kvmx86 -- Add function MassCreateAsync in cloudbroker/kvmx86 +| Идентификатор
задачи | Описание | +| --- | --- | +| BGOS-193 | Изменен тип возвращаемых данных метода `WorkersGroupAdd` c uint64, error на string, error в cloudapi/k8s | #### lb -- Change ExtNetID field from uint64 to int64 in CreateRequest, ItemLBList, RecordLB in cloudapi/lb, cloudbroker/lb -- Change ExtNetID, VINSID fields from required to optional in CreateRequest in cloudapi/lb - -#### node -- Add field Force in EnableRequest in cloudbroker/node -- Add function EnableAsync in cloudbroker/node - -#### rg -- Add endpoints removeDefNet in cloudapi/rg and cloudbroker/rg -- Add field ClearUniqPools in UpdateRequest in cloudbroker/rg and cloudapi/rg -- Add field UniqPools in UpdateRequest in cloudapi/rg -- Delete field IPCIDR in CreateRequest in cloudbroker/rg - -#### sep -- Add endpoints SharedLockStart and SharedLockStop in cloudbroker/sep - -#### user -- Add field GUID in models ItemAudit in cloudapi/user and cloudbroker/user -- Add fields MaxStatusCode and MinStatusCode in GetAuditRequest in cloudapi/user - -#### vins -- Add field Computes in model ListVINS in cloudbroker/vins -- Add fields VNFDevId in ListRequest in cloudapi/vins and in ListDeletedRequest in cloudbroker/vins -- Add field MTU, LibvirtSettings in model ItemInterface in cloudapi/vins and cloudbroker/vins -- Add field BusNumber in model ItemInterface in cloudapi/vins and cloudbroker/vins - -### Removed - -#### common -- The reason field has been deleted everywhere - -#### accounts -- The GetConsumption function was removed in cloudapi/account - -#### grid -- The CheckVMs function was removed in cloudbroker/grid -- The CreateSystemSpace function was removed in cloudbroker/grid - -#### image -- The Permanently field has been removed from DeleteCDROMImageRequest in cloudbroker/image - -#### kvmppc -- The group has been completely deleted - -#### sizes -- The group has been completely deleted - -#### user -- The StatusCode field has been deleted from GetAuditRequest in cloudapi/user - -### Bugfix - -#### backup -- Fixed RestoreDisksFromBackupRequest in cloudbroker/backup +| Идентификатор
задачи | Описание | +| --- | --- | +| BGOS-194 | Исправлена валидация полей `ExtNetID` и `VINSID` в структурах `CreateRequest` в cloudapi/lb и cloudbroker/lb | \ No newline at end of file diff --git a/internal/validators/custom.go b/internal/validators/custom.go index 406d4c6..4e2141c 100644 --- a/internal/validators/custom.go +++ b/internal/validators/custom.go @@ -372,6 +372,13 @@ func urlValidartor(fl validator.FieldLevel) bool { return err == nil } +func chipsetValidator(fe validator.FieldLevel) bool { + fieldValue := fe.Field().String() + fieldValue = strings.ToLower(fieldValue) + + return IsInSlice(fieldValue, chipsetValues) +} + // ValidateRAM checks if request contains RAM value that is positive integer divisible by divisibility passed. // It is recommended to pass constants.RAM_DIVISIBILITY as divisility arguement func ValidateRAM(r interfaces.RequestWithRAM, divisibility uint64) error { diff --git a/internal/validators/messages.go b/internal/validators/messages.go index aa18412..72b4100 100644 --- a/internal/validators/messages.go +++ b/internal/validators/messages.go @@ -299,6 +299,12 @@ func errorMessage(fe validator.FieldError) string { prefix, fe.Field(), joinValues(kvmx86NetTypeValues)) + + case "chipset": + return fmt.Sprintf("%s %s must be one of the following: %s", + prefix, + fe.Field(), + joinValues(chipsetValues)) } return fe.Error() diff --git a/internal/validators/validator.go b/internal/validators/validator.go index 832f435..829eb95 100644 --- a/internal/validators/validator.go +++ b/internal/validators/validator.go @@ -256,5 +256,10 @@ func registerAllValidators(validate *validator.Validate) error { return err } + err = validate.RegisterValidation("chipset", chipsetValidator) + if err != nil { + return err + } + return nil } diff --git a/internal/validators/values.go b/internal/validators/values.go index caf43aa..219fd52 100644 --- a/internal/validators/values.go +++ b/internal/validators/values.go @@ -62,6 +62,8 @@ var ( ioEventFDValues = []string{"on", "off", "selected by hypervisor"} eventIDxValues = []string{"on", "off", "selected by hypervisor"} + + chipsetValues = []string{"i440fx", "Q35"} ) const ( diff --git a/pkg/cloudapi/compute/update.go b/pkg/cloudapi/compute/update.go index f4296e7..aca9b29 100644 --- a/pkg/cloudapi/compute/update.go +++ b/pkg/cloudapi/compute/update.go @@ -37,7 +37,7 @@ type UpdateRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false - Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"` + 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 // Required: false diff --git a/pkg/cloudapi/flipgroup/list.go b/pkg/cloudapi/flipgroup/list.go index e9e1c5e..f248a88 100644 --- a/pkg/cloudapi/flipgroup/list.go +++ b/pkg/cloudapi/flipgroup/list.go @@ -44,7 +44,7 @@ type ListRequest struct { // Find by list of clientIds // Required: false - ClientIDs []string `url:"clientIds,omitempty" json:"clientIds,omitempty"` + ClientIDs []uint64 `url:"clientIds,omitempty" json:"clientIds,omitempty"` // Page number // Required: false diff --git a/pkg/cloudapi/k8s/create.go b/pkg/cloudapi/k8s/create.go index 830d2cc..f110c15 100644 --- a/pkg/cloudapi/k8s/create.go +++ b/pkg/cloudapi/k8s/create.go @@ -165,7 +165,7 @@ type CreateRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false - Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"` + Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` } // GetRAM returns RAM field values diff --git a/pkg/cloudapi/k8s/worker_add.go b/pkg/cloudapi/k8s/worker_add.go index 0849583..636c564 100644 --- a/pkg/cloudapi/k8s/worker_add.go +++ b/pkg/cloudapi/k8s/worker_add.go @@ -24,7 +24,7 @@ type WorkerAddRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false - Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"` + Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` } // WorkerAdd adds worker nodes to a Kubernetes cluster diff --git a/pkg/cloudapi/k8s/workers_group_add.go b/pkg/cloudapi/k8s/workers_group_add.go index 97570c7..79f6245 100644 --- a/pkg/cloudapi/k8s/workers_group_add.go +++ b/pkg/cloudapi/k8s/workers_group_add.go @@ -3,7 +3,6 @@ package k8s import ( "context" "net/http" - "strconv" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" ) @@ -63,7 +62,7 @@ type WorkersGroupAddRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false - Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"` + Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` } // GetRAM returns RAM field values @@ -77,23 +76,18 @@ func (r WorkersGroupAddRequest) GetRAM() map[string]uint64 { } // WorkersGroupAdd adds workers group to Kubernetes cluster -func (k8s K8S) WorkersGroupAdd(ctx context.Context, req WorkersGroupAddRequest) (uint64, error) { +func (k8s K8S) WorkersGroupAdd(ctx context.Context, req WorkersGroupAddRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { - return 0, validators.ValidationErrors(validators.GetErrors(err)) + return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudapi/k8s/workersGroupAdd" res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { - return 0, err + return "", err } - result, err := strconv.ParseUint(string(res), 10, 64) - if err != nil { - return 0, err - } - - return result, nil + return string(res), nil } diff --git a/pkg/cloudapi/kvmx86/create.go b/pkg/cloudapi/kvmx86/create.go index 47fb460..df54d50 100644 --- a/pkg/cloudapi/kvmx86/create.go +++ b/pkg/cloudapi/kvmx86/create.go @@ -153,7 +153,7 @@ type CreateRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false - Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"` + 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 // Required: false diff --git a/pkg/cloudapi/kvmx86/create_blank.go b/pkg/cloudapi/kvmx86/create_blank.go index 5b59aba..b02c69d 100644 --- a/pkg/cloudapi/kvmx86/create_blank.go +++ b/pkg/cloudapi/kvmx86/create_blank.go @@ -63,7 +63,7 @@ type CreateBlankRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false - Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"` + Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` // Text description of this VM // Required: false diff --git a/pkg/cloudapi/lb/create.go b/pkg/cloudapi/lb/create.go index 996efc4..f469776 100644 --- a/pkg/cloudapi/lb/create.go +++ b/pkg/cloudapi/lb/create.go @@ -22,12 +22,12 @@ type CreateRequest struct { Name string `url:"name" json:"name" validate:"required"` // External network to connect this load balancer to - // Required: true - ExtNetID uint64 `url:"extnetId" json:"extnetId" validate:"required"` + // Required: true, can be 0 + ExtNetID uint64 `url:"extnetId" json:"extnetId"` // Internal network (VINS) to connect this load balancer to - // Required: true - VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"` + // Required: true, can be 0 + VINSID uint64 `url:"vinsId" json:"vinsId"` // Custom sysctl values for Load Balancer instance. Applied on boot // Required: false diff --git a/pkg/cloudbroker/compute/update.go b/pkg/cloudbroker/compute/update.go index cda1215..8c659c1 100644 --- a/pkg/cloudbroker/compute/update.go +++ b/pkg/cloudbroker/compute/update.go @@ -37,7 +37,7 @@ type UpdateRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false - Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"` + 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 // Required: false diff --git a/pkg/cloudbroker/k8s/create.go b/pkg/cloudbroker/k8s/create.go index 30f718b..0a44290 100644 --- a/pkg/cloudbroker/k8s/create.go +++ b/pkg/cloudbroker/k8s/create.go @@ -167,7 +167,7 @@ type CreateRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false - Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"` + Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` } // GetRAM returns RAM values diff --git a/pkg/cloudbroker/k8s/worker_add.go b/pkg/cloudbroker/k8s/worker_add.go index 925fcda..3dbc2a5 100644 --- a/pkg/cloudbroker/k8s/worker_add.go +++ b/pkg/cloudbroker/k8s/worker_add.go @@ -24,7 +24,7 @@ type WorkerAddRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false - Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"` + Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` } // WorkerAdd adds worker nodes to a kubernetes cluster diff --git a/pkg/cloudbroker/k8s/workers_group_add.go b/pkg/cloudbroker/k8s/workers_group_add.go index 39a468e..3fad133 100644 --- a/pkg/cloudbroker/k8s/workers_group_add.go +++ b/pkg/cloudbroker/k8s/workers_group_add.go @@ -65,7 +65,7 @@ type WorkersGroupAddRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false - Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"` + Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` } // GetRAM returns RAM field values diff --git a/pkg/cloudbroker/kvmx86/create.go b/pkg/cloudbroker/kvmx86/create.go index 899b320..add6a53 100644 --- a/pkg/cloudbroker/kvmx86/create.go +++ b/pkg/cloudbroker/kvmx86/create.go @@ -157,7 +157,7 @@ type CreateRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false - Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"` + 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 // Required: false diff --git a/pkg/cloudbroker/kvmx86/create_blank.go b/pkg/cloudbroker/kvmx86/create_blank.go index cc4039f..648443a 100644 --- a/pkg/cloudbroker/kvmx86/create_blank.go +++ b/pkg/cloudbroker/kvmx86/create_blank.go @@ -67,7 +67,7 @@ type CreateBlankRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false - Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"` + Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` } // GetRAM returns RAM field values diff --git a/pkg/cloudbroker/kvmx86/mass_create.go b/pkg/cloudbroker/kvmx86/mass_create.go index f496cbf..2fddda5 100644 --- a/pkg/cloudbroker/kvmx86/mass_create.go +++ b/pkg/cloudbroker/kvmx86/mass_create.go @@ -78,7 +78,7 @@ type MassCreateRequest struct { // Type of the emulated system, Q35 or i440fx // Required: false - Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"` + Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"omitempty,chipset"` } type asyncWrapperMassCreateRequest struct { diff --git a/pkg/cloudbroker/lb/create.go b/pkg/cloudbroker/lb/create.go index 57596f2..046652a 100644 --- a/pkg/cloudbroker/lb/create.go +++ b/pkg/cloudbroker/lb/create.go @@ -22,12 +22,12 @@ type CreateRequest struct { Name string `url:"name" json:"name" validate:"required"` // External network to connect this load balancer to - // Required: true - ExtNetID int64 `url:"extnetId" json:"extnetId" validate:"required"` + // Required: true, can be 0 + ExtNetID int64 `url:"extnetId" json:"extnetId"` // Internal network (VINS) to connect this load balancer to - // Required: true - VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"` + // Required: true, can be 0 + VINSID uint64 `url:"vinsId" json:"vinsId"` // Start now Load balancer // Required: true