Commit 84d6d856 authored by Danny Lockard's avatar Danny Lockard

Add the ability to create a SCSI Device as the main HD controller for

virtualbox.
parent 8f5664d2
...@@ -18,6 +18,9 @@ import ( ...@@ -18,6 +18,9 @@ import (
type Driver interface { type Driver interface {
// Create a SATA controller. // Create a SATA controller.
CreateSATAController(vm string, controller string) error CreateSATAController(vm string, controller string) error
// Create a SCSI controller.
CreateSCSIController(vm string, controller string) error
// Delete a VM by name // Delete a VM by name
Delete(string) error Delete(string) error
......
...@@ -36,6 +36,18 @@ func (d *VBox42Driver) CreateSATAController(vmName string, name string) error { ...@@ -36,6 +36,18 @@ func (d *VBox42Driver) CreateSATAController(vmName string, name string) error {
return d.VBoxManage(command...) return d.VBoxManage(command...)
} }
func (d *VBox42Driver) CreateSCSIController(vmName string, name string) error {
command := []string{
"storagectl", vmName,
"--name", name,
"--add", "scsi",
"--controller", "LSILogic",
}
return d.VBoxManage(command...)
}
func (d *VBox42Driver) Delete(name string) error { func (d *VBox42Driver) Delete(name string) error {
return d.VBoxManage("unregistervm", name, "--delete") return d.VBoxManage("unregistervm", name, "--delete")
} }
......
...@@ -9,6 +9,10 @@ type DriverMock struct { ...@@ -9,6 +9,10 @@ type DriverMock struct {
CreateSATAControllerController string CreateSATAControllerController string
CreateSATAControllerErr error CreateSATAControllerErr error
CreateSCSIControllerVM string
CreateSCSIControllerController string
CreateSCSIControllerErr error
DeleteCalled bool DeleteCalled bool
DeleteName string DeleteName string
DeleteErr error DeleteErr error
...@@ -49,6 +53,12 @@ func (d *DriverMock) CreateSATAController(vm string, controller string) error { ...@@ -49,6 +53,12 @@ func (d *DriverMock) CreateSATAController(vm string, controller string) error {
return d.CreateSATAControllerErr return d.CreateSATAControllerErr
} }
func (d *DriverMock) CreateSCSIController(vm string, controller string) error {
d.CreateSCSIControllerVM = vm
d.CreateSCSIControllerController = vm
return d.CreateSCSIControllerErr
}
func (d *DriverMock) Delete(name string) error { func (d *DriverMock) Delete(name string) error {
d.DeleteCalled = true d.DeleteCalled = true
d.DeleteName = name d.DeleteName = name
......
...@@ -158,9 +158,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { ...@@ -158,9 +158,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
} }
} }
if b.config.HardDriveInterface != "ide" && b.config.HardDriveInterface != "sata" { if b.config.HardDriveInterface != "ide" && b.config.HardDriveInterface != "sata" && b.config.HardDriveInterface != "scsi" {
errs = packer.MultiErrorAppend( errs = packer.MultiErrorAppend(
errs, errors.New("hard_drive_interface can only be ide or sata")) errs, errors.New("hard_drive_interface can only be ide, sata, or scsi"))
} }
if b.config.ISOChecksumType == "" { if b.config.ISOChecksumType == "" {
......
...@@ -63,11 +63,24 @@ func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction { ...@@ -63,11 +63,24 @@ func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction {
} }
} }
if config.HardDriveInterface == "scsi" {
if err := driver.CreateSCSIController(vmName, "SCSI Controller"); err != nil {
err := fmt.Errorf("Error creating disk controller: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
}
// Attach the disk to the controller // Attach the disk to the controller
controllerName := "IDE Controller" controllerName := "IDE Controller"
if config.HardDriveInterface == "sata" { if config.HardDriveInterface == "sata" {
controllerName = "SATA Controller" controllerName = "SATA Controller"
} }
if config.HardDriveInterface == "scsi" {
controllerName = "SCSI Controller"
}
command = []string{ command = []string{
"storageattach", vmName, "storageattach", vmName,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment