/
interfaces_vms.go
68 lines (53 loc) · 1.35 KB
/
interfaces_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package apiv1
type VMsV1 interface {
CreateVM(AgentID, StemcellCID, VMCloudProps, Networks, []DiskCID, VMEnv) (VMCID, error)
DeleteVM(VMCID) error
CalculateVMCloudProperties(VMResources) (VMCloudProps, error)
SetVMMetadata(VMCID, VMMeta) error
HasVM(VMCID) (bool, error)
RebootVM(VMCID) error
GetDisks(VMCID) ([]DiskCID, error)
}
type VMsV2Additions interface {
CreateVMV2(AgentID, StemcellCID, VMCloudProps, Networks, []DiskCID, VMEnv) (VMCID, Networks, error)
}
type VMCloudProps interface {
As(interface{}) error
_final() // interface unimplementable from outside
}
type VMResources struct {
RAM int `json:"ram"`
CPU int `json:"cpu"`
EphemeralDiskSize int `json:"ephemeral_disk_size"`
Audio string `json:"audio"`
}
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}}
}