Merge remote-tracking branch 'upstream/master' into provisioner-chef-solo
This commit is contained in:
commit
695d3ea9f5
|
@ -5,6 +5,10 @@ FEATURES:
|
|||
* VirtualBox and VMware can now have `floppy_files` specified to attach
|
||||
floppy disks when booting. This allows for unattended Windows installs.
|
||||
|
||||
IMPROVEMENTS:
|
||||
|
||||
* vmware: error if shutdown command has non-zero exit status.
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
* core: UI messages are now properly prefixed with spaces again.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package vmware
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
|
@ -35,7 +36,13 @@ func (s *stepShutdown) Run(state map[string]interface{}) multistep.StepAction {
|
|||
if config.ShutdownCommand != "" {
|
||||
ui.Say("Gracefully halting virtual machine...")
|
||||
log.Printf("Executing shutdown command: %s", config.ShutdownCommand)
|
||||
cmd := &packer.RemoteCmd{Command: config.ShutdownCommand}
|
||||
|
||||
var stdout, stderr bytes.Buffer
|
||||
cmd := &packer.RemoteCmd{
|
||||
Command: config.ShutdownCommand,
|
||||
Stdout: &stdout,
|
||||
Stderr: &stderr,
|
||||
}
|
||||
if err := comm.Start(cmd); err != nil {
|
||||
err := fmt.Errorf("Failed to send shutdown command: %s", err)
|
||||
state["error"] = err
|
||||
|
@ -46,6 +53,17 @@ func (s *stepShutdown) Run(state map[string]interface{}) multistep.StepAction {
|
|||
// Wait for the command to run
|
||||
cmd.Wait()
|
||||
|
||||
// If the command failed to run, notify the user in some way.
|
||||
if cmd.ExitStatus != 0 {
|
||||
state["error"] = fmt.Errorf(
|
||||
"Shutdown command has non-zero exit status.\n\nStdout: %s\n\nStderr: %s",
|
||||
stdout.String(), stderr.String())
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
log.Printf("Shutdown stdout: %s", stdout.String())
|
||||
log.Printf("Shutdown stderr: %s", stderr.String())
|
||||
|
||||
// Wait for the machine to actually shut down
|
||||
log.Printf("Waiting max %s for shutdown to complete", config.ShutdownTimeout)
|
||||
shutdownTimer := time.After(config.ShutdownTimeout)
|
||||
|
|
Loading…
Reference in New Issue