|
|
|
|
@ -11,8 +11,15 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// A driver is able to talk to VirtualBox and perform certain
|
|
|
|
|
// operations with it.
|
|
|
|
|
// operations with it. Some of the operations on here may seem overly
|
|
|
|
|
// specific, but they were built specifically in mind to handle features
|
|
|
|
|
// of the VirtualBox builder for Packer, and to abstract differences in
|
|
|
|
|
// versions out of the builder steps, so sometimes the methods are
|
|
|
|
|
// extremely specific.
|
|
|
|
|
type Driver interface {
|
|
|
|
|
// Create a SATA controller.
|
|
|
|
|
CreateSATAController(vm string, controller string) error
|
|
|
|
|
|
|
|
|
|
// Checks if the VM with the given name is running.
|
|
|
|
|
IsRunning(string) (bool, error)
|
|
|
|
|
|
|
|
|
|
@ -40,6 +47,27 @@ type VBox42Driver struct {
|
|
|
|
|
VBoxManagePath string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (d *VBox42Driver) CreateSATAController(vmName string, name string) error {
|
|
|
|
|
version, err := d.Version()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
portCountArg := "sataportcount"
|
|
|
|
|
if strings.HasPrefix(version, "4.3") {
|
|
|
|
|
portCountArg = "portcount"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
command := []string{
|
|
|
|
|
"storagectl", vmName,
|
|
|
|
|
"--name", name,
|
|
|
|
|
"--add", "sata",
|
|
|
|
|
portCountArg, "1",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return d.VBoxManage(command...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (d *VBox42Driver) IsRunning(name string) (bool, error) {
|
|
|
|
|
var stdout bytes.Buffer
|
|
|
|
|
|
|
|
|
|
|