You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
decort-golang-sdk/pkg/cloudbroker/compute/start_migration_out.go

59 lines
1.9 KiB

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
}