v1.16.7
v1.16.7
This commit is contained in:
@@ -3,6 +3,7 @@ package compute
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
@@ -25,17 +26,48 @@ type MigrateStorageRequest struct {
|
||||
// Target node ID
|
||||
// Required: true
|
||||
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||
}
|
||||
|
||||
// Async API call
|
||||
// Required: true
|
||||
Async interface{} `url:"async_mode" json:"async_mode" validate:"required,isBool"`
|
||||
type wrapperMigrateStorageRequest struct {
|
||||
MigrateStorageRequest
|
||||
AsyncMode bool `url:"async_mode,omitempty"`
|
||||
}
|
||||
|
||||
// MigrateStorage gets complex compute migration
|
||||
// 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) {
|
||||
func (c Compute) MigrateStorage(ctx context.Context, req MigrateStorageRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/migrateStorage"
|
||||
|
||||
aReq := wrapperMigrateStorageRequest{
|
||||
MigrateStorageRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// MigrateStorageAsync gets complex compute migration in async mode
|
||||
// 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) MigrateStorageAsync(ctx context.Context, req MigrateStorageRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
@@ -43,7 +75,12 @@ func (c Compute) MigrateStorage(ctx context.Context, req MigrateStorageRequest)
|
||||
|
||||
url := "/cloudbroker/compute/migrateStorage"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
aReq := wrapperMigrateStorageRequest{
|
||||
MigrateStorageRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user