Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
0fdf9b09
Commit
0fdf9b09
authored
Jul 09, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: error if shutdown command failed
parent
56aff481
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
CHANGELOG.md
CHANGELOG.md
+4
-0
builder/vmware/step_shutdown.go
builder/vmware/step_shutdown.go
+19
-1
No files found.
CHANGELOG.md
View file @
0fdf9b09
...
...
@@ -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.
...
...
builder/vmware/step_shutdown.go
View file @
0fdf9b09
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\n
Stdout: %s
\n\n
Stderr: %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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment