forked from pitstopcloud/virtualbox-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
160 lines (136 loc) · 3.49 KB
/
types.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package virtualbox
import "net"
type StorageControllerType string
const (
IDE = StorageControllerType("IDE")
SATA = StorageControllerType("SATA")
SCSCI = StorageControllerType("SCSCI")
NVME = StorageControllerType("NVME")
)
type DiskType string
const DVDDrive = DiskType("dvddrive")
const HDDrive = DiskType("hdd")
const FDDrive = DiskType("fdd")
func (d DiskType) ForShowMedium() string {
switch d {
case DVDDrive:
return "dvd"
case HDDrive:
return "disk"
case FDDrive:
return "floppy"
}
return ""
}
type Disk struct {
// Path represents the absolute path in the system where the disk is stored, normally is under the vm folder
Path string
SizeMB int64
Format DiskFormat
UUID string
Controller StorageControllerAttachment
Type DiskType
NonRotational bool
AutoDiscard bool
}
type StorageControllerAttachment struct {
// Type represents the storage controller, rest of the fields needs to interpreted based on this
Type StorageControllerType
Port int
Device int
// Name of the storage controller target for this attachment
Name string
}
type StorageController struct {
Name string
Type StorageControllerType
Instance int
PortCount int
Bootable string //on, off
}
type CPU struct {
Count int
}
type Memory struct {
SizeMB int
}
type NetworkMode string
const (
NWMode_none = NetworkMode("none")
NWMode_null = NetworkMode("null")
NWMode_nat = NetworkMode("nat")
NWMode_natnetwork = NetworkMode("natnetwork")
NWMode_bridged = NetworkMode("bridged")
NWMode_intnet = NetworkMode("intnet")
NWMode_hostonly = NetworkMode("hostonly")
NWMode_generic = NetworkMode("generic")
)
type NICType string
const (
NIC_Am79C970A = NICType("Am79C970A")
NIC_Am79C973 = NICType("Am79C973")
NIC_82540EM = NICType("82540EM")
NIC_82543GC = NICType("82543GC")
NIC_82545EM = NICType("82545EM")
NIC_virtio = NICType("virtio")
)
type NIC struct {
Index int
// Name string // device name of this nic, used for correlation with Adapters
Mode NetworkMode // nat, hostonly etc
NetworkName string //optional name of the Network to connect this nic to. For hostnetwork and int this is the same as the host device
Type NICType
CableConnected bool
Speedkbps int
BootPrio int
PromiscuousMode string
MAC string
}
type Network struct {
GUID string
Name string
IPNet net.IPNet
Mode NetworkMode
DeviceName string
HWAddress string
}
type BootDevice string
const BOOT_net, BOOT_disk, BOOT_dvd, BOOT_none BootDevice = "net", "disk", "dvd", "none"
type VirtualMachineSpec struct {
// Name identifies the vm and is also used in forming full path, see VBox.BasePath
Name string
Group string
Disks []Disk
CPU CPU
Memory Memory
NICs []NIC
OSType OSType
StorageControllers []StorageController
Boot []BootDevice
}
type VirtualMachine struct {
UUID string
Spec VirtualMachineSpec
}
func (vm *VirtualMachine) UUIDOrName() string {
if vm.UUID == "" {
return vm.Spec.Name
} else {
return vm.UUID
}
}
type DHCPServer struct {
IPAddress string
NetworkName string
NetworkMask string
LowerIPAddress string
UpperIPAddress string
Enabled bool
}
type OSType struct {
ID string
Description string
FamilyID string
FamilyDescription string
Bit64 bool
}