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.
49 lines
1.2 KiB
49 lines
1.2 KiB
|
4 days ago
|
package logicalports
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"encoding/json"
|
||
|
|
"net/http"
|
||
|
|
|
||
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||
|
|
)
|
||
|
|
|
||
|
|
// MigrateStartRequest struct to start migrate
|
||
|
|
type MigrateStartRequest struct {
|
||
|
|
// ID of the logical port
|
||
|
|
// Required: true
|
||
|
|
LogicalPortID string `url:"logical_port_id" json:"logical_port_id" validate:"required"`
|
||
|
|
|
||
|
|
// ID of the version
|
||
|
|
// Required: true
|
||
|
|
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||
|
|
|
||
|
|
// Hypervisor
|
||
|
|
// Required: true
|
||
|
|
TargetHypervisor string `url:"target_hypervisor" json:"target_hypervisor" validate:"required"`
|
||
|
|
}
|
||
|
|
|
||
|
|
func (i LogicalPorts) StartMigrate(ctx context.Context, req MigrateStartRequest) (*MigrationStatus, error) {
|
||
|
|
err := validators.ValidateRequest(req)
|
||
|
|
if err != nil {
|
||
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||
|
|
}
|
||
|
|
|
||
|
|
url := "/sdn/logical_port/migration_start"
|
||
|
|
|
||
|
|
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
info := MigrationStatus{}
|
||
|
|
|
||
|
|
err = json.Unmarshal(res, &info)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
return &info, nil
|
||
|
|
}
|