-
Notifications
You must be signed in to change notification settings - Fork 23
/
cdrom.go
42 lines (35 loc) · 843 Bytes
/
cdrom.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
package portdevices
import (
apiv1 "github.com/cppforlife/bosh-cpi-go/apiv1"
"github.com/cppforlife/bosh-virtualbox-cpi/driver"
)
type CDROM struct {
driver driver.Driver
vmCID apiv1.VMCID
name string // e.g. IDE Controller
port string
device string
}
func (cd CDROM) Mount(isoPath string) error {
_, err := cd.driver.Execute(
"storageattach", cd.vmCID.AsString(),
"--storagectl", cd.name,
"--port", cd.port,
"--device", cd.device,
"--type", "dvddrive",
"--medium", isoPath,
)
return err
}
func (cd CDROM) Unmount() error {
_, err := cd.driver.Execute(
"storageattach", cd.vmCID.AsString(),
"--storagectl", cd.name,
"--port", cd.port,
"--device", cd.device,
"--type", "dvddrive",
// 'emptydrive' removes medium from the drive; 'none' removes the device
"--medium", "emptydrive",
)
return err
}