-
Notifications
You must be signed in to change notification settings - Fork 23
/
vm_props.go
47 lines (36 loc) · 926 Bytes
/
vm_props.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
package vm
import (
"errors"
apiv1 "github.com/cppforlife/bosh-cpi-go/apiv1"
)
type SharedFolder struct {
HostPath string `json:"host_path"`
}
type VMProps struct {
Memory int
CPUs int
EphemeralDisk int `json:"ephemeral_disk"`
Audio string `json:"audio"`
GUI bool
ParavirtProvider string `json:"paravirtprovider"`
SharedFolders []SharedFolder `json:"shared_folders"`
}
func NewVMProps(props apiv1.VMCloudProps) (VMProps, error) {
vmProps := VMProps{
Memory: 512,
CPUs: 1,
EphemeralDisk: 5000,
Audio: "none",
ParavirtProvider: "minimal", // KVM caused CPU lockups with 4+ kernel
}
err := props.As(&vmProps)
if err != nil {
return VMProps{}, err
}
for _, folder := range vmProps.SharedFolders {
if folder.HostPath == "" {
return VMProps{}, errors.New("Expected host paths not to be empty")
}
}
return vmProps, nil
}