Files
decort-golang-sdk/pkg/cloudbroker/compute/migrate_storage.go

55 lines
1.4 KiB
Go
Raw Normal View History

2022-12-22 17:56:47 +03:00
package compute
import (
"context"
"net/http"
"strings"
2023-03-24 17:09:30 +03:00
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
2022-12-22 17:56:47 +03:00
)
2023-10-25 17:37:18 +03:00
// MigrateStorageRequest struct for migration
2022-12-22 17:56:47 +03:00
type MigrateStorageRequest struct {
// ID of the compute instance
// Required: true
2023-03-24 17:09:30 +03:00
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
2022-12-22 17:56:47 +03:00
// SEP ID to migrate disks
// Required: true
2023-03-24 17:09:30 +03:00
SEPID uint64 `url:"sepId" json:"sepId" validate:"required"`
2022-12-22 17:56:47 +03:00
// SEP pool name to migrate disks
// Required: true
2023-03-24 17:09:30 +03:00
PoolName string `url:"poolName" json:"poolName" validate:"required"`
2022-12-22 17:56:47 +03:00
2025-12-08 16:16:35 +03:00
// Target node ID
2022-12-22 17:56:47 +03:00
// Required: true
2025-12-08 16:16:35 +03:00
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
2022-12-22 17:56:47 +03:00
// Async API call
// Required: true
2023-03-24 17:09:30 +03:00
Sync bool `url:"sync" json:"sync" validate:"required"`
2022-12-22 17:56:47 +03:00
}
// MigrateStorage gets complex compute migration
2025-12-08 16:16:35 +03:00
// Compute will be migrated to specified node, and compute disks will
2022-12-22 17:56:47 +03:00
// 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) {
2023-03-24 17:09:30 +03:00
err := validators.ValidateRequest(req)
2022-12-22 17:56:47 +03:00
if err != nil {
2023-10-25 17:37:18 +03:00
return "", validators.ValidationErrors(validators.GetErrors(err))
2022-12-22 17:56:47 +03:00
}
url := "/cloudbroker/compute/migrateStorage"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return "", err
}
result := strings.ReplaceAll(string(res), "\"", "")
return result, nil
}