This commit is contained in:
asteam
2025-12-08 16:16:35 +03:00
parent a267d35ddf
commit f0dee6360a
89 changed files with 455 additions and 1067 deletions

View File

@@ -0,0 +1,41 @@
package compute
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// ChangeReadOnlyRequest defines parameters for toggling read-only mode.
type ChangeReadOnlyRequest struct {
// Compute ID
// Required: true
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
// ReadOnly indicates whether the read-only mode is enabled
// Required: true
ReadOnly bool `url:"read_only" json:"read_only" validate:"required"`
}
// ChangeReadOnly toggles compute read-only mode.
func (c Compute) ChangeReadOnly(ctx context.Context, req ChangeReadOnlyRequest) (bool, error) {
if err := validators.ValidateRequest(req); err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/compute/change_read_only"
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

@@ -65,7 +65,7 @@ var computes = ListComputes{
MigrationJob: 0,
Milestones: 363500,
Name: "test",
PinnedToStack: 1,
PinnedToNode: 1,
RAM: 4096,
ReferenceID: "c7cb19ac-af4a-4067-852f-c5572949207e",
Registered: true,
@@ -127,7 +127,7 @@ var computes = ListComputes{
MigrationJob: 0,
Milestones: 363853,
Name: "compute_2",
PinnedToStack: 1,
PinnedToNode: 1,
RAM: 4096,
ReferenceID: "a542c449-5b1c-4f90-88c5-7bb5f8ae68ff",
Registered: true,

View File

@@ -42,17 +42,17 @@ type ListRequest struct {
// Required: false
IPAddress string `url:"ipAddress,omitempty" json:"ipAddress,omitempty"`
// Find by stack ID
// Find by node ID
// Required: false
StackID uint64 `url:"stackId,omitempty" json:"stackId,omitempty"`
NodeID uint64 `url:"node_id,omitempty" json:"node_id,omitempty"`
// Find by CD image ID
// Required: false
CDImageID uint64 `url:"cdImageId,omitempty" json:"cdImageId,omitempty"`
// Find by stack name
// Find by node name
// Required: false
StackName string `url:"stackName,omitempty" json:"stackName,omitempty"`
NodeName string `url:"nodeName,omitempty" json:"nodeName,omitempty"`
// Find by external network name
// Required: false

View File

@@ -15,9 +15,9 @@ type MigrateRequest struct {
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Particular Stack ID to migrate this compute to
// Particular Node ID to migrate this compute to
// Required: false
TargetStackID uint64 `url:"targetStackId,omitempty" json:"targetStackId,omitempty"`
TargetNodeID uint64 `url:"targetNodeId,omitempty" json:"targetNodeId,omitempty"`
// If live migration fails, destroy compute
// on source node and recreate on the target
@@ -30,7 +30,7 @@ type AsyncWrapperMigrateRequest struct {
SyncMode bool `url:"sync"`
}
// Migrate migrates compute to another stack
// Migrate migrates compute to another node
func (c Compute) Migrate(ctx context.Context, req MigrateRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
@@ -54,7 +54,7 @@ func (c Compute) Migrate(ctx context.Context, req MigrateRequest) (bool, error)
return result, nil
}
// AsyncMigrate migrates compute to another stack in async mode
// AsyncMigrate migrates compute to another node in async mode
func (c Compute) AsyncMigrate(ctx context.Context, req MigrateRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {

View File

@@ -22,9 +22,9 @@ type MigrateStorageRequest struct {
// Required: true
PoolName string `url:"poolName" json:"poolName" validate:"required"`
// Target stack ID
// Target node ID
// Required: true
StackID uint64 `url:"stackId" json:"stackId" validate:"required"`
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
// Async API call
// Required: true
@@ -32,7 +32,7 @@ type MigrateStorageRequest struct {
}
// MigrateStorage gets complex compute migration
// Compute will be migrated to specified stack, and compute disks will
// Compute will be migrated to specified node, and compute disks will
// be migrated to specified SEP to specified pool.
// This action can take up to 84 hours
func (c Compute) MigrateStorage(ctx context.Context, req MigrateStorageRequest) (string, error) {

View File

@@ -804,8 +804,8 @@ type InfoCompute struct {
// Name of OS
OSVersion string `json:"os_version"`
// Pinned to stack
PinnedToStack int64 `json:"pinnedToStack"`
// Pinned to node
PinnedToNode int64 `json:"pinnedToNode"`
// PreferredCPU
PreferredCPU []int64 `json:"preferredCpu"`
@@ -813,6 +813,9 @@ type InfoCompute struct {
// Qemu_quest
QemuQuest QemuQuest `json:"qemu_guest"`
// ReadOnly indicates read-only mode state
ReadOnly bool `json:"read_only"`
// Number of RAM
RAM uint64 `json:"ram"`
@@ -837,11 +840,11 @@ type InfoCompute struct {
// SnapSets
SnapSets ListSnapshots `json:"snapSets"`
// Stack ID
StackID uint64 `json:"stackId"`
// Node ID
NodeID uint64 `json:"nodeId"`
// Stack name
StackName string `json:"stackName"`
// Node name
NodeName string `json:"nodeName"`
// Stateless SEP ID
StatelessSEPID int64 `json:"statelessSepId"`
@@ -1055,9 +1058,6 @@ type RecordCompute struct {
// Name
Name string `json:"name"`
// Node ID
NodeID uint64 `json:"nodeId"`
// Natable VINS ID
NatableVINSID uint64 `json:"natableVinsId"`
@@ -1091,8 +1091,8 @@ type RecordCompute struct {
// Name of OS
OSVersion string `json:"os_version"`
// Pinned to stack
PinnedToStack int64 `json:"pinnedToStack"`
// Pinned to node
PinnedToNode int64 `json:"pinnedToNode"`
// PreferredCPU
PreferredCPU []int64 `json:"preferredCpu"`
@@ -1100,6 +1100,9 @@ type RecordCompute struct {
// Qemu_quest
QemuQuest QemuQuest `json:"qemu_guest"`
// ReadOnly indicates read-only mode state
ReadOnly bool `json:"read_only"`
// Number of RAM
RAM uint64 `json:"ram"`
@@ -1124,11 +1127,11 @@ type RecordCompute struct {
// SnapSets
SnapSets ListSnapshots `json:"snapSets"`
// Stack ID
StackID uint64 `json:"stackId"`
// Node ID
NodeID uint64 `json:"node_id"`
// Stack name
StackName string `json:"stackName"`
// Node name
NodeName string `json:"nodeName"`
// Stateless SEP ID
StatelessSEPID int64 `json:"statelessSepId"`
@@ -1338,8 +1341,8 @@ type ItemPCIDevice struct {
// Resource group ID
RGID uint64 `json:"rgId"`
// Stack ID
StackID uint64 `json:"stackId"`
// Node ID
NodeID uint64 `json:"nodeId"`
// Status
Status string `json:"status"`
@@ -1441,14 +1444,14 @@ type MigrateStorageItem struct {
// Migration process log
Log []string `json:"log"`
// Source stack ID
SourceStackID uint64 `json:"sourceStackId"`
// Source node ID
SourceNodeID uint64 `json:"sourceNodeId"`
// Migration status
Status string `json:"status"`
// Target stack ID
TargetStackID uint64 `json:"targetStackId"`
// Target node ID
TargetNodeID uint64 `json:"targetNodeId"`
}
type RecordCloneStatus struct {

View File

@@ -8,15 +8,15 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// PinToStackRequest struct to pin compute to stack
type PinToStackRequest struct {
// PinToNodeRequest struct to pin compute to node
type PinToNodeRequest struct {
// ID of the compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Stack ID to pin to
// Node ID to pin to
// Required: false
TargetStackID uint64 `url:"targetStackId" json:"targetStackId"`
TargetNodeID uint64 `url:"targetNodeId" json:"targetNodeId"`
// Try to migrate or not if compute in running states
// Required: false
@@ -28,14 +28,14 @@ type PinToStackRequest struct {
AutoStart bool `url:"autoStart" json:"autoStart"`
}
// PinToStack pins compute to current stack
func (c Compute) PinToStack(ctx context.Context, req PinToStackRequest) (uint64, error) {
// PinToNode pins compute to current node
func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
return 0, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/compute/pinToStack"
url := "/cloudbroker/compute/pin_to_node"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {

View File

@@ -24,7 +24,7 @@ type RedeployRequest struct {
// Storage policy id of compute. The rules of the specified storage policy will be used.
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
// New size for the boot disk in GB, if boot disk size change is required
// Required: false

View File

@@ -18,9 +18,9 @@ type StartRequest struct {
// Required: false
AltBootID uint64 `url:"altBootId,omitempty" json:"altBootId,omitempty"`
// ID of stack to start compute
// ID of node to start compute
// Required: false
StackID uint64 `url:"stackId,omitempty" json:"stackId,omitempty"`
NodeID uint64 `url:"nodeId,omitempty" json:"nodeId,omitempty"`
}
// Start starts compute

View File

@@ -13,9 +13,9 @@ type StartMigrationINRequest struct {
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// ID of the stack where the compute will be staged for migration-in
// ID of the node where the compute will be staged for migration-in
// Required: false
StackID uint64 `url:"stackId,omitempty" json:"stackId,omitempty"`
NodeID uint64 `url:"node_id,omitempty" json:"node_id,omitempty"`
}
// StartMigrationIN starts compute for external migration in

View File

@@ -8,21 +8,21 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// UnpinFromStackRequest struct to unpin from stack
type UnpinFromStackRequest struct {
// UnpinFromNodeRequest struct to unpin from node
type UnpinFromNodeRequest struct {
// ID of the compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
}
// UnpinFromStack unpins compute from current stack
func (c Compute) UnpinFromStack(ctx context.Context, req UnpinFromStackRequest) (bool, error) {
// UnpinFromNode unpins compute from current node
func (c Compute) UnpinFromNode(ctx context.Context, req UnpinFromNodeRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/compute/unpinFromStack"
url := "/cloudbroker/compute/unpin_from_node"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {