This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
doc.go
85 lines (80 loc) · 3.12 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package base
import (
api "github.com/konveyor/forklift-controller/pkg/apis/forklift/v1beta1"
planapi "github.com/konveyor/forklift-controller/pkg/apis/forklift/v1beta1/plan"
"github.com/konveyor/forklift-controller/pkg/apis/forklift/v1beta1/ref"
plancontext "github.com/konveyor/forklift-controller/pkg/controller/plan/context"
core "k8s.io/api/core/v1"
cnv "kubevirt.io/client-go/api/v1"
cdi "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
)
//
// Adapter API.
// Constructs provider-specific implementations
// of the Builder, Client, and Validator.
type Adapter interface {
// Construct builder.
Builder(ctx *plancontext.Context) (Builder, error)
// Construct VM client.
Client(ctx *plancontext.Context) (Client, error)
// Construct validator.
Validator(plan *api.Plan) (Validator, error)
}
//
// Builder API.
// Builds/updates objects as needed with provider
// specific constructs.
type Builder interface {
// Build secret.
Secret(vmRef ref.Ref, in, object *core.Secret) error
// Build DataVolume config map.
ConfigMap(vmRef ref.Ref, secret *core.Secret, object *core.ConfigMap) error
// Build the Kubevirt VirtualMachine spec.
VirtualMachine(vmRef ref.Ref, object *cnv.VirtualMachineSpec, dataVolumes []cdi.DataVolume) error
// Build DataVolumes.
DataVolumes(vmRef ref.Ref, secret *core.Secret, configMap *core.ConfigMap) (dvs []cdi.DataVolumeSpec, err error)
// Build tasks.
Tasks(vmRef ref.Ref) ([]*planapi.Task, error)
// Build template labels.
TemplateLabels(vmRef ref.Ref) (labels map[string]string, err error)
// Return a stable identifier for a DataVolume.
ResolveDataVolumeIdentifier(dv *cdi.DataVolume) string
}
//
// Client API.
// Performs provider-specific actions on the source VM.
type Client interface {
// Power on the source VM.
PowerOn(vmRef ref.Ref) error
// Power off the source VM.
PowerOff(vmRef ref.Ref) error
// Return the source VM's power state.
PowerState(vmRef ref.Ref) (string, error)
// Return whether the source VM is powered off.
PoweredOff(vmRef ref.Ref) (bool, error)
// Create a snapshot of the source VM.
CreateSnapshot(vmRef ref.Ref) (string, error)
// Remove all warm migration snapshots.
RemoveSnapshots(vmRef ref.Ref, precopies []planapi.Precopy) error
// Check if a snapshot is ready to transfer.
CheckSnapshotReady(vmRef ref.Ref, snapshot string) (bool, error)
// Set DataVolume checkpoints.
SetCheckpoints(vmRef ref.Ref, precopies []planapi.Precopy, datavolumes []cdi.DataVolume, final bool) (err error)
// Close connections to the provider API.
Close()
}
//
// Validator API.
// Performs provider-specific validation.
type Validator interface {
// Validate that a VM's disk backing storage has been mapped.
StorageMapped(vmRef ref.Ref) (bool, error)
// Validate that a VM's networks have been mapped.
NetworksMapped(vmRef ref.Ref) (bool, error)
// Validate that a VM's Host isn't in maintenance mode.
MaintenanceMode(vmRef ref.Ref) (bool, error)
// Validate whether warm migration is supported from this provider type.
WarmMigration() bool
// Validate that no more than one of a VM's networks is mapped to the pod network.
PodNetwork(vmRef ref.Ref) (bool, error)
}