This commit is contained in:
2025-09-19 13:45:58 +03:00
parent abd35f858c
commit befff7acd9
28 changed files with 900 additions and 82 deletions

View File

@@ -50,6 +50,14 @@ type DiskAddRequest struct {
// Specify image id for create disk from template
// Required: false
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
// Desired PCI slot (hex string, e.g. "0x1A")
// Required: false
PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"`
// Desired bus number (hex string, e.g. "0x03")
// Required: false
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
}
// DiskAdd creates new disk and attach to compute

View File

@@ -21,6 +21,14 @@ type DiskAttachRequest struct {
// Type of the disk B;D
// Required: false
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty"`
// Desired PCI slot (hex string, e.g. "0x1A")
// Required: false
PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"`
// Desired bus number (hex string, e.g. "0x03")
// Required: false
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
}
// DiskAttach attach disk to compute

View File

@@ -20,7 +20,7 @@ type MigrateStorageListRequest struct {
// Sort by one of supported fields, format +|-(field)
// Required: false
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty" validate:"omitempty,sortBy"`
// Page number
// Required: false

View File

@@ -373,9 +373,18 @@ type ItemDisk struct {
// Bus number
BusNumber uint64 `json:"bus_number"`
// Created by
CreatedBy string `json:"createdBy"`
// Created time
CreatedTime uint64 `json:"createdTime"`
// Device name
DeviceName string `json:"devicename"`
// Deleted by
DeletedBy string `json:"deletedBy"`
// Deleted time
DeletedTime uint64 `json:"deletedTime"`
@@ -495,6 +504,9 @@ type ItemDisk struct {
// Updated by
UpdatedBy string `json:"updatedBy"`
// UpdatedTime
UpdatedTime uint64 `json:"updatedTime"`
}
type ItemReplication struct {
@@ -980,12 +992,15 @@ type RecordCompute struct {
// Image ID
ImageID uint64 `json:"imageId"`
// ImageName
// Image name
ImageName string `json:"imageName"`
// List interfaces
Interfaces ListInterfaces `json:"interfaces"`
// Loader meta iso information
LoaderMetaIso LoaderMetaIso `json:"loaderMetaIso"`
// Live migration job ID
LiveMigrationJobID uint64 `json:"live_migration_job_id"`
@@ -1125,6 +1140,14 @@ type RecordCompute struct {
ZoneID uint64 `json:"zoneId"`
}
type LoaderMetaIso struct {
// Name
DeviceName string `json:"devicename"`
// Path
Path string `json:"path"`
}
type VGPUItem struct {
// ID
ID uint64 `json:"id"`

View File

@@ -0,0 +1,58 @@
package compute
import (
"context"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// StartMigrationOutRequest struct to start compute for external migration out
type StartMigrationOutRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
// Remote libvirt host to connect to
// Required: true
Target string `url:"target" json:"target" validate:"required"`
// Graphics handling on the destination
// Required: true
Graphics string `url:"graphics" json:"graphics" validate:"required"`
// Optional new domain name on the destination
// Required: false
NewName string `url:"new_name,omitempty" json:"new_name,omitempty"`
// When true, adds libvirt's UNSAFE flag to force migration even if libvirt marks it unsafe.
// Default: false
// Required: false
UseUnsafe bool `url:"use_unsafe,omitempty" json:"use_unsafe,omitempty"`
// Mapping of guest disk target names to absolute paths on the destination host.
// Required: false
Diskmap map[string]string `url:"diskmap,omitempty" json:"diskmap,omitempty"`
// Mapping for CD/DVD devices or their source paths to new ISO/device paths on the destination
// Required: false
CDROMMap map[string]string `url:"cdrommap,omitempty" json:"cdrommap,omitempty"`
}
// StartMigrationOut starts compute for external migration out
func (c Compute) StartMigrationOut(ctx context.Context, req StartMigrationOutRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/compute/start_migration_out"
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -4,9 +4,26 @@ import (
"context"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// OSUsers struct contains OS user data for Guest OS.
// Must be provided if NewVMUUID is provided.
type OSUser struct {
// Login of a user
Login string `url:"login,omitempty" json:"login,omitempty"`
// Password of a user
Password string `url:"password,omitempty" json:"password,omitempty"`
// GUID
GUID string `url:"guid,omitempty" json:"guid,omitempty"`
// Pubkey
Pubkey string `url:"pubkey,omitempty" json:"pubkey,omitempty"`
}
// StopMigrationINRequest struct to stop compute for external migration in
type StopMigrationINRequest struct {
// ID of compute instance
@@ -16,10 +33,14 @@ type StopMigrationINRequest struct {
// If provided, indicates the UUID of the VM on the target host and that migration completed.
// Required: false
NewVMUUID string `url:"new_vm_uuid,omitempty" json:"new_vm_uuid,omitempty"`
// OS user data for Guest OS
// Required: false
OSUsers []OSUser `url:"os_users,omitempty" json:"os_users,omitempty"`
}
// StopMigrationIN stops compute for external migration in
func (c Compute) StopMigrationIN(ctx context.Context, req StartRequest) (string, error) {
func (c Compute) StopMigrationIN(ctx context.Context, req StopMigrationINRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
@@ -27,7 +48,7 @@ func (c Compute) StopMigrationIN(ctx context.Context, req StartRequest) (string,
url := "/cloudbroker/compute/stop_migration_in"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return "", err
}

View File

@@ -0,0 +1,37 @@
package compute
import (
"context"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// StopMigrationOutRequest struct to stop compute for external migration out
type StopMigrationOutRequest struct {
// ID of compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Identifier of the agent-side external migration (LibvirtMigrateToURI3Request) job
// Required: false
MigrateToURI3JobID string `url:"migrate_to_uri3_job_id,omitempty" json:"migrate_to_uri3_job_id,omitempty"`
}
// StopMigrationOut stops compute for external migration out
func (c Compute) StopMigrationOut(ctx context.Context, req StopMigrationOutRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/compute/stop_migration_out"
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return "", err
}
return string(res), nil
}