This commit is contained in:
2024-11-12 12:51:21 +03:00
parent f1e0f7abb6
commit 80491ed643
226 changed files with 3033 additions and 2633 deletions

View File

@@ -13,10 +13,6 @@ type DeleteRequest struct {
// Required: true
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
// Reason to delete
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
// Whether to completely delete the account
// Required: false
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`

View File

@@ -13,10 +13,6 @@ type DeleteAccountsRequest struct {
// Required: true
AccountsIDs []uint64 `url:"accountIds" json:"accountIds" validate:"min=1"`
// Reason for deletion
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
// Whether to completely destroy accounts or not
// Required: false
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`

View File

@@ -17,10 +17,6 @@ type DeleteUserRequest struct {
// ID or emailaddress of the user to remove
// Required: true
UserName string `url:"username" json:"username" validate:"required"`
// Recursively revoke access rights from owned cloudspaces and vmachines
// Required: false
RecursiveDelete bool `url:"recursivedelete" json:"recursivedelete"`
}
// DeleteUser revokes user access from the account

View File

@@ -13,10 +13,6 @@ type DisableRequest struct {
// ID of account
// Required: true
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
// Reason to disable
// Required: true
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Disable disables an account

View File

@@ -13,10 +13,6 @@ type EnableRequest struct {
// ID of account
// Required: true
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
// Reason to enable
// Required: true
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Enable enables an account

View File

@@ -12,10 +12,6 @@ type RestoreRequest struct {
// ID an account
// Required: true
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
// Reason to restore
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Restore restores a deleted account

View File

@@ -3,8 +3,9 @@ package account
import (
"context"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// SetCPUAllocationRatioRequest struct for setting CPU allocation ratio
@@ -14,9 +15,8 @@ type SetCPUAllocationRatioRequest struct {
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
// CPU allocation ratio, i.e. one pCPU = ratio*vCPU
// if don't set, default value = 0
// Required: false
Ratio float64 `url:"ratio" json:"ratio"`
// Required: true
Ratio float64 `url:"ratio" json:"ratio" validate:"required"`
}
// SetCPUAllocationRatio sets CPU allocation ratio

View File

@@ -50,6 +50,11 @@ type UpdateRequest struct {
// i.e.: ["sep1_poolName1", "sep2_poolName2", etc]
// Required: false
UniqPools []string `url:"uniqPools,omitempty" json:"uniqPools,omitempty"`
// if True the field will be cleared
// Default: false
// Required: false
ClearUniqPools bool `url:"clearUniqPools" json:"clearUniqPools"`
}
// Update updates an account name and resource types and limits

View File

@@ -83,7 +83,6 @@ type CloudAPIEndpoints struct {
Image []string `json:"image,omitempty"`
K8CI []string `json:"k8ci,omitempty"`
K8S []string `json:"k8s,omitempty"`
KVMPPC []string `json:"kvmppc,omitempty"`
KVMX86 []string `json:"kvmx86,omitempty"`
LB []string `json:"lb,omitempty"`
Loactions []string `json:"locations,omitempty"`
@@ -127,7 +126,6 @@ type CloudBrokerEndpoints struct {
Job interface{} `json:"job,omitempty"`
K8CI []string `json:"k8ci,omitempty"`
K8S []string `json:"k8s,omitempty"`
KVMPPC []string `json:"kvmppc,omitempty"`
KVMX86 []string `json:"kvmx86,omitempty"`
LB []string `json:"lb,omitempty"`
Machine []string `json:"machine,omitempty"`

View File

@@ -0,0 +1,18 @@
package audit
import (
"context"
"net/http"
)
// ExportAuditsToFile Get audits in csv file, return []byte which should be written to a file *tar.gz
func (a Audit) ExportAuditsToFile(ctx context.Context) ([]byte, error) {
url := "/cloudbroker/audit/exportAuditsToFile"
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, nil)
if err != nil {
return nil, err
}
return res, nil
}

View File

@@ -33,9 +33,6 @@ type ListAudits struct {
// Main info about audit
type RecordAudit struct {
// Apitask
Apitask string `json:"apitask"`
// Arguments
Arguments string `json:"args"`

View File

@@ -26,7 +26,7 @@ type RestoreDisksFromBackupRequest struct {
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
//Backup files
BackupFiles []BackupFile `url:"backupFiles" json:"backupFiles" validate:"required,dive"`
BackupFiles []BackupFile `url:"disks" json:"disks" validate:"required,dive"`
}
type wrapperRestoreDisksFromBackupRequest struct {

View File

@@ -13,10 +13,6 @@ type CDEjectRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Reason to eject
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// CDEject ejects CD image to compute's CD-ROM

View File

@@ -16,10 +16,6 @@ type CDInsertRequest struct {
// ID of CD-ROM image
// Required: true
CDROMID uint64 `url:"cdromId" json:"cdromId" validate:"required"`
// Reason to insert
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// CDInsert inserts new CD image to compute's CD-ROM

View File

@@ -0,0 +1,54 @@
package compute
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// ChangeIPRequest struct to change IP for network
type ChangeIPRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Network type
// 'EXTNET' for connect to external network directly
// 'VINS' for connect to ViNS
// Required: true
NetType string `url:"netType" json:"netType" validate:"computeNetType"`
// Network ID for connect to
// For EXTNET - external network ID
// For VINS - VINS ID
// Required: true
NetID uint64 `url:"netId" json:"netId" validate:"required"`
// IP address to which we will change the existing one, it must be from the same subnet
// Required: true
IPAddr string `url:"ipAddr" json:"ipAddr" validate:"required"`
}
// ChangeIP change reserved IP for compute instance
func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/compute/changeIp"
res, err := c.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
}

View File

@@ -26,9 +26,10 @@ type CloneRequest struct {
// Required: false
SnapshotName string `url:"snapshotName" json:"snapshotName"`
// Reason to clone
// true ignore that the compute is running
// Default: false
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
Force bool `url:"force" json:"force"`
}
// Clone clones compute instance

View File

@@ -18,10 +18,6 @@ type CreateTemplateRequest struct {
// Name to assign to the template being created
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
type wrapperCreateTemplateRequest struct {

View File

@@ -21,10 +21,6 @@ type DeleteRequest struct {
// Set True if you want to detach data disks (if any) from the compute before its deletion
// Required: false
DetachDisks bool `url:"detachDisks,omitempty" json:"detachDisks,omitempty"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Delete deletes compute

View File

@@ -13,10 +13,6 @@ type DisableRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Disable disables compute

View File

@@ -21,10 +21,6 @@ type DiskAttachRequest struct {
// Type of the disk B;D
// Required: false
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// DiskAttach attach disk to compute

View File

@@ -21,10 +21,6 @@ type DiskDelRequest struct {
// False if disk is to be deleted to recycle bin
// Required: true
Permanently bool `url:"permanently" json:"permanently"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// DiskDel deletes disk and detaches it from compute

View File

@@ -17,10 +17,6 @@ type DiskDetachRequest struct {
// ID of the disk to detach
// Required: true
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// DiskDetach detaches disk from compute

View File

@@ -24,8 +24,8 @@ type DiskMigrateRequest struct {
// Migration mode. 1 - Data migration and domain update were already completed by third-party software.
// Use this if target disk already connected to compute and you only need to save changes for next reboot.
// Required: true
Mode int64 `url:"mode" json:"mode" validate:"required"`
// Required: false
Mode int64 `url:"mode,omitempty" json:"mode,omitempty"`
}
// DiskMigrate - migrate compute's disk to target disk. Source disk will be detached, target disk will be attached to the same PCI slot.

View File

@@ -21,10 +21,6 @@ type DiskQOSRequest struct {
// Limit IO for a certain disk total and read/write options are not allowed to be combined
// Required: true
Limits string `url:"limits" json:"limits" validate:"required"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// DiskQOS changes QOS of the disk

View File

@@ -21,10 +21,6 @@ type DiskResizeRequest struct {
// New disk size
// Required: true
Size uint64 `url:"size" json:"size" validate:"required"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// DiskResize changes disk size

View File

@@ -13,10 +13,6 @@ type EnableRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Enable enables compute

View File

@@ -13,10 +13,6 @@ type GetRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Reason to action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Get gets information about compute as a RecordCompute struct

View File

@@ -13,10 +13,6 @@ type GetAuditsRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Reason to action
// Required: true
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// GetAudits gets compute audits

View File

@@ -42,6 +42,14 @@ type ListRequest struct {
// Required: false
IPAddress string `url:"ipAddress,omitempty" json:"ipAddress,omitempty"`
// Find by stack ID
// Required: false
StackID uint64 `url:"stackId,omitempty" json:"stackId,omitempty"`
// Find by image ID
// Required: false
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
// Find by external network name
// Required: false
ExtNetName string `url:"extNetName,omitempty" json:"extNetName,omitempty"`

View File

@@ -17,10 +17,6 @@ type MassDeleteRequest struct {
// Delete computes permanently
// Required: false
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// MassDelete starts jobs to delete several computes

View File

@@ -13,10 +13,6 @@ type MassRebootRequest struct {
// IDs of compute instances to reboot
// Required: true
ComputeIDs []uint64 `url:"computeIds" json:"computeIds" validate:"min=1"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// MassReboot starts jobs to reboot several computes

View File

@@ -13,10 +13,6 @@ type MassRepairBootFSRequest struct {
// IDs of compute instances which boot file systems will be repaired
// Required: true
ComputeIDs []uint64 `url:"computeIds" json:"computeIds" validate:"min=1"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// MassRepairBootFS repairs boot disk filesystem on several computes

View File

@@ -13,10 +13,6 @@ type MassStartRequest struct {
// IDs of compute instances to start
// Required: true
ComputeIDs []uint64 `url:"computeIds" json:"computeIds" validate:"min=1"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// MassStart starts jobs to start several computes

View File

@@ -17,10 +17,6 @@ type MassStopRequest struct {
// Force stop compute
// Required: false
Force bool `url:"force,omitempty" json:"force,omitempty"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// MassStop starts jobs to stop several computes

View File

@@ -22,10 +22,6 @@ type MigrateRequest struct {
// on source node and recreate on the target
// Required: false
Force bool `url:"force,omitempty" json:"force,omitempty"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Migrate migrates compute to another stack

View File

@@ -13,6 +13,11 @@ type MigrateStorageAbortRequest struct {
// ID of the compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Status check
// Default: false
// Required: false
StatusCheck bool `url:"statusCheck" json:"statusCheck"`
}
// MigrateStorageAbort aborts complex compute migration job

View File

@@ -364,6 +364,9 @@ type ItemDisk struct {
// Boot partition
BootPartition uint64 `json:"bootPartition"`
// Bus number
BusNumber uint64 `json:"bus_number"`
// Created time
CreatedTime uint64 `json:"createdTime"`
@@ -510,6 +513,9 @@ type ListDisks []ItemDisk
// Main information about interface
type ItemInterface struct {
// Bus number
BusNumber uint64 `json:"bus_number"`
// Connection ID
ConnID uint64 `json:"connId"`
@@ -534,6 +540,12 @@ type ItemInterface struct {
// Listen SSH or not
ListenSSH bool `json:"listenSsh"`
// Maximum transmission unit
MTU uint64 `json:"mtu"`
// Libvirt Settings
LibvirtSettings LibvirtSettings `json:"libvirtSettings"`
// MAC
MAC string `json:"mac"`
@@ -621,9 +633,12 @@ type InfoCompute struct {
// Boot disk size
BootDiskSize uint64 `json:"bootdiskSize"`
// cd Image Id
// CD Image Id
CdImageId uint64 `json:"cdImageId"`
// Chipset
Chipset string `json:"chipset"`
// Clone reference
CloneReference uint64 `json:"cloneReference"`
@@ -784,6 +799,30 @@ type InfoCompute struct {
VirtualImageID uint64 `json:"virtualImageId"`
}
// Information about libvirt settings
type LibvirtSettings struct {
// TX mode
TXMode string `json:"txmode"`
// IO event
IOEventFD string `json:"ioeventfd"`
// Event ID
EventIDx string `json:"event_idx"`
// Number of queues
Queues uint64 `json:"queues"`
// RX queue size
RXQueueSize uint64 `json:"rx_queue_size"`
// TX queue size
TXQueueSize uint64 `json:"tx_queue_size"`
// GUID
GUID string `json:"guid"`
}
// Detailed information about compute
type RecordCompute struct {
// Account ID
@@ -816,9 +855,12 @@ type RecordCompute struct {
// Boot disk size
BootDiskSize uint64 `json:"bootdiskSize"`
// cd Image Id
// CD Image Id
CdImageId uint64 `json:"cdImageId"`
// Chipset
Chipset string `json:"chipset"`
// Clone reference
CloneReference uint64 `json:"cloneReference"`
@@ -900,6 +942,9 @@ type RecordCompute struct {
// Name
Name string `json:"name"`
// Node ID
NodeID uint64 `json:"nodeId"`
// Natable VINS ID
NatableVINSID uint64 `json:"natableVinsId"`
@@ -1020,6 +1065,9 @@ type ItemCompute struct {
// Information Disk
type InfoDisk struct {
// Bus number
BusNumber uint64 `json:"bus_number"`
// ID
ID uint64 `json:"id"`
@@ -1036,7 +1084,6 @@ type ListComputes struct {
EntryCount uint64 `json:"entryCount"`
}
// Short information about audit
// Short information about audit
type ItemAudit struct {
// Epoch

View File

@@ -18,6 +18,7 @@ type NetAttachRequest struct {
// 'EXTNET' for connect to external network directly
// 'VINS' for connect to ViNS
// 'VFNIC' for connect to vfpool
// 'DPDK' for connect to DPDK
// Required: true
NetType string `url:"netType" json:"netType" validate:"computex86NetType"`
@@ -31,9 +32,9 @@ type NetAttachRequest struct {
// Required: true
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
// Reason for action
// Used only for DPDK type, must be 1-9216
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
}
// NetAttach attaches network to compute and gets info about network

View File

@@ -21,10 +21,6 @@ type NetDetachRequest struct {
// MAC of the network interface
// Required: false
MAC string `url:"mac,omitempty" json:"mac,omitempty"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// NetDetach detaches network from compute

View File

@@ -13,10 +13,6 @@ type PauseRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Pause pause compute

View File

@@ -33,10 +33,6 @@ type PFWAddRequest struct {
// - udp
// Required: true
Proto string `url:"proto" json:"proto" validate:"proto"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// PFWAdd adds port forward rule

View File

@@ -36,10 +36,6 @@ type PFWDelRequest struct {
// - udp
// Required: false
Proto string `url:"proto,omitempty" json:"proto,omitempty" validate:"omitempty,proto"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// PFWDel deletes port forward rule

View File

@@ -13,10 +13,6 @@ type PFWListRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// PFWList gets compute port forwards list

View File

@@ -15,8 +15,8 @@ type PinToStackRequest struct {
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Stack ID to pin to
// Required: true
TargetStackID uint64 `url:"targetStackId" json:"targetStackId" validate:"required"`
// Required: false
TargetStackID uint64 `url:"targetStackId" json:"targetStackId"`
// Try to migrate or not if compute in running states
// Required: false

View File

@@ -13,10 +13,6 @@ type RebootRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Reboot reboots compute

View File

@@ -37,10 +37,6 @@ type RedeployRequest struct {
// Set this flag to True to force stop running compute instance and redeploy next
// Required: false
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Redeploy redeploys compute

View File

@@ -13,10 +13,6 @@ type RepairBootFSRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// RepairBootFS repairs compute boot disk filesystem

View File

@@ -13,10 +13,6 @@ type ResetRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Reset resets compute

View File

@@ -27,10 +27,6 @@ type ResizeRequest struct {
// Force compute resize
// Required: false
Force bool `url:"force,omitempty" json:"force,omitempty"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// GetRAM returns RAM field values

View File

@@ -13,10 +13,6 @@ type RestoreRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Restore restores compute from recycle bin

View File

@@ -13,10 +13,6 @@ type ResumeRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Resume resumes Compute from paused state

View File

@@ -0,0 +1,66 @@
package compute
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// SetNetConfigRequest struct to Configure libvirt virtio interface parameters
type SetNetConfigRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Interface MAC-address
// Required: true
MAC string `url:"mac" json:"mac" validate:"required"`
// TXMode, must be 'iothread', 'timer' or 'selected by hypervisor'
// Required: false
TXMode string `url:"txmode,omitempty" json:"txmode,omitempty" validate:"omitempty,interfaceTXModel"`
// IOEventFD, must be 'on', 'off' or 'selected by hypervisor'
// Required: false
IOEventFD string `url:"ioeventfd,omitempty" json:"ioeventfd,omitempty" validate:"omitempty,interfaceIOEventFD"`
// EventIDx, must be 'on', 'off' or 'selected by hypervisor'
// Required: false
EventIDx string `url:"event_idx,omitempty" json:"event_idx,omitempty" validate:"omitempty,interfaceEventIDx"`
// Number of queues
// Required: false
Queues uint64 `url:"queues,omitempty" json:"queues,omitempty"`
// RX queue size
// Required: false
RXQueueSize uint64 `url:"rx_queue_size,omitempty" json:"rx_queue_size,omitempty"`
// TX queue size
// Required: false
TXQueueSize uint64 `url:"tx_queue_size,omitempty" json:"tx_queue_size,omitempty"`
}
// Configure libvirt virtio interface parameters
func (c Compute) SetNetConfig(ctx context.Context, req SetNetConfigRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/compute/setNetConfig"
res, err := c.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
}

View File

@@ -3,7 +3,6 @@ package compute
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
@@ -19,24 +18,52 @@ type SnapshotDeleteRequest struct {
Label string `url:"label" json:"label" validate:"required"`
}
type wrapperSnapshotDeleteRequest struct {
SnapshotDeleteRequest
AsyncMode bool `url:"asyncMode"`
}
// SnapshotDelete deletes specified compute snapshot
func (c Compute) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (bool, error) {
func (c Compute) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperSnapshotDeleteRequest{
SnapshotDeleteRequest: req,
AsyncMode: false,
}
url := "/cloudbroker/compute/snapshotDelete"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
return "", err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
return string(res), nil
}
// SnapshotDeleteAsync deletes specified compute snapshot with AsyncMode
func (c Compute) SnapshotDeleteAsync(ctx context.Context, req SnapshotDeleteRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperSnapshotDeleteRequest{
SnapshotDeleteRequest: req,
AsyncMode: true,
}
url := "/cloudbroker/compute/snapshotDelete"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -21,10 +21,6 @@ type StartRequest struct {
// ID of stack to start compute
// Required: false
StackID uint64 `url:"stackId,omitempty" json:"stackId,omitempty"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Start starts compute

View File

@@ -22,10 +22,6 @@ type StopRequest struct {
// Default: true
// Required: false
Depresent bool `url:"depresent" json:"depresent"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Stop stops compute

View File

@@ -35,14 +35,14 @@ type UpdateRequest struct {
// Default: false
CPUPin bool `url:"cpupin" json:"cpupin"`
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
// 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
// Default: false
HPBacked bool `url:"hpBacked" json:"hpBacked"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Update updates some properties of the compute

View File

@@ -21,10 +21,6 @@ type DeleteRequest struct {
// Whether to completely delete the disk, works only with non attached disks
// Required: false
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
// Reason to delete
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Delete deletes disk by ID

View File

@@ -14,10 +14,6 @@ type DeleteDisksRequest struct {
// Required: true
DisksIDs []uint64 `url:"diskIds" json:"diskIds" validate:"min=1"`
// Reason for deleting the disks
// Required: true
Reason string `url:"reason" json:"reason" validate:"required"`
// Whether to completely delete the disks, works only with non attached disks
// Required: false
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`

View File

@@ -30,7 +30,6 @@ type FromPlatformDiskRequest struct {
// Binary architecture of this image
// Should be:
// - X86_64
// - PPC64_LE
// Required: true
Architecture string `url:"architecture" json:"architecture" validate:"imageArchitecture"`
@@ -56,8 +55,8 @@ type FromPlatformDiskRequest struct {
// List of types of compute suitable for image
// Example: [ "KVM_X86" ]
// Required: false
Drivers []string `url:"drivers,omitempty" json:"drivers,omitempty"`
// Required: true
Drivers []string `url:"drivers" json:"drivers" validate:"required"`
// Does this machine supports hot resize
// Required: false

View File

@@ -13,10 +13,6 @@ type RestoreRequest struct {
// ID of the disk to restore
// Required: true
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
// Reason for restoring the disk
// Required: true
Reason string `url:"reason" json:"reason" validate:"required"`
}
// Restore restores a deleted unattached disk from recycle bin

8
pkg/cloudbroker/dpdk.go Normal file
View File

@@ -0,0 +1,8 @@
package cloudbroker
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/dpdknet"
// Accessing the DPDK method group
func (ca *CloudBroker) DPDKNet() *dpdknet.DPDKNet {
return dpdknet.New(ca.client)
}

View File

@@ -0,0 +1,62 @@
package dpdknet
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// CreateRequest struct to create DPDK network
type CreateRequest struct {
// Name of new DPDK network
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// Description of new DPDK network. Prefer to contain additional information about DPDK network.
// Required: false
Description string `url:"description,omitempty" json:"description,omitempty"`
// ID of the grid (platform)
// Required: true
GID uint64 `url:"gid" json:"gid" validate:"required"`
// ID of vlan
// Required: true
VlanID uint64 `url:"vlanId" json:"vlanId" validate:"required"`
// Name of OVS Bridge to use for creating DPDK network on
// Required: true
OVSBridge string `url:"ovsBridge" json:"ovsBridge" validate:"required"`
// List of account IDs to which DPDK network will be available. Empty field means all accounts in the system.
// Required: false
AccountAccess []uint64 `url:"accountAccess,omitempty" json:"accountAccess,omitempty"`
// List of resource groups IDs to which DPDK network will be available. Empty field means all resource groups in the system.
// Required: false
RGAccess []uint64 `url:"rgAccess,omitempty" json:"rgAccess,omitempty"`
}
// Create creates a DPDK networks
func (d DPDKNet) Create(ctx context.Context, req CreateRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
return 0, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/dpdknet/create"
res, err := d.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
}

View File

@@ -1,4 +1,4 @@
package grid
package dpdknet
import (
"context"
@@ -8,23 +8,23 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// CheckVMsRequest struct to check virtual machine
type CheckVMsRequest struct {
// Grid (platform) ID
// DeleteRequest struct to delete DPDK network
type DeleteRequest struct {
// ID of DPDK network to delete
// Required: true
GID uint64 `url:"gid" json:"gid" validate:"required"`
DPDKID uint64 `url:"dpdkId" json:"dpdkId" validate:"required"`
}
// CheckVMs run checkvms jumpscript
func (g Grid) CheckVMs(ctx context.Context, req CheckVMsRequest) (bool, error) {
// Delete deletes DPDK network by ID
func (d DPDKNet) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/grid/checkVMs"
url := "/cloudbroker/dpdknet/delete"
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}

View File

@@ -0,0 +1,39 @@
package dpdknet
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DisableRequest struct to disable DPDK network
// Computes will not be able to use it until it is enabled again.
type DisableRequest struct {
// ID of DPDK network to disable
// Required: true
DPDKID uint64 `url:"dpdkId" json:"dpdkId" validate:"required"`
}
// Disable disables DPDK network by ID
func (d DPDKNet) Disable(ctx context.Context, req DisableRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/dpdknet/disable"
res, err := d.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
}

View File

@@ -0,0 +1,15 @@
package dpdknet
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
// Structure for creating request to DPDK network
type DPDKNet struct {
client interfaces.Caller
}
// Builder for dpdk endpoints
func New(client interfaces.Caller) *DPDKNet {
return &DPDKNet{
client,
}
}

View File

@@ -0,0 +1,38 @@
package dpdknet
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// EnableRequest struct to enable DPDK network
type EnableRequest struct {
// ID of DPDK network to enable
// Required: true
DPDKID uint64 `url:"dpdkId" json:"dpdkId" validate:"required"`
}
// Enable enables DPDK network by ID
func (d DPDKNet) Enable(ctx context.Context, req EnableRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/dpdknet/enable"
res, err := d.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
}

View File

@@ -0,0 +1,46 @@
package dpdknet
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// GetRequest struct to get information about DPDK network
type GetRequest struct {
// ID of the DPDK network
// Required: true
DPDKID uint64 `url:"dpdkId" json:"dpdkId" validate:"required"`
}
// Get DPDK network details as a RecordDPDKNet struct
func (d DPDKNet) Get(ctx context.Context, req GetRequest) (*RecordDPDKNet, error) {
res, err := d.GetRaw(ctx, req)
if err != nil {
return nil, err
}
info := RecordDPDKNet{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
// GetRaw gets DPDK network details as an array of bytes
func (d DPDKNet) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/dpdknet/get"
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -0,0 +1,91 @@
package dpdknet
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// ListRequest struct to get list of DPDK networks
type ListRequest struct {
// Find by id
// Required: false
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
// Find by gid
// Required: false
GID uint64 `url:"gid,omitempty" json:"gid,omitempty"`
// Find by name
// Required: false
Name string `url:"name,omitempty" json:"name,omitempty"`
// Find by description
// Required: false
Description string `url:"description,omitempty" json:"description,omitempty"`
// Find by status
// Required: false
Status string `url:"status,omitempty" json:"status,omitempty"`
// Find by account access
// Required: false
AccountAccess []uint64 `url:"accountAccess,omitempty" json:"accountAccess,omitempty"`
// Find by resource group access
// Required: false
RGAccess []uint64 `url:"rgAccess,omitempty" json:"rgAccess,omitempty"`
// Find by vlan ID
// Required: false
VlanID uint64 `url:"vlanId,omitempty" json:"vlanId,omitempty"`
// Find by computeIDs
// Required: false
ComputeIDs []uint64 `url:"computeIds,omitempty" json:"computeIds,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"`
}
// List gets list of the created DPDK networks belonging to an account as a ListDPDKNet struct
func (d DPDKNet) List(ctx context.Context, req ListRequest) (*ListDPDKNet, error) {
res, err := d.ListRaw(ctx, req)
if err != nil {
return nil, err
}
list := ListDPDKNet{}
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
return &list, nil
}
// ListRaw gets list of the created DPDK networks belonging to an account as an array of bytes
func (d DPDKNet) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
if err := validators.ValidateRequest(req); err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/dpdknet/list"
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -0,0 +1,92 @@
package dpdknet
// Detailed information about DPDK network
type RecordDPDKNet struct {
// List of accounts with access
AccountAccess []uint64 `json:"accountAccess"`
// Created time
CreatedTime uint64 `json:"createdTime"`
// Updated time
UpdatedTime uint64 `json:"updatedTime"`
// Description
Description string `json:"description"`
// Grid ID
GID uint64 `json:"gid"`
// Guid ID
GUID uint64 `json:"guid"`
// ID
ID uint64 `json:"id"`
// Name
Name string `json:"name"`
// List of resource groups with access
RGAccess []uint64 `json:"rgAccess"`
// Status
Status string `json:"status"`
// OVS bridge
OVSBridge string `json:"ovsBridge"`
// Vlan ID
VlanID uint64 `json:"vlanId"`
// Compute IDs
ComputeIDs []uint64 `json:"computeIds"`
}
type ListDPDKNet struct {
// Data
Data []ItemDPDKNet `json:"data"`
// Entry count
EntryCount uint64 `json:"entryCount"`
}
type ItemDPDKNet struct {
// List of accounts with access
AccountAccess []uint64 `json:"accountAccess"`
// Created time
CreatedTime uint64 `json:"createdTime"`
// Updated time
UpdatedTime uint64 `json:"updatedTime"`
// Description
Description string `json:"description"`
// Grid ID
GID uint64 `json:"gid"`
// Guid ID
GUID uint64 `json:"guid"`
// ID
ID uint64 `json:"id"`
// Name
Name string `json:"name"`
// List of resource groups with access
RGAccess []uint64 `json:"rgAccess"`
// Status
Status string `json:"status"`
// OVS bridge
OVSBridge string `json:"ovsBridge"`
// Vlan ID
VlanID uint64 `json:"vlanId"`
// Compute IDs
ComputeIDs []uint64 `json:"computeIds"`
}

View File

@@ -0,0 +1,62 @@
package dpdknet
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// UpdateRequest struct to update DPDK network
type UpdateRequest struct {
// ID of DPDK network to update
// Required: true
DPDKID uint64 `url:"dpdkId" json:"dpdkId" validate:"required"`
// New name of DPDK network
// Required: false
Name string `url:"name,omitempty" json:"name,omitempty"`
// Description of DPDK network. Prefer to contain additional information about DPDK network
// Required: false
Description string `url:"description,omitempty" json:"description,omitempty"`
// List of account IDs to which DPDK network will be available. Empty field means all accounts in the system.
// Required: false
AccountAccess []uint64 `url:"accountAccess,omitempty" json:"accountAccess,omitempty"`
// List of resource groups IDs to which DPDK network will be available. Empty field means all resource groups in the system.
// Required: true
RGAccess []uint64 `url:"rgAccess,omitempty" json:"rgAccess,omitempty"`
// ID of vlan
// Required: true
VlanID uint64 `url:"vlanId,omitempty" json:"vlanId,omitempty"`
// Name of OVS Bridge to use for DPDK network
// Required: true
OVSBridge string `url:"ovsBridge,omitempty" json:"ovsBridge,omitempty"`
}
// Update updates a DPDK networks
func (d DPDKNet) Update(ctx context.Context, req UpdateRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/dpdknet/update"
res, err := d.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
}

View File

@@ -15,7 +15,8 @@ type DeviceMigrateRequest struct {
NetID uint64 `url:"net_id" json:"net_id" validate:"required"`
// Target stack ID to migrate to
StackID uint64 `url:"stackId" json:"stackId" validate:"required"`
// Required: false
StackID uint64 `url:"stackId,omitempty" json:"stackId,omitempty"`
}
// DeviceMigrate migrates external network VNF device

View File

@@ -1,60 +0,0 @@
package grid
import (
"context"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// CreateSystemSpaceRequest struct to create system space
type CreateSystemSpaceRequest struct {
// Grid (platform) ID
// Required: true
GID uint64 `url:"id" json:"id" validate:"required"`
// Name of the account/cloudspace to be created for the system
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// ID of the specific image
// Required: true
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
// Size of base volume
// Required: true
BootSize uint64 `url:"bootsize" json:"bootsize" validate:"required"`
// Data disk size in gigabytes
// Required: true
DataDiskSize uint64 `url:"dataDiskSize" json:"dataDiskSize" validate:"required"`
// ID of the specific size
// Required: false
SizeID uint64 `url:"sizeId,omitempty" json:"sizeId,omitempty"`
// Number of vcpus to provide
// Required: false
VCPUS uint64 `url:"vcpus,omitempty" json:"vcpus,omitempty"`
// Amount of memory to provide
// Required: false
Memory uint64 `url:"memory,omitempty" json:"memory,omitempty"`
}
// CreateSystemSpace creates system space
func (g Grid) CreateSystemSpace(ctx context.Context, req CreateSystemSpaceRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/grid/createSystemSpace"
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -12,7 +12,7 @@ import (
type ExecuteMaintenanceScriptRequest struct {
// Grid (platform) ID
// Required: true
GID string `url:"gid" json:"gid" validate:"required"`
GID uint64 `url:"gid" json:"gid" validate:"required"`
// Type of nodes you want to apply the action on
// Required: true

View File

@@ -0,0 +1,46 @@
package grid
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// GetSettingsRequest struct to get grid settings
type GetSettingsRequest struct {
// Grid (platform) ID
// Required: true
GID uint64 `url:"grid_id" json:"grid_id" validate:"required"`
}
// GetSettings gets settings grid by ID as a RecordSettingsGrid struct
func (g Grid) GetSettings(ctx context.Context, req GetSettingsRequest) (*RecordSettingsGrid, error) {
res, err := g.GetSettingsRaw(ctx, req)
if err != nil {
return nil, err
}
settings := RecordSettingsGrid{}
err = json.Unmarshal(res, &settings)
if err != nil {
return nil, err
}
return &settings, nil
}
// GetSettingsRaw gets settings grid by ID as an array of bytes
func (g Grid) GetSettingsRaw(ctx context.Context, req GetSettingsRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/grid/getSettings"
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -67,6 +67,12 @@ type DiskUsage struct {
// Detailed information about grid
type RecordGrid struct {
// CKey
CKey string `json:"_ckey"`
// Meta
Meta []interface{} `json:"_meta"`
// AuthBroker
AuthBroker []interface{} `json:"authBroker"`
@@ -133,3 +139,101 @@ type ListEmails struct {
// Entry count
EntryCount uint64 `json:"entryCount"`
}
// Detailed information about grid settings
type RecordSettingsGrid struct {
//Allowed ports
Allowedports []int `json:"allowedports"`
//Cleanup retention period
CleanupRetentionPeriod uint64 `json:"cleanupRetentionPeriod"`
//Docker registry
DockerRegistry DockerRegistry `json:"docker_registry"`
//Enable uptime monitor
EnableUptimeMonitor bool `json:"enableUptimeMonitor"`
//Extnet max prereservation num
ExtnetMaxPreReservationsNum int `json:"extnetMaxPreReservationsNum"`
//Healthcheck notifications
HealthcheckNotifications HealthcheckNotifications `json:"healthcheck_notifications"`
//k8s cleanup enabled
K8sCleanupEnabled bool `json:"k8s_cleanup_enabled"`
//Limits
Limits interface{} `json:"limits"`
//Location url
LocationURL string `json:"location_url"`
//Net QOS
NetQOS NetQOS `json:"net_qos"`
//Networks
Networks string `json:"networks"`
//Prometheus
Prometheus Prometheus `json:"prometheus"`
//Vins max prereservation num
VinsMaxPreReservationsNum int `json:"vinsMaxPreReservationsNum"`
//Vnfdev mgmt net range
VnfdevMgmtNetRange string `json:"vnfdev_mgmt_net_range"`
}
// DockerRegistry in grid settings
type DockerRegistry struct {
//Password
Password string `json:"password"`
//Server
Server string `json:"server"`
//Username
Username string `json:"username"`
}
// NetQOS in grid settings
type NetQOS struct {
// ExtNet Net QOS settings
ExtNet SettingsNetQOS `json:"ext_net"`
// VINS Net QOS settings
VINS SettingsNetQOS `json:"vins"`
}
// SettingsNetQOS in grid settings
type SettingsNetQOS struct {
//ERate
ERate uint64 `json:"eRate"`
//InBurst
InBurst uint64 `json:"inBurst"`
//InRate
InRate uint64 `json:"inRate"`
}
// HealthcheckNotifications settings in grid
type HealthcheckNotifications struct {
//Emails
Emails []Emails `json:"emails"`
}
type Emails struct {
//Address
Address string `json:"address"`
//Enabled
Enabled bool `json:"enabled"`
}
// Prometheus setting in grid
type Prometheus struct {
//ScrapeInterval
ScrapeInterval int `json:"scrapeInterval"`
}

View File

@@ -17,7 +17,7 @@ type SetPasswordPolicyRequest struct {
// Available numbers in the password
// Default value : true
// Required: true
Digits bool `url:"digits" json:"digits"`
Digits interface{} `url:"digits" json:"digits" validate:"isBool"`
// Available special characters in the password
// Default value : false
@@ -27,12 +27,12 @@ type SetPasswordPolicyRequest struct {
// Number of characters in the password
// Default value : 9
// Required: true
PasswordLength uint64 `url:"passwordLength" json:"passwordLength" validate:"required"`
PasswordLength uint64 `url:"passwordLength" json:"passwordLength"`
// Capital letters in the password are available
// Default value : true
// Required: true
Uppercase bool `url:"uppercase" json:"uppercase"`
Uppercase interface{} `url:"uppercase" json:"uppercase" validate:"isBool"`
}
// RemoveCustomBackupPath set set password policy for a grid
@@ -42,6 +42,18 @@ func (g Grid) SetPasswordPolicy(ctx context.Context, req SetPasswordPolicyReques
return false, validators.ValidationErrors(validators.GetErrors(err))
}
if req.PasswordLength == 0 {
req.PasswordLength = 9
}
if req.Digits == nil {
req.Digits = true
}
if req.Uppercase == nil {
req.Uppercase = true
}
url := "/cloudbroker/grid/setPasswordPolicy"
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)

View File

@@ -12,7 +12,7 @@ import (
type ListRequest struct {
// Find by id.
// Requires: false
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
ByID string `url:"by_id,omitempty" json:"by_id,omitempty"`
// Find by list users.
// Required: false

View File

@@ -45,14 +45,13 @@ type CreateCDROMImageRequest struct {
// Binary architecture of this image
// Should be one of:
// - X86_64
// - PPC64_LE
// Required: false
Architecture string `url:"architecture,omitempty" json:"architecture,omitempty"`
// List of types of compute suitable for image.
// Example: [ "KVM_X86" ]
// Required: true
Drivers []string `url:"drivers" json:"drivers" validate:"min=1,max=2,imageDrivers"`
// Required: false
Drivers []string `url:"drivers,omitempty" json:"drivers,omitempty" validate:"max=2,imageDrivers"`
}
// CreateCDROMImage creates CD-ROM image from an ISO identified by URL

View File

@@ -79,7 +79,6 @@ type CreateRequest struct {
// Binary architecture of this image
// Should be one of:
// - X86_64
// - PPC64_LE
// Required: false
Architecture string `url:"architecture,omitempty" json:"architecture,omitempty"`

View File

@@ -13,14 +13,6 @@ type DeleteRequest struct {
// ID of the image to delete
// Required: true
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
// Reason for action
// Required: true
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
// Whether to completely delete the image
// Required: false
Permanently bool `url:"permanently" json:"permanently"`
}
// Delete deletes image by ID

View File

@@ -13,10 +13,6 @@ type DeleteCDROMImageRequest struct {
// ID of the CD-ROM image to delete
// Required: true
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
// Whether to completely delete the CD-ROM image, needs to be unused
// Required: false
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
}
// DeleteCDROMImage deletes a CD-ROM image

View File

@@ -13,14 +13,6 @@ type DeleteImagesRequest struct {
// List of images to be deleted
// Required: true
ImageIDs []uint64 `url:"imageIds" json:"imageIds" validate:"min=1"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
// Whether to completely delete the images
// Required: false
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
}
// DeleteImages deletes images

View File

@@ -69,6 +69,10 @@ type ListRequest struct {
// Page size
// Required: false
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
// Find by enabled True or False
// Required: false
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
}
// List gets list of information about images as a ListImages struct

View File

@@ -18,10 +18,6 @@ type SyncCreateRequest struct {
// Required: true
URL string `url:"url" json:"url" validate:"required"`
// Grid (platform) ID where this template should be create in
// Required: true
GID uint64 `url:"gid" json:"gid" validate:"required"`
// Boot type of image
// Should be one of:
// - bios
@@ -79,7 +75,6 @@ type SyncCreateRequest struct {
// Binary architecture of this image
// Should be one of:
// - X86_64
// - PPC64_LE
// Required: false
Architecture string `url:"architecture,omitempty" json:"architecture,omitempty"`

View File

@@ -29,7 +29,6 @@ type CreateRequest struct {
// Compute driver
// Should be one of:
// - KVM_X86
// - KVM_PPC
// - etc
// Required: true
MasterDriver string `url:"masterDriver" json:"masterDriver" validate:"driver"`
@@ -41,7 +40,6 @@ type CreateRequest struct {
// Compute driver
// Should be one of
// - KVM_X86
// - KVM_PPC
// - etc
// Required: true
WorkerDriver string `url:"workerDriver" json:"workerDriver" validate:"driver"`

View File

@@ -164,6 +164,10 @@ type CreateRequest struct {
// Insert ssl certificate in x509 pem format
// Required: false
OidcCertificate string `url:"oidcCertificate,omitempty" json:"oidcCertificate,omitempty"`
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
}
// GetRAM returns RAM values

View File

@@ -20,7 +20,7 @@ type DeleteMasterFromGroupRequest struct {
// List of Compute IDs of master nodes to delete
// Required: true
MasterIDs []string `url:"masterIds" json:"masterIds" validate:"min=1"`
MasterIDs []uint64 `url:"masterIds" json:"masterIds" validate:"min=1"`
}
// DeleteMasterFromGroup deletes compute from masters group in selected kubernetes cluster

View File

@@ -89,6 +89,15 @@ type RecordK8S struct {
// Deleted time
DeletedTime uint64 `json:"deletedTime"`
// Only external network
ExtnetOnly bool `json:"extnetOnly"`
// Highly available LB
HighlyAvailableLB bool `json:"highlyAvailableLB"`
// Address Virtual Internet Protocol
AddressVIP K8SAddressVIP `json:"addressVip"`
// ID
ID uint64 `json:"id"`
@@ -124,6 +133,18 @@ type RecordK8S struct {
// Updated time
UpdatedTime uint64 `json:"updatedTime"`
// With LB
WithLB bool `json:"withLB"`
}
// Detailed info about address of the Virtual Internet Protocol
type K8SAddressVIP struct {
// Backend IP
BackendIP string `json:"backendIp"`
// Frontend IP
FrontendIP string `json:"frontendIp"`
}
// Detailed info about K8S groups

View File

@@ -21,6 +21,10 @@ type WorkerAddRequest struct {
// How many worker nodes to add
// Required: false
Num uint64 `url:"num,omitempty" json:"num,omitempty"`
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
}
// WorkerAdd adds worker nodes to a kubernetes cluster

View File

@@ -62,6 +62,10 @@ type WorkersGroupAddRequest struct {
// Meta data for working group computes, format YAML "user_data": 1111
// Required: false
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
}
// GetRAM returns RAM field values

View File

@@ -1,8 +0,0 @@
package cloudbroker
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/kvmppc"
// Accessing the KVMPPC method group
func (cb *CloudBroker) KVMPPC() *kvmppc.KVMPPC {
return kvmppc.New(cb.client)
}

View File

@@ -1,210 +0,0 @@
package kvmppc
import (
"context"
"encoding/json"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
type Interface struct {
// Network type
// Should be one of:
// - VINS
// - EXTNET
NetType string `url:"netType" json:"netType" validate:"required,kvmNetType"`
// Network ID for connect to,
// for EXTNET - external network ID,
// for VINS - VINS ID,
NetID uint64 `url:"netId" json:"netId" validate:"required"`
// IP address to assign to this VM when connecting to the specified network
// Required: false
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
}
// DataDisk detailed struct for DataDisks field in CreateRequest, CreateBlankRequest and MassCreateRequest
type DataDisk struct {
// Name for disk
// Required: true
DiskName string `url:"diskName" json:"diskName" validate:"required"`
// Disk size in GB
// Required: true
Size uint64 `url:"size" json:"size" validate:"required"`
// Storage endpoint provider ID
// By default the same with boot disk
// Required: false
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
// Pool name
// By default will be chosen automatically
// Required: false
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
// Optional description
// Required: false
Description string `url:"desc,omitempty" json:"desc,omitempty"`
// Specify image id for create disk from template
// Required: false
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
}
// CreateRequest struct to create KVM PowerPC VM
type CreateRequest struct {
// ID of the resource group, which will own this VM
// Required: true
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
// Name of this VM.
// Must be unique among all VMs (including those in DELETED state) in target resource group
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// Number CPUs to allocate to this VM
// Required: true
CPU uint64 `url:"cpu" json:"cpu" validate:"required"`
// Volume of RAM in MB to allocate to this VM
// Required: true
RAM uint64 `url:"ram" json:"ram" validate:"required"`
// ID of the OS image to base this VM on;
// Could be boot disk image or CD-ROM image
// Required: true
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
// Size of the boot disk in GB
// Required: false
BootDisk uint64 `url:"bootDisk,omitempty" json:"bootDisk,omitempty"`
// ID of SEP to create boot disk on.
// Uses images SEP ID if not set
// Required: false
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
// Pool to use if SEP ID is set, can be also empty if needed to be chosen by system
// Required: false
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
// If not specified, compute will be created without disks.
// To create compute without disks, pass initialized empty slice .
// Required: false
DataDisks []DataDisk `url:"-" json:"dataDisks,omitempty" validate:"omitempty,dive"`
// Slice of structs with net interface description.
// If not specified, compute will be created with default interface from RG.
// To create compute without interfaces, pass initialized empty slice .
// Required: false
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,dive"`
// Input data for cloud-init facility
// Required: false
Userdata string `url:"userdata,omitempty" json:"userdata,omitempty"`
// Text description of this VM
// Required: false
Description string `url:"desc,omitempty" json:"desc,omitempty"`
// Start VM upon success
// Required: false
Start bool `url:"start" json:"start"`
// Stack ID
// Required: false
StackID uint64 `url:"stackId,omitempty" json:"stackId,omitempty"`
// System name
// Required: false
IS string `url:"IS,omitempty" json:"IS,omitempty"`
// Compute purpose
// Required: false
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// GetRAM returns RAM field values
func (r CreateRequest) GetRAM() map[string]uint64 {
res := make(map[string]uint64, 1)
res["RAM"] = r.RAM
return res
}
type wrapperCreateRequest struct {
CreateRequest
Interfaces []string `url:"interfaces,omitempty"`
DataDisks []string `url:"dataDisks,omitempty"`
}
// Create creates KVM PowerPC VM based on specified OS image
func (k KVMPPC) Create(ctx context.Context, req CreateRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
return 0, validators.ValidationErrors(validators.GetErrors(err))
}
var interfaces []string
if req.Interfaces != nil && len(req.Interfaces) != 0 {
interfaces = make([]string, 0, len(req.Interfaces))
for i := range req.Interfaces {
b, err := json.Marshal(req.Interfaces[i])
if err != nil {
return 0, err
}
interfaces = append(interfaces, string(b))
}
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
interfaces = []string{"[]"}
}
var dataDisks []string
if req.DataDisks != nil && len(req.DataDisks) != 0 {
dataDisks = make([]string, 0, len(req.DataDisks))
for i := range req.DataDisks {
b, err := json.Marshal(req.DataDisks[i])
if err != nil {
return 0, err
}
dataDisks = append(dataDisks, string(b))
}
}
reqWrapped := wrapperCreateRequest{
CreateRequest: req,
Interfaces: interfaces,
DataDisks: dataDisks,
}
url := "/cloudbroker/kvmppc/create"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return 0, err
}
result, err := strconv.ParseUint(string(res), 10, 64)
if err != nil {
return 0, err
}
return result, nil
}

View File

@@ -1,135 +0,0 @@
package kvmppc
import (
"context"
"encoding/json"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// CreateBlankRequest struct to create KVM PowerPC VM from scratch
type CreateBlankRequest struct {
// ID of the resource group, which will own this VM
// Required: true
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
// Name of this VM.
// Must be unique among all VMs (including those in DELETED state) in target resource group
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// Number CPUs to allocate to this VM
// Required: true
CPU uint64 `url:"cpu" json:"cpu" validate:"required"`
// Volume of RAM in MB to allocate to this VM
// Required: true
RAM uint64 `url:"ram" json:"ram" validate:"required"`
// Size of the boot disk in GB
// Required: true
BootDisk uint64 `url:"bootDisk" json:"bootDisk" validate:"required"`
// ID of SEP to create boot disk on.
// Uses images SEP ID if not set
// Required: true
SEPID uint64 `url:"sepId" json:"sepId" validate:"required"`
// Pool to use if SEP ID is set, can be also empty if needed to be chosen by system
// Required: true
Pool string `url:"pool" json:"pool" validate:"required"`
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
// If not specified, compute will be created without disks.
// To create compute without disks, pass initialized empty slice .
// Required: false
DataDisks []DataDisk `url:"-" json:"dataDisks,omitempty" validate:"omitempty,dive"`
// Slice of structs with net interface description.
// If not specified, compute will be created with default interface from RG.
// To create compute without interfaces, pass initialized empty slice .
// Required: false
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,dive"`
// Text description of this VM
// Required: false
Description string `url:"desc,omitempty" json:"desc,omitempty"`
}
// GetRAM returns RAM field values
func (r CreateBlankRequest) GetRAM() map[string]uint64 {
res := make(map[string]uint64, 1)
res["RAM"] = r.RAM
return res
}
type wrapperCreateBlankRequest struct {
CreateBlankRequest
Interfaces []string `url:"interfaces,omitempty"`
DataDisks []string `url:"dataDisks,omitempty"`
}
// CreateBlank creates KVM PowerPC VM from scratch
func (k KVMPPC) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
return 0, validators.ValidationErrors(validators.GetErrors(err))
}
var interfaces []string
if req.Interfaces != nil && len(req.Interfaces) != 0 {
interfaces = make([]string, 0, len(req.Interfaces))
for i := range req.Interfaces {
b, err := json.Marshal(req.Interfaces[i])
if err != nil {
return 0, err
}
interfaces = append(interfaces, string(b))
}
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
interfaces = []string{"[]"}
}
var dataDisks []string
if req.DataDisks != nil && len(req.DataDisks) != 0 {
dataDisks = make([]string, 0, len(req.DataDisks))
for i := range req.DataDisks {
b, err := json.Marshal(req.DataDisks[i])
if err != nil {
return 0, err
}
dataDisks = append(dataDisks, string(b))
}
}
reqWrapped := wrapperCreateBlankRequest{
CreateBlankRequest: req,
Interfaces: interfaces,
DataDisks: dataDisks,
}
url := "/cloudbroker/kvmppc/createBlank"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return 0, err
}
result, err := strconv.ParseUint(string(res), 10, 64)
if err != nil {
return 0, err
}
return result, nil
}

View File

@@ -1,16 +0,0 @@
// API to manage KVM PowerPC compute instances (PPC VMs)
package kvmppc
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
// Structure for creating request to KVMPPC
type KVMPPC struct {
client interfaces.Caller
}
// Builder for KVMPPC endpoints
func New(client interfaces.Caller) *KVMPPC {
return &KVMPPC{
client: client,
}
}

View File

@@ -1,156 +0,0 @@
package kvmppc
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// MassCreateRequest struct for mass create KVM PowerPC
type MassCreateRequest struct {
// ID of the resource group, which will own this VM
// Required: true
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
// Name of this VM.
// Must be unique among all VMs (including those in DELETED state) in target resource group
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// Number of VMs
// Required: true
Count uint64 `url:"count" json:"count" validate:"required"`
// Number CPUs to allocate to this VM
// Required: true
CPU uint64 `url:"cpu" json:"cpu" validate:"required"`
// Volume of RAM in MB to allocate to this VM
// Required: true
RAM uint64 `url:"ram" json:"ram" validate:"required"`
// Image ID
// Required: true
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
// Size of the boot disk in GB
// Required: false
BootDisk uint64 `url:"bootDisk,omitempty" json:"bootDisk,omitempty"`
// ID of SEP to create boot disk on.
// Uses images SEP ID if not set
// Required: false
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
// Pool to use if SEP ID is set, can be also empty if needed to be chosen by system
// Required: false
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
// If not specified, compute will be created without disks.
// To create compute without disks, pass initialized empty slice .
// Required: false
DataDisks []DataDisk `url:"-" json:"dataDisks,omitempty" validate:"omitempty,dive"`
// Slice of structs with net interface description.
// If not specified, compute will be created with default interface from RG.
// To create compute without interfaces, pass initialized empty slice.
// Required: false
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,dive"`
// Input data for cloud-init facility
// Required: false
UserData string `url:"userdata,omitempty" json:"userdata,omitempty"`
// Text description of this VM
// Required: false
Description string `url:"desc,omitempty" json:"desc,omitempty"`
// Start after create of not
// Required: false
Start bool `url:"start" json:"start"`
// Reason to action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// GetRAM returns RAM field values
func (r MassCreateRequest) GetRAM() map[string]uint64 {
res := make(map[string]uint64, 1)
res["RAM"] = r.RAM
return res
}
type wrapperMassCreateRequest struct {
MassCreateRequest
Interfaces []string `url:"interfaces,omitempty"`
DataDisks []string `url:"dataDisks,omitempty"`
}
// MassCreate creates KVM PPC computes based on specified OS image
func (k KVMPPC) MassCreate(ctx context.Context, req MassCreateRequest) ([]uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
var interfaces []string
if req.Interfaces != nil && len(req.Interfaces) != 0 {
interfaces = make([]string, 0, len(req.Interfaces))
for i := range req.Interfaces {
b, err := json.Marshal(req.Interfaces[i])
if err != nil {
return nil, err
}
interfaces = append(interfaces, string(b))
}
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
interfaces = []string{"[]"}
}
var dataDisks []string
if req.DataDisks != nil && len(req.DataDisks) != 0 {
dataDisks = make([]string, 0, len(req.DataDisks))
for i := range req.DataDisks {
b, err := json.Marshal(req.DataDisks[i])
if err != nil {
return nil, err
}
dataDisks = append(dataDisks, string(b))
}
}
reqWrapped := wrapperMassCreateRequest{
MassCreateRequest: req,
Interfaces: interfaces,
DataDisks: dataDisks,
}
url := "/cloudbroker/kvmppc/massCreate"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return nil, err
}
computes := make([]uint64, 0)
err = json.Unmarshal(res, &computes)
if err != nil {
return nil, err
}
return computes, nil
}

View File

@@ -15,6 +15,7 @@ type Interface struct {
// - VINS
// - EXTNET
// - VFNIC
// - DPDK
NetType string `url:"netType" json:"netType" validate:"required,kvmx86NetType"`
// Network ID for connect to,
@@ -154,14 +155,14 @@ type CreateRequest struct {
// Default: false
CPUPin bool `url:"cpupin" json:"cpupin"`
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
// 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
// Default: false
HPBacked bool `url:"hpBacked" json:"hpBacked"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// GetRAM returns RAM field values

View File

@@ -64,6 +64,10 @@ type CreateBlankRequest struct {
//Type of compute Stateful (KVM_X86) or Stateless (SVA_KVM_X86)
// Required: false
Driver string `url:"driver,omitempty" json:"driver,omitempty"`
// Type of the emulated system, Q35 or i440fx
// Required: false
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
}
// GetRAM returns RAM field values

View File

@@ -76,9 +76,14 @@ type MassCreateRequest struct {
// Required: false
Start bool `url:"start" json:"start"`
// Reason to action
// Type of the emulated system, Q35 or i440fx
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty"`
}
type asyncWrapperMassCreateRequest struct {
wrapperMassCreateRequest
AsyncMode bool `url:"asyncMode"`
}
// GetRAM returns RAM field values
@@ -142,9 +147,11 @@ func (k KVMX86) MassCreate(ctx context.Context, req MassCreateRequest) ([]uint64
DataDisks: dataDisks,
}
finalReq := asyncWrapperMassCreateRequest{wrapperMassCreateRequest: reqWrapped, AsyncMode: false}
url := "/cloudbroker/kvmx86/massCreate"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, finalReq)
if err != nil {
return nil, err
}
@@ -158,3 +165,67 @@ func (k KVMX86) MassCreate(ctx context.Context, req MassCreateRequest) ([]uint64
return computes, nil
}
// MassCreate creates KVM x86 computes based on specified OS image in async mode
func (k KVMX86) MassCreateAsync(ctx context.Context, req MassCreateRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
var interfaces []string
if req.Interfaces != nil && len(req.Interfaces) != 0 {
interfaces = make([]string, 0, len(req.Interfaces))
for i := range req.Interfaces {
b, err := json.Marshal(req.Interfaces[i])
if err != nil {
return "", err
}
interfaces = append(interfaces, string(b))
}
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
interfaces = []string{"[]"}
}
var dataDisks []string
if req.DataDisks != nil && len(req.DataDisks) != 0 {
dataDisks = make([]string, 0, len(req.DataDisks))
for i := range req.DataDisks {
b, err := json.Marshal(req.DataDisks[i])
if err != nil {
return "", err
}
dataDisks = append(dataDisks, string(b))
}
}
reqWrapped := wrapperMassCreateRequest{
MassCreateRequest: req,
Interfaces: interfaces,
DataDisks: dataDisks,
}
finalReq := asyncWrapperMassCreateRequest{wrapperMassCreateRequest: reqWrapped, AsyncMode: true}
url := "/cloudbroker/kvmx86/massCreate"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, finalReq)
if err != nil {
return "", err
}
var computes string
err = json.Unmarshal(res, &computes)
if err != nil {
return "", err
}
return computes, nil
}

View File

@@ -22,12 +22,16 @@ type CreateRequest struct {
Name string `url:"name" json:"name" validate:"required"`
// External network to connect this load balancer to
// Required: false
ExtNetID uint64 `url:"extnetId" json:"extnetId"`
// Required: true
ExtNetID int64 `url:"extnetId" json:"extnetId" validate:"required"`
// Internal network (VINS) to connect this load balancer to
// Required: false
VINSID uint64 `url:"vinsId" json:"vinsId"`
// Required: true
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
// Start now Load balancer
// Required: true
Start bool `url:"start" json:"start" validate:"required"`
// Custom sysctl values for Load Balancer instance. Applied on boot
// Required: false
@@ -37,10 +41,6 @@ type CreateRequest struct {
// Required: false
HighlyAvailable bool `url:"highlyAvailable,omitempty" json:"highlyAvailable,omitempty"`
// Start now Load balancer
// Required: false
Start bool `url:"start" json:"start"`
// Text description of this load balancer
// Required: false
Description string `url:"desc,omitempty" json:"desc,omitempty"`

View File

@@ -26,7 +26,7 @@ func (ll ListLB) FilterByName(name string) ListLB {
}
// FilterByExtNetID returns ListLB with specified ExtNetID.
func (ll ListLB) FilterByExtNetID(extNetID uint64) ListLB {
func (ll ListLB) FilterByExtNetID(extNetID int64) ListLB {
predicate := func(rlb ItemLBList) bool {
return rlb.ExtNetID == extNetID
}

Some files were not shown because too many files have changed in this diff Show More