This commit is contained in:
2026-10-16 15:23:28 +03:00
parent 8cde0e9371
commit 84164a72a4
32 changed files with 1019 additions and 260 deletions

View File

@@ -26,6 +26,8 @@ type wrapperCreateTemplateRequest struct {
}
// CreateTemplate create template from compute instance
//
// Deprecated: will be removed in SDK v1.17
func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {

View File

@@ -56,6 +56,8 @@ type wrapperCreateTemplateFromBlankRequest struct {
// CreateTemplateFromBlank creates template from boot disk of current compute in sync mode.
// It returns id of created compute and error.
//
// Deprecated: will be removed in SDK v1.17
func (c Compute) CreateTemplateFromBlank(ctx context.Context, req CreateTemplateFromBlankRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
@@ -84,6 +86,8 @@ func (c Compute) CreateTemplateFromBlank(ctx context.Context, req CreateTemplate
// CreateTemplateFromBlankAsync creates template from boot disk of current compute in async mode.
// It returns guid of task and error.
//
// Deprecated: will be removed in SDK v1.17
func (c Compute) CreateTemplateFromBlankAsync(ctx context.Context, req CreateTemplateFromBlankRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {

View File

@@ -21,8 +21,8 @@ type ChangeDiskStoragePolicyRequest struct {
// Keep current disk I/O tune settings in the domain XML
// Required: false
// Default: false
KeepCurrentIOTune interface{} `url:"keep_current_iot,omitempty" json:"keep_current_iot,omitempty" validate:"omitempty,isBool"`
// Default: false
KeepCurrentIOTune interface{} `url:"keep_current_iotune,omitempty" json:"keep_current_iotune,omitempty" validate:"omitempty,isBool"`
}
type wrapperChangeDiskStoragePolicyRequest struct {

View File

@@ -55,6 +55,8 @@ type wrapperFromPlatformDiskRequest struct {
// FromPlatformDisk creates template from platform disk in sync mode.
// It returns id of created disk and error.
//
// Deprecated: will be removed in SDK v1.17
func (d Disks) FromPlatformDisk(ctx context.Context, req FromPlatformDiskRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
@@ -83,6 +85,8 @@ func (d Disks) FromPlatformDisk(ctx context.Context, req FromPlatformDiskRequest
// FromPlatformDiskAsync creates template from platform disk in async mode.
// It returns guid of task and error.
//
// Deprecated: will be removed in SDK v1.17
func (d Disks) FromPlatformDiskAsync(ctx context.Context, req FromPlatformDiskRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {

View File

@@ -0,0 +1,139 @@
package image
import (
"context"
"encoding/json"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// CreateFromDiskRequest to create image from existing disk
type CreateFromDiskRequest struct {
// Name of the new image
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// ID of the source disk to create image from
// Required: true
DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"`
// Boot type of the image (bios or uefi)
// Required: true
// Options:
// - bios
// - uefi
BootType string `url:"boot_type" json:"boot_type" validate:"required,imageBootType"`
// Type of the operating system
// Required: true
// Options:
// - linux
// - windows
// - unknown
ImageType string `url:"image_type" json:"image_type" validate:"required,imageType"`
// ID of the storage policy to apply
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
// Network interface naming pattern for Linux machines. eth - onboard naming, ens - PCI slot naming.
// Required: false
// Default: ens
// Options:
// - eth
// - ens
NetworkInterfaceNaming string `url:"network_interface_naming,omitempty" json:"network_interface_naming,omitempty" validate:"omitempty,networkInterfaceNaming"`
// Whether the image supports hot resize (online resizing)
// Required: false
// Default: false
HotResize interface{} `url:"hot_resize,omitempty" json:"hot_resize,omitempty" validate:"omitempty,isBool"`
// Default username for VMs created from this image
// Required: false
UserName string `url:"user_name,omitempty" json:"user_name,omitempty"`
// Default password for the default user
// Required: false
Password string `url:"password,omitempty" json:"password,omitempty"`
// Account ID to grant exclusive access to the image
// Required: false
AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"`
// Target SEP ID where the image will be created. If not specified, the best SEP will be selected based on storage policy.
// Required: false
SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"`
// Target pool name in the SEP. If not specified, the best pool will be selected automatically.
// Required: false
PoolName string `url:"pool_name,omitempty" json:"pool_name,omitempty"`
// Whether the image is bootable
// Required: false
// Default: true
Bootable interface{} `url:"bootable,omitempty" json:"bootable,omitempty" validate:"omitempty,isBool"`
}
type wrapperCreateFromDiskRequest struct {
CreateFromDiskRequest
AsyncMode bool `url:"async_mode" json:"async_mode" validate:"omitempty,isBool"`
}
// CreateFromDisk creates image from existing disk
func (i Image) CreateFromDisk(ctx context.Context, req CreateFromDiskRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
return 0, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/image/create_from_disk"
aReq := wrapperCreateFromDiskRequest{
CreateFromDiskRequest: req,
AsyncMode: false,
}
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
if err != nil {
return 0, err
}
result, err := strconv.ParseUint(string(res), 10, 64)
if err != nil {
return 0, err
}
return result, nil
}
// CreateFromDiskAsync creates image from existing disk in async mode
func (i Image) CreateFromDiskAsync(ctx context.Context, req CreateFromDiskRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/image/create_from_disk"
aReq := wrapperCreateFromDiskRequest{
CreateFromDiskRequest: req,
AsyncMode: true,
}
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
if err != nil {
return "", err
}
var resp string
err = json.Unmarshal(res, &resp)
if err != nil {
return "", err
}
return resp, nil
}

View File

@@ -168,6 +168,7 @@ type CloudBrokerEndpoints struct {
AuditCollector interface{} `json:"auditcollector,omitempty"`
Backup interface{} `json:"backup,omitempty"`
BackupCreator interface{} `json:"backupcreator,omitempty"`
BasisMPM interface{} `json:"basis_mpm,omitempty"`
BService interface{} `json:"bservice,omitempty"`
Compute interface{} `json:"compute,omitempty"`
Disks interface{} `json:"disks,omitempty"`

View File

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

View File

@@ -0,0 +1,17 @@
package basismpm
import (
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
)
// Structure for creating request to Basis mpm
type BasisMPM struct {
client interfaces.Caller
}
// BasisMPM for Basis mpm endpoints
func New(client interfaces.Caller) *BasisMPM {
return &BasisMPM{
client: client,
}
}

View File

@@ -0,0 +1,36 @@
package basismpm
type MemInfo struct {
// Total amount of memory
MemTotal string `json:"MemTotal"`
// Amount of free memory
MemFree string `json:"MemFree"`
// Amount of available memory
MemAvailable string `json:"MemAvailable"`
// Amount of available memory (in percent)
MemAvailablePercent float64 `json:"MemAvailablePercent"`
}
// Basis MPM service status
type RecordBasisMPM struct {
// Whether the service is installed
ServiceInstalled bool `json:"service_installed"`
// Whether the config exists
ConfigExists bool `json:"config_exists"`
// Whether the service is active
ServiceActive bool `json:"service_active"`
// Service state
ServiceState string `json:"service_state"`
// Config
Config interface{} `json:"config"`
// Memory info
MemInfo MemInfo `json:"meminfo"`
}

View File

@@ -0,0 +1,114 @@
package basismpm
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// StartRequest to start basis_mpm service on a node
type StartRequest struct {
// Node ID
// Required: true
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
// Memory pressure threshold (%)
// Required: false
// Default: 20
PressureThreshold uint64 `url:"pressure_threshold,omitempty" json:"pressure_threshold,omitempty" validate:"omitempty,pressureThreshold"`
// Deflate threshold (%)
// Required: false
// Default: 30
DeflateThreshold uint64 `url:"deflate_threshold,omitempty" json:"deflate_threshold,omitempty" validate:"omitempty,deflateThreshold"`
// Host reserved memory
// Required: false
// Default: "8GB+5%"
HostReserved string `url:"host_reserved,omitempty" json:"host_reserved,omitempty"`
// Buffer percentage (%)
// Required: false
// Default: 20
BufferPCT uint64 `url:"buffer_pct,omitempty" json:"buffer_pct,omitempty" validate:"omitempty,bufferPCT"`
// Guaranteed memory percentage (%)
// Required: false
// Default: 25
GuaranteedPCT uint64 `url:"guaranteed_pct,omitempty" json:"guaranteed_pct,omitempty" validate:"omitempty,guaranteedPCT"`
// Absolute minimum guaranteed memory (MB)
// Required: false
// Default: 512
GuaranteedABSMin uint64 `url:"guaranteed_abs_min,omitempty" json:"guaranteed_abs_min,omitempty" validate:"omitempty,guaranteedABSMin"`
// Shrink threshold percentage (%)
// Required: false
// Default: 50
ShrinkThresholdPCT uint64 `url:"shrink_threshold_pct,omitempty" json:"shrink_threshold_pct,omitempty" validate:"omitempty,shrinkThresholdPCT"`
// Max shrink percentage per cycle (%)
// Required: false
// Default: 10
BalloonMaxShrinkPCT uint64 `url:"balloon_max_shrink_pct,omitempty" json:"balloon_max_shrink_pct,omitempty" validate:"omitempty,balloonMaxShrinkPCT"`
// Max grow percentage per cycle (%)
// Required: false
// Default: 10
BalloonMaxGrowPCT uint64 `url:"balloon_max_grow_pct,omitempty" json:"balloon_max_grow_pct,omitempty" validate:"omitempty,balloonMaxGrowPCT"`
// VM change cooldown (seconds)
// Required: false
// Default: 60
VMChangeCooldown uint64 `url:"vm_change_cooldown,omitempty" json:"vm_change_cooldown,omitempty" validate:"omitempty,vmChangeCooldown"`
// Emergency return cooldown (seconds)
// Required: false
// Default: 300
EmergencyReturnCooldown uint64 `url:"emergency_return_cooldown,omitempty" json:"emergency_return_cooldown,omitempty"`
// Major fault increase per cycle that triggers emergency memory return
// Required: false
// Default: 100
MajorFaultThreshold uint64 `url:"major_fault_threshold,omitempty" json:"major_fault_threshold,omitempty" validate:"omitempty,majorFaultThreshold"`
// Daemon log level
// Required: false
// Default: INFO
// Options:
// - DEBUG
// - INFO
// - WARNING
// - ERROR
// - CRITICAL
LogLevel string `url:"log_level,omitempty" json:"log_level,omitempty" validate:"omitempty,logLevel"`
// Daemon log file path (empty for stdout only)
// Required: false
LogFile string `url:"log_file,omitempty" json:"log_file,omitempty"`
}
// Start starts basis_mpm service on a node
func (bm BasisMPM) Start(ctx context.Context, req StartRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/basis_mpm/start"
res, err := bm.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, 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,47 @@
package basismpm
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// StatusRequest to get basis_mpm service status on a node
type StatusRequest struct {
// Node ID
// Required: true
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
}
// Status gets basis_mpm service status on a node
func (bm BasisMPM) Status(ctx context.Context, req StatusRequest) (*RecordBasisMPM, error) {
res, err := bm.StatusRaw(ctx, req)
if err != nil {
return nil, err
}
info := RecordBasisMPM{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
// StatusRaw gets basis_mpm service status on a node as an array of bites
func (bm BasisMPM) StatusRaw(ctx context.Context, req StatusRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/basis_mpm/status"
res, err := bm.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
return res, err
}

View File

@@ -0,0 +1,44 @@
package basismpm
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// StopRequest to stop basis_mpm service on a node
type StopRequest struct {
// Node ID
// Required: true
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
// Restore VM memory before stopping
// Required: false
// Default: true
RestoreMemory interface{} `url:"restore_memory,omitempty" json:"restore_memory,omitempty" validate:"omitempty,isBool"`
}
// Stop stops basis_mpm service on a node
func (bm BasisMPM) Stop(ctx context.Context, req StopRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/basis_mpm/stop"
res, err := bm.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, 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,113 @@
package basismpm
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// UpdateRequest to update basis_mpm service configuration on a node
type UpdateRequest struct {
// Node ID
// Required: true
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
// Memory pressure threshold (%)
// Required: false
// Default: 20
PressureThreshold uint64 `url:"pressure_threshold,omitempty" json:"pressure_threshold,omitempty" validate:"omitempty,pressureThreshold"`
// Deflate threshold (%)
// Required: false
// Default: 30
DeflateThreshold uint64 `url:"deflate_threshold,omitempty" json:"deflate_threshold,omitempty" validate:"omitempty,deflateThreshold"`
// Host reserved memory
// Required: false
// Default: "8GB+5%"
HostReserved string `url:"host_reserved,omitempty" json:"host_reserved,omitempty"`
// Buffer percentage (%)
// Required: false
// Default: 20
BufferPCT uint64 `url:"buffer_pct,omitempty" json:"buffer_pct,omitempty" validate:"omitempty,bufferPCT"`
// Guaranteed memory percentage (%)
// Required: false
// Default: 25
GuaranteedPCT uint64 `url:"guaranteed_pct,omitempty" json:"guaranteed_pct,omitempty" validate:"omitempty,guaranteedPCT"`
// Absolute minimum guaranteed memory (MB)
// Required: false
// Default: 512
GuaranteedABSMin uint64 `url:"guaranteed_abs_min,omitempty" json:"guaranteed_abs_min,omitempty" validate:"omitempty,guaranteedABSMin"`
// Shrink threshold percentage (%)
// Required: false
// Default: 50
ShrinkThresholdPCT uint64 `url:"shrink_threshold_pct,omitempty" json:"shrink_threshold_pct,omitempty" validate:"omitempty,shrinkThresholdPCT"`
// Max shrink percentage per cycle (%)
// Required: false
// Default: 10
BalloonMaxShrinkPCT uint64 `url:"balloon_max_shrink_pct,omitempty" json:"balloon_max_shrink_pct,omitempty" validate:"omitempty,balloonMaxShrinkPCT"`
// Max grow percentage per cycle (%)
// Required: false
// Default: 10
BalloonMaxGrowPCT uint64 `url:"balloon_max_grow_pct,omitempty" json:"balloon_max_grow_pct,omitempty" validate:"omitempty,balloonMaxGrowPCT"`
// VM change cooldown (seconds)
// Required: false
// Default: 60
VMChangeCooldown uint64 `url:"vm_change_cooldown,omitempty" json:"vm_change_cooldown,omitempty" validate:"omitempty,vmChangeCooldown"`
// Emergency return cooldown (seconds)
// Required: false
// Default: 300
EmergencyReturnCooldown uint64 `url:"emergency_return_cooldown,omitempty" json:"emergency_return_cooldown,omitempty" validate:"omitempty,emergencyReturnCooldown"`
// Major fault increase per cycle that triggers emergency memory return
// Required: false
// Default: 100
MajorFaultThreshold uint64 `url:"major_fault_threshold,omitempty" json:"major_fault_threshold,omitempty" validate:"omitempty,majorFaultThreshold"`
// Daemon log level
// Required: false
// Default: INFO
// Options:
// - DEBUG
// - INFO
// - WARNING
// - ERROR
// - CRITICAL
LogLevel string `url:"log_level,omitempty" json:"log_level,omitempty" validate:"omitempty,logLevel"`
// Daemon log file path (empty for stdout only)
// Required: false
LogFile string `url:"log_file,omitempty" json:"log_file,omitempty"`
}
func (bm BasisMPM) Update(ctx context.Context, req UpdateRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/basis_mpm/update"
res, err := bm.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, 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,6 +26,8 @@ type wrapperCreateTemplateRequest struct {
}
// CreateTemplate create template from compute instance
//
// Deprecated: will be removed in SDK v1.17
func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
@@ -50,6 +52,8 @@ func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest)
}
// CreateTemplateAsync create template from compute instance with AsyncMode
//
// Deprecated: will be removed in SDK v1.17
func (c Compute) CreateTemplateAsync(ctx context.Context, req CreateTemplateRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {

View File

@@ -60,6 +60,8 @@ type wrapperCreateTemplateFromBlankRequest struct {
// CreateTemplateFromBlank creates template from boot disk of current compute in sync mode.
// It returns id of created compute and error.
//
// Deprecated: will be removed in SDK v1.17
func (c Compute) CreateTemplateFromBlank(ctx context.Context, req CreateTemplateFromBlankRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
@@ -88,6 +90,8 @@ func (c Compute) CreateTemplateFromBlank(ctx context.Context, req CreateTemplate
// CreateTemplateFromBlankAsync creates template from boot disk of current compute in async mode.
// It returns guid of task and error.
//
// Deprecated: will be removed in SDK v1.17
func (c Compute) CreateTemplateFromBlankAsync(ctx context.Context, req CreateTemplateFromBlankRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {

View File

@@ -23,7 +23,8 @@ type Target struct {
// Required: false
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
// Disk IDs
// Disk IDs. May be omitted if Targets contains one element (all persistent disks are migrated).
// Required if Targets contains two or more elements; disk IDs must not overlap between targets.
// Required: false
DiskIDs []uint64 `url:"disk_ids,omitempty" json:"disk_ids,omitempty"`
}
@@ -31,8 +32,8 @@ type Target struct {
// Storage describes a destination for a disk
type Storage struct {
// Target for migration
// Required: false
Targets []Target `url:"targets,omitempty" json:"targets,omitempty"`
// Required: true
Targets []Target `url:"targets" json:"targets" validate:"required,min=1,dive"`
// Whether a separate source-disk cleanup job should be started after full success
// Required: false
@@ -55,7 +56,7 @@ type MigrateV2Request struct {
// Destination for a disk
// Required: false
Storage Storage `url:"storage,omitempty" json:"storage,omitempty"`
Storage *Storage `url:"storage,omitempty" json:"storage,omitempty"`
}
// MigrateV2 starts a migration of a compute or a disk

View File

@@ -18,6 +18,10 @@ type MigrateV2ResolveRequest struct {
// Take over cleanup
// Required: false
TakeOverCleanup interface{} `url:"take_over_cleanup,omitempty" json:"take_over_cleanup,omitempty" validate:"omitempty,isBool"`
// Take over resources
// Required: false
TakeOverResources interface{} `url:"take_over_resources,omitempty" json:"take_over_resources,omitempty" validate:"omitempty,isBool"`
}
// MigrateV2Resolve resolves a migration of a compute

View File

@@ -2315,7 +2315,7 @@ type Origin struct {
type Observation struct {
// Updated at
UpdatedAt uint64 `json:"updated_at"`
UpdatedAt float64 `json:"updated_at"`
// Agent job ID
AgentJobID string `json:"agent_job_id"`
@@ -2329,13 +2329,13 @@ type Observation struct {
type Memory struct {
// Sampled at
SampledAt uint64 `json:"sampled_at"`
SampledAt float64 `json:"sampled_at"`
// Percent
Percent uint64 `json:"percent"`
Percent float64 `json:"percent"`
// Bytes per second
BytesPerSecond uint64 `json:"bytes_per_second"`
BytesPerSecond float64 `json:"bytes_per_second"`
// Processed bytes
ProcessedBytes uint64 `json:"processed_bytes"`
@@ -2352,19 +2352,59 @@ type ProgressDisks struct {
TargetDevs []string `json:"target_devs"`
// Sampled at
SampledAt uint64 `json:"sampled_at"`
SampledAt float64 `json:"sampled_at"`
// Percent
Percent uint64 `json:"percent"`
Percent float64 `json:"percent"`
// Bytes per second
BytesPerSecond uint64 `json:"bytes_per_second"`
BytesPerSecond float64 `json:"bytes_per_second"`
// Processed bytes
ProcessedBytes uint64 `json:"processed_bytes"`
// Remaining bytes
RemainingBytes uint64 `json:"remaining_bytes"`
// Disks completed
DisksCompleted uint64 `json:"disks_completed"`
// Completed disks
CompletedDisks []CompletedDisk `json:"completed_disks"`
// Disks total
DisksTotal uint64 `json:"disks_total"`
// Current disk
CurrentDisk CurrentDisk `json:"current_disk"`
}
type CompletedDisk struct {
// Source disk ID
SourceDiskID uint64 `json:"source_disk_id"`
// Target disk ID
TargetDiskID uint64 `json:"target_disk_id"`
// Target dev
TargetDev string `json:"target_dev"`
}
type CurrentDisk struct {
// Source disk ID
SourceDiskID uint64 `json:"source_disk_id"`
// Target disk ID
TargetDiskID uint64 `json:"target_disk_id"`
// Target dev
TargetDev string `json:"target_dev"`
// Percent
Percent float64 `json:"percent"`
// Sampled at
SampledAt float64 `json:"sampled_at"`
}
type SystemDisk struct {
@@ -2372,13 +2412,13 @@ type SystemDisk struct {
TargetDev string `json:"target_dev"`
// Sampled at
SampledAt uint64 `json:"sampled_at"`
SampledAt float64 `json:"sampled_at"`
// Percent
Percent uint64 `json:"percent"`
Percent float64 `json:"percent"`
// Bytes per second
BytesPerSecond uint64 `json:"bytes_per_second"`
BytesPerSecond float64 `json:"bytes_per_second"`
// Processed bytes
ProcessedBytes uint64 `json:"processed_bytes"`
@@ -2448,12 +2488,18 @@ type Resolution struct {
// Take over cleanup
TakeOverCleanup bool `json:"take_over_cleanup"`
// Take over resources
TakeOverResources bool `json:"take_over_resources"`
// Previous status
PreviousStatus string `json:"previous_status"`
// Previous cleanup required
PreviousCleanupRequired bool `json:"previous_cleanup_required"`
// Previous reserves compute resources
PreviousReservesComputeResources bool `json:"previous_reserves_compute_resources"`
// Previous error
PreviousError string `json:"previous_error"`
}
@@ -2607,6 +2653,9 @@ type MigrateV2ResolveRecord struct {
// Cleanup required
CleanupRequired bool `json:"cleanup_required"`
// Message
Message string `json:"message"`
// Resolution
Resolution Resolution `json:"resolution"`
}

View File

@@ -21,8 +21,8 @@ type ChangeDiskStoragePolicyRequest struct {
// Keep current disk I/O tune settings in the domain XML
// Required: false
// Default: false
KeepCurrentIOTune interface{} `url:"keep_current_iot,omitempty" json:"keep_current_iot,omitempty" validate:"omitempty,isBool"`
// Default: false
KeepCurrentIOTune interface{} `url:"keep_current_iotune,omitempty" json:"keep_current_iotune,omitempty" validate:"omitempty,isBool"`
}
type wrapperChangeDiskStoragePolicyRequest struct {

View File

@@ -59,6 +59,8 @@ type wrapperFromPlatformDiskRequest struct {
// FromPlatformDisk creates template from platform disk in sync mode.
// It returns id of created disk and error.
//
// Deprecated: will be removed in SDK v1.17
func (d Disks) FromPlatformDisk(ctx context.Context, req FromPlatformDiskRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
@@ -87,6 +89,8 @@ func (d Disks) FromPlatformDisk(ctx context.Context, req FromPlatformDiskRequest
// FromPlatformDiskAsync creates template from platform disk in async mode.
// It returns guid of task and error.
//
// Deprecated: will be removed in SDK v1.17
func (d Disks) FromPlatformDiskAsync(ctx context.Context, req FromPlatformDiskRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {

View File

@@ -0,0 +1,139 @@
package image
import (
"context"
"encoding/json"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// CreateFromDiskRequest to create image from existing disk
type CreateFromDiskRequest struct {
// Name of the new image
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// ID of the source disk to create image from
// Required: true
DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"`
// Boot type of the image (bios or uefi)
// Required: true
// Options:
// - bios
// - uefi
BootType string `url:"boot_type" json:"boot_type" validate:"required,imageBootType"`
// Type of the operating system
// Required: true
// Options:
// - linux
// - windows
// - unknown
ImageType string `url:"image_type" json:"image_type" validate:"required,imageType"`
// ID of the storage policy to apply
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
// Network interface naming pattern for Linux machines. eth - onboard naming, ens - PCI slot naming.
// Required: false
// Default: ens
// Options:
// - eth
// - ens
NetworkInterfaceNaming string `url:"network_interface_naming,omitempty" json:"network_interface_naming,omitempty" validate:"omitempty,networkInterfaceNaming"`
// Whether the image supports hot resize (online resizing)
// Required: false
// Default: false
HotResize interface{} `url:"hot_resize,omitempty" json:"hot_resize,omitempty" validate:"omitempty,isBool"`
// Default username for VMs created from this image
// Required: false
UserName string `url:"user_name,omitempty" json:"user_name,omitempty"`
// Default password for the default user
// Required: false
Password string `url:"password,omitempty" json:"password,omitempty"`
// Account ID to grant exclusive access to the image
// Required: false
AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"`
// Target SEP ID where the image will be created. If not specified, the best SEP will be selected based on storage policy.
// Required: false
SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"`
// Target pool name in the SEP. If not specified, the best pool will be selected automatically.
// Required: false
PoolName string `url:"pool_name,omitempty" json:"pool_name,omitempty"`
// Whether the image is bootable
// Required: false
// Default: true
Bootable interface{} `url:"bootable,omitempty" json:"bootable,omitempty" validate:"omitempty,isBool"`
}
type wrapperCreateFromDiskRequest struct {
CreateFromDiskRequest
AsyncMode bool `url:"async_mode" json:"async_mode" validate:"omitempty,isBool"`
}
// CreateFromDisk creates image from existing disk
func (i Image) CreateFromDisk(ctx context.Context, req CreateFromDiskRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
return 0, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/image/create_from_disk"
aReq := wrapperCreateFromDiskRequest{
CreateFromDiskRequest: req,
AsyncMode: false,
}
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
if err != nil {
return 0, err
}
result, err := strconv.ParseUint(string(res), 10, 64)
if err != nil {
return 0, err
}
return result, nil
}
// CreateFromDiskAsync creates image from existing disk in async mode
func (i Image) CreateFromDiskAsync(ctx context.Context, req CreateFromDiskRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/image/create_from_disk"
aReq := wrapperCreateFromDiskRequest{
CreateFromDiskRequest: req,
AsyncMode: true,
}
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
if err != nil {
return "", err
}
var resp string
err = json.Unmarshal(res, &resp)
if err != nil {
return "", err
}
return resp, nil
}

View File

@@ -192,6 +192,9 @@ type RecordZone struct {
// Minimal level of logs
LoggingLevel string `json:"logging_level"`
// DRS port seed
DRSPortSeed uint64 `json:"drs_port_seed"`
}
// A zone item from a list
@@ -279,4 +282,7 @@ type ItemZone struct {
// Minimal level of logs
LoggingLevel string `json:"logging_level"`
// DRS port seed
DRSPortSeed uint64 `json:"drs_port_seed"`
}