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
4d5edcaa
Commit
4d5edcaa
authored
Jul 02, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: Improve check for VMware cleanup
parent
529f72c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
3 deletions
+31
-3
builder/vmware/step_compact_disk.go
builder/vmware/step_compact_disk.go
+2
-1
builder/vmware/step_shutdown.go
builder/vmware/step_shutdown.go
+29
-2
No files found.
builder/vmware/step_compact_disk.go
View file @
4d5edcaa
...
...
@@ -10,6 +10,7 @@ import (
//
// Uses:
// driver Driver
// full_disk_path string
// ui packer.Ui
//
// Produces:
...
...
@@ -23,7 +24,7 @@ func (stepCompactDisk) Run(state map[string]interface{}) multistep.StepAction {
ui
.
Say
(
"Compacting the disk image"
)
if
err
:=
driver
.
CompactDisk
(
full_disk_path
);
err
!=
nil
{
state
[
"error"
]
:
=
fmt
.
Errorf
(
"Error compacting disk: %s"
,
err
)
state
[
"error"
]
=
fmt
.
Errorf
(
"Error compacting disk: %s"
,
err
)
return
multistep
.
ActionHalt
}
...
...
builder/vmware/step_shutdown.go
View file @
4d5edcaa
...
...
@@ -6,6 +6,8 @@ import (
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log"
"path/filepath"
"strings"
"time"
)
...
...
@@ -72,8 +74,33 @@ func (s *stepShutdown) Run(state map[string]interface{}) multistep.StepAction {
}
}
log
.
Println
(
"Giving VMware a few extra seconds to clean up after itself..."
)
time
.
Sleep
(
5
*
time
.
Second
)
ui
.
Message
(
"Waiting for VMware to clean up after itself..."
)
lockPattern
:=
filepath
.
Join
(
config
.
OutputDir
,
"*.lck"
)
timer
:=
time
.
After
(
15
*
time
.
Second
)
LockWaitLoop
:
for
{
locks
,
err
:=
filepath
.
Glob
(
lockPattern
)
if
err
==
nil
{
if
len
(
locks
)
==
0
{
log
.
Println
(
"No more lock files found. VMware is clean."
)
break
}
if
len
(
locks
)
==
1
&&
strings
.
HasSuffix
(
locks
[
0
],
".vmx.lck"
)
{
log
.
Println
(
"Only waiting on VMX lock. VMware is clean."
)
break
}
log
.
Printf
(
"Waiting on lock files: %#v"
,
locks
)
}
select
{
case
<-
timer
:
log
.
Println
(
"Reached timeout on waiting for clean VMware. Assuming clean."
)
break
LockWaitLoop
case
<-
time
.
After
(
1
*
time
.
Second
)
:
}
}
log
.
Println
(
"VM shut down."
)
return
multistep
.
ActionContinue
...
...
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