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 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