Merge pull request #108 from smerrill/headless-mode
builder/vmware, builder/virtualbox: Headless mode
This commit is contained in:
commit
67920da4ec
|
@ -30,6 +30,7 @@ type config struct {
|
||||||
DiskSize uint `mapstructure:"disk_size"`
|
DiskSize uint `mapstructure:"disk_size"`
|
||||||
GuestAdditionsPath string `mapstructure:"guest_additions_path"`
|
GuestAdditionsPath string `mapstructure:"guest_additions_path"`
|
||||||
GuestOSType string `mapstructure:"guest_os_type"`
|
GuestOSType string `mapstructure:"guest_os_type"`
|
||||||
|
Headless bool `mapstructure:"headless"`
|
||||||
HTTPDir string `mapstructure:"http_directory"`
|
HTTPDir string `mapstructure:"http_directory"`
|
||||||
HTTPPortMin uint `mapstructure:"http_port_min"`
|
HTTPPortMin uint `mapstructure:"http_port_min"`
|
||||||
HTTPPortMax uint `mapstructure:"http_port_max"`
|
HTTPPortMax uint `mapstructure:"http_port_max"`
|
||||||
|
|
|
@ -23,7 +23,11 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction {
|
||||||
vmName := state["vmName"].(string)
|
vmName := state["vmName"].(string)
|
||||||
|
|
||||||
ui.Say("Starting the virtual machine...")
|
ui.Say("Starting the virtual machine...")
|
||||||
command := []string{"startvm", vmName, "--type", "gui"}
|
guiArgument := "gui"
|
||||||
|
if config.Headless == true {
|
||||||
|
guiArgument = "headless"
|
||||||
|
}
|
||||||
|
command := []string{"startvm", vmName, "--type", guiArgument}
|
||||||
if err := driver.VBoxManage(command...); err != nil {
|
if err := driver.VBoxManage(command...); err != nil {
|
||||||
err := fmt.Errorf("Error starting VM: %s", err)
|
err := fmt.Errorf("Error starting VM: %s", err)
|
||||||
state["error"] = err
|
state["error"] = err
|
||||||
|
|
|
@ -33,6 +33,7 @@ type config struct {
|
||||||
ISOUrl string `mapstructure:"iso_url"`
|
ISOUrl string `mapstructure:"iso_url"`
|
||||||
VMName string `mapstructure:"vm_name"`
|
VMName string `mapstructure:"vm_name"`
|
||||||
OutputDir string `mapstructure:"output_directory"`
|
OutputDir string `mapstructure:"output_directory"`
|
||||||
|
Headless bool `mapstructure:"headless"`
|
||||||
HTTPDir string `mapstructure:"http_directory"`
|
HTTPDir string `mapstructure:"http_directory"`
|
||||||
HTTPPortMin uint `mapstructure:"http_port_min"`
|
HTTPPortMin uint `mapstructure:"http_port_min"`
|
||||||
HTTPPortMax uint `mapstructure:"http_port_max"`
|
HTTPPortMax uint `mapstructure:"http_port_max"`
|
||||||
|
|
|
@ -22,7 +22,7 @@ type Driver interface {
|
||||||
IsRunning(string) (bool, error)
|
IsRunning(string) (bool, error)
|
||||||
|
|
||||||
// Start starts a VM specified by the path to the VMX given.
|
// Start starts a VM specified by the path to the VMX given.
|
||||||
Start(string) error
|
Start(string, bool) error
|
||||||
|
|
||||||
// Stop stops a VM specified by the path to the VMX given.
|
// Stop stops a VM specified by the path to the VMX given.
|
||||||
Stop(string) error
|
Stop(string) error
|
||||||
|
@ -87,8 +87,13 @@ func (d *Fusion5Driver) IsRunning(vmxPath string) (bool, error) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Fusion5Driver) Start(vmxPath string) error {
|
func (d *Fusion5Driver) Start(vmxPath string, headless bool) error {
|
||||||
cmd := exec.Command(d.vmrunPath(), "-T", "fusion", "start", vmxPath, "gui")
|
guiArgument := "gui"
|
||||||
|
if headless == true {
|
||||||
|
guiArgument = "nogui"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := exec.Command(d.vmrunPath(), "-T", "fusion", "start", vmxPath, guiArgument)
|
||||||
if _, _, err := d.runAndLog(cmd); err != nil {
|
if _, _, err := d.runAndLog(cmd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction {
|
||||||
s.vmxPath = vmxPath
|
s.vmxPath = vmxPath
|
||||||
|
|
||||||
ui.Say("Starting virtual machine...")
|
ui.Say("Starting virtual machine...")
|
||||||
if err := driver.Start(vmxPath); err != nil {
|
if err := driver.Start(vmxPath, config.Headless); err != nil {
|
||||||
err := fmt.Errorf("Error starting VM: %s", err)
|
err := fmt.Errorf("Error starting VM: %s", err)
|
||||||
state["error"] = err
|
state["error"] = err
|
||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
|
|
Loading…
Reference in New Issue