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
d89fd906
Commit
d89fd906
authored
Oct 14, 2014
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1504 from sneal/always-remove-vmx-floppy-entries
Clean VMX step should always remove floppy.
parents
72aea045
5fd96519
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
31 deletions
+23
-31
builder/vmware/common/step_clean_vmx.go
builder/vmware/common/step_clean_vmx.go
+15
-26
builder/vmware/common/step_clean_vmx_test.go
builder/vmware/common/step_clean_vmx_test.go
+1
-2
builder/vmware/common/step_shutdown.go
builder/vmware/common/step_shutdown.go
+7
-3
No files found.
builder/vmware/common/step_clean_vmx.go
View file @
d89fd906
...
...
@@ -32,38 +32,27 @@ func (s StepCleanVMX) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionHalt
}
if
_
,
ok
:=
state
.
GetOk
(
"floppy_path"
);
ok
{
// Delete the floppy0 entries so the floppy is no longer mounted
ui
.
Message
(
"Unmounting floppy from VMX..."
)
for
k
,
_
:=
range
vmxData
{
if
strings
.
HasPrefix
(
k
,
"floppy0."
)
{
log
.
Printf
(
"Deleting key: %s"
,
k
)
delete
(
vmxData
,
k
)
}
// Delete the floppy0 entries so the floppy is no longer mounted
ui
.
Message
(
"Unmounting floppy from VMX..."
)
for
k
,
_
:=
range
vmxData
{
if
strings
.
HasPrefix
(
k
,
"floppy0."
)
{
log
.
Printf
(
"Deleting key: %s"
,
k
)
delete
(
vmxData
,
k
)
}
vmxData
[
"floppy0.present"
]
=
"FALSE"
}
vmxData
[
"floppy0.present"
]
=
"FALSE"
if
isoPathRaw
,
ok
:=
state
.
GetOk
(
"iso_path"
);
ok
{
isoPath
:=
isoPathRaw
.
(
string
)
devRe
:=
regexp
.
MustCompile
(
`^ide\d:\d\.`
)
for
k
,
v
:=
range
vmxData
{
ide
:=
devRe
.
FindString
(
k
)
if
ide
==
""
||
v
!=
"cdrom-image"
{
continue
}
ui
.
Message
(
"Detaching ISO from CD-ROM device..."
)
devRe
:=
regexp
.
MustCompile
(
`^ide\d:\d\.`
)
for
k
,
_
:=
range
vmxData
{
match
:=
devRe
.
FindString
(
k
)
if
match
==
""
{
continue
}
filenameKey
:=
match
+
"filename"
if
filename
,
ok
:=
vmxData
[
filenameKey
];
ok
{
if
filename
==
isoPath
{
// Change the CD-ROM device back to auto-detect to eject
vmxData
[
filenameKey
]
=
"auto detect"
vmxData
[
match
+
"devicetype"
]
=
"cdrom-raw"
}
}
}
vmxData
[
ide
+
"devicetype"
]
=
"cdrom-raw"
vmxData
[
ide
+
"filename"
]
=
"auto detect"
}
// Rewrite the VMX
...
...
builder/vmware/common/step_clean_vmx_test.go
View file @
d89fd906
...
...
@@ -39,7 +39,6 @@ func TestStepCleanVMX_floppyPath(t *testing.T) {
t
.
Fatalf
(
"err: %s"
,
err
)
}
state
.
Put
(
"floppy_path"
,
"foo"
)
state
.
Put
(
"vmx_path"
,
vmxPath
)
// Test the run
...
...
@@ -89,7 +88,6 @@ func TestStepCleanVMX_isoPath(t *testing.T) {
t
.
Fatalf
(
"err: %s"
,
err
)
}
state
.
Put
(
"iso_path"
,
"foo"
)
state
.
Put
(
"vmx_path"
,
vmxPath
)
// Test the run
...
...
@@ -136,6 +134,7 @@ floppy0.filetype = "file"
`
const
testVMXISOPath
=
`
ide0:0.devicetype = "cdrom-image"
ide0:0.filename = "foo"
ide0:1.filename = "bar"
foo = "bar"
...
...
builder/vmware/common/step_shutdown.go
View file @
d89fd906
...
...
@@ -137,10 +137,14 @@ LockWaitLoop:
}
}
if
runtime
.
GOOS
==
"windows
"
&&
!
s
.
Testing
{
if
runtime
.
GOOS
!=
"darwin
"
&&
!
s
.
Testing
{
// Windows takes a while to yield control of the files when the
// process is exiting. We just sleep here. In the future, it'd be
// nice to find a better solution to this.
// process is exiting. Ubuntu will yield control of the files but
// VMWare may overwrite the VMX cleanup steps that run after this,
// so we wait to ensure VMWare has exited and flushed the VMX.
// We just sleep here. In the future, it'd be nice to find a better
// solution to this.
time
.
Sleep
(
5
*
time
.
Second
)
}
...
...
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