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
d5cfa42e
Commit
d5cfa42e
authored
Jun 05, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: Wait a minimum time before shutting down VM
parent
daf076bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
builder/vmware/step_run.go
builder/vmware/step_run.go
+14
-5
No files found.
builder/vmware/step_run.go
View file @
d5cfa42e
...
...
@@ -18,7 +18,8 @@ import (
// Produces:
// <nothing>
type
stepRun
struct
{
vmxPath
string
bootTime
time
.
Time
vmxPath
string
}
func
(
s
*
stepRun
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
...
...
@@ -28,16 +29,17 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction {
vmrun_path
:=
"/Applications/VMware Fusion.app/Contents/Library/vmrun"
// Set the VMX path so that we know we started the machine
s
.
bootTime
=
time
.
Now
()
s
.
vmxPath
=
vmxPath
ui
.
Say
(
"Starting virtual machine..."
)
cmd
:=
exec
.
Command
(
vmrun_path
,
"-T"
,
"fusion"
,
"start"
,
vmxPath
,
"gui"
)
cmd
:=
exec
.
Command
(
vmrun_path
,
"-T"
,
"fusion"
,
"start"
,
s
.
vmxPath
,
"gui"
)
if
err
:=
cmd
.
Run
();
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error starting VM: %s"
,
err
))
return
multistep
.
ActionHalt
}
// Set the VMX path so that we know we started the machine
s
.
vmxPath
=
vmxPath
// Wait the wait amount
if
config
.
BootWait
>
0
{
ui
.
Say
(
fmt
.
Sprintf
(
"Waiting %d seconds for boot..."
,
config
.
BootWait
))
...
...
@@ -54,6 +56,13 @@ func (s *stepRun) Cleanup(state map[string]interface{}) {
// If we started the machine... stop it.
if
s
.
vmxPath
!=
""
{
// If we started it less than 5 seconds ago... wait.
sinceBootTime
:=
time
.
Since
(
s
.
bootTime
)
waitBootTime
:=
5
*
time
.
Second
if
sinceBootTime
<
waitBootTime
{
time
.
Sleep
(
waitBootTime
-
sinceBootTime
)
}
ui
.
Say
(
"Stopping virtual machine..."
)
cmd
:=
exec
.
Command
(
vmrun_path
,
"-T"
,
"fusion"
,
"stop"
,
s
.
vmxPath
,
"hard"
)
if
err
:=
cmd
.
Run
();
err
!=
nil
{
...
...
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