/
vms.go
54 lines (42 loc) · 924 Bytes
/
vms.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
package apiv1
type VMs interface {
CreateVM(AgentID, StemcellCID, VMCloudProps, Networks, []DiskCID, VMEnv) (VMCID, error)
DeleteVM(VMCID) error
SetVMMetadata(VMCID, VMMeta) error
HasVM(VMCID) (bool, error)
RebootVM(VMCID) error
GetDisks(VMCID) ([]DiskCID, error)
}
type VMCloudProps interface {
As(interface{}) error
}
type VMCID struct {
cloudID
}
type AgentID struct {
cloudID
}
type VMMeta struct {
cloudKVs
}
type VMEnv struct {
cloudKVs
}
func NewVMCID(cid string) VMCID {
if cid == "" {
panic("Internal incosistency: VM CID must not be empty")
}
return VMCID{cloudID{cid}}
}
func NewAgentID(id string) AgentID {
if id == "" {
panic("Internal incosistency: Agent ID must not be empty")
}
return AgentID{cloudID{id}}
}
func NewVMMeta(meta map[string]interface{}) VMMeta {
return VMMeta{cloudKVs{meta}}
}
func NewVMEnv(env map[string]interface{}) VMEnv {
return VMEnv{cloudKVs{env}}
}