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
79c0c6b5
Commit
79c0c6b5
authored
Dec 22, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox: step attach floppy
parent
d731dcd8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
16 deletions
+95
-16
builder/virtualbox/common/driver_mock.go
builder/virtualbox/common/driver_mock.go
+8
-6
builder/virtualbox/common/step_attach_floppy.go
builder/virtualbox/common/step_attach_floppy.go
+10
-8
builder/virtualbox/common/step_attach_floppy_test.go
builder/virtualbox/common/step_attach_floppy_test.go
+73
-0
builder/virtualbox/iso/builder.go
builder/virtualbox/iso/builder.go
+1
-1
builder/virtualbox/ovf/builder.go
builder/virtualbox/ovf/builder.go
+3
-1
No files found.
builder/virtualbox/common/driver_mock.go
View file @
79c0c6b5
...
@@ -15,9 +15,8 @@ type DriverMock struct {
...
@@ -15,9 +15,8 @@ type DriverMock struct {
SuppressMessagesCalled
bool
SuppressMessagesCalled
bool
SuppressMessagesErr
error
SuppressMessagesErr
error
VBoxManageCalled
bool
VBoxManageCalls
[][]
string
VBoxManageArgs
[]
string
VBoxManageErrs
[]
error
VBoxManageErr
error
VerifyCalled
bool
VerifyCalled
bool
VerifyErr
error
VerifyErr
error
...
@@ -49,9 +48,12 @@ func (d *DriverMock) SuppressMessages() error {
...
@@ -49,9 +48,12 @@ func (d *DriverMock) SuppressMessages() error {
}
}
func
(
d
*
DriverMock
)
VBoxManage
(
args
...
string
)
error
{
func
(
d
*
DriverMock
)
VBoxManage
(
args
...
string
)
error
{
d
.
VBoxManageCalled
=
true
d
.
VBoxManageCalls
=
append
(
d
.
VBoxManageCalls
,
args
)
d
.
VBoxManageArgs
=
args
return
d
.
VBoxManageErr
if
len
(
d
.
VBoxManageErrs
)
>=
len
(
d
.
VBoxManageCalls
)
{
return
d
.
VBoxManageErrs
[
len
(
d
.
VBoxManageCalls
)
-
1
]
}
return
nil
}
}
func
(
d
*
DriverMock
)
Verify
()
error
{
func
(
d
*
DriverMock
)
Verify
()
error
{
...
...
builder/virtualbox/
iso
/step_attach_floppy.go
→
builder/virtualbox/
common
/step_attach_floppy.go
View file @
79c0c6b5
package
iso
package
common
import
(
import
(
"fmt"
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/multistep"
vboxcommon
"github.com/mitchellh/packer/builder/virtualbox/common"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer"
"io"
"io"
"io/ioutil"
"io/ioutil"
...
@@ -15,13 +14,16 @@ import (
...
@@ -15,13 +14,16 @@ import (
// This step attaches the ISO to the virtual machine.
// This step attaches the ISO to the virtual machine.
//
//
// Uses:
// Uses:
// driver Driver
// ui packer.Ui
// vmName string
//
//
// Produces:
// Produces:
type
s
tepAttachFloppy
struct
{
type
S
tepAttachFloppy
struct
{
floppyPath
string
floppyPath
string
}
}
func
(
s
*
s
tepAttachFloppy
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
func
(
s
*
S
tepAttachFloppy
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
// Determine if we even have a floppy disk to attach
// Determine if we even have a floppy disk to attach
var
floppyPath
string
var
floppyPath
string
if
floppyPathRaw
,
ok
:=
state
.
GetOk
(
"floppy_path"
);
ok
{
if
floppyPathRaw
,
ok
:=
state
.
GetOk
(
"floppy_path"
);
ok
{
...
@@ -40,7 +42,7 @@ func (s *stepAttachFloppy) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -40,7 +42,7 @@ func (s *stepAttachFloppy) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
driver
:=
state
.
Get
(
"driver"
)
.
(
vboxcommon
.
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmName
:=
state
.
Get
(
"vmName"
)
.
(
string
)
vmName
:=
state
.
Get
(
"vmName"
)
.
(
string
)
...
@@ -77,7 +79,7 @@ func (s *stepAttachFloppy) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -77,7 +79,7 @@ func (s *stepAttachFloppy) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
s
*
s
tepAttachFloppy
)
Cleanup
(
state
multistep
.
StateBag
)
{
func
(
s
*
S
tepAttachFloppy
)
Cleanup
(
state
multistep
.
StateBag
)
{
if
s
.
floppyPath
==
""
{
if
s
.
floppyPath
==
""
{
return
return
}
}
...
@@ -85,7 +87,7 @@ func (s *stepAttachFloppy) Cleanup(state multistep.StateBag) {
...
@@ -85,7 +87,7 @@ func (s *stepAttachFloppy) Cleanup(state multistep.StateBag) {
// Delete the floppy disk
// Delete the floppy disk
defer
os
.
Remove
(
s
.
floppyPath
)
defer
os
.
Remove
(
s
.
floppyPath
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vboxcommon
.
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
vmName
:=
state
.
Get
(
"vmName"
)
.
(
string
)
vmName
:=
state
.
Get
(
"vmName"
)
.
(
string
)
command
:=
[]
string
{
command
:=
[]
string
{
...
@@ -101,7 +103,7 @@ func (s *stepAttachFloppy) Cleanup(state multistep.StateBag) {
...
@@ -101,7 +103,7 @@ func (s *stepAttachFloppy) Cleanup(state multistep.StateBag) {
}
}
}
}
func
(
s
*
s
tepAttachFloppy
)
copyFloppy
(
path
string
)
(
string
,
error
)
{
func
(
s
*
S
tepAttachFloppy
)
copyFloppy
(
path
string
)
(
string
,
error
)
{
tempdir
,
err
:=
ioutil
.
TempDir
(
""
,
"packer"
)
tempdir
,
err
:=
ioutil
.
TempDir
(
""
,
"packer"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
...
...
builder/virtualbox/common/step_attach_floppy_test.go
0 → 100644
View file @
79c0c6b5
package
common
import
(
"github.com/mitchellh/multistep"
"io/ioutil"
"os"
"testing"
)
func
TestStepAttachFloppy_impl
(
t
*
testing
.
T
)
{
var
_
multistep
.
Step
=
new
(
StepAttachFloppy
)
}
func
TestStepAttachFloppy
(
t
*
testing
.
T
)
{
state
:=
testState
(
t
)
step
:=
new
(
StepAttachFloppy
)
// Create a temporary file for our floppy file
tf
,
err
:=
ioutil
.
TempFile
(
""
,
"packer"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
tf
.
Close
()
defer
os
.
Remove
(
tf
.
Name
())
state
.
Put
(
"floppy_path"
,
tf
.
Name
())
state
.
Put
(
"vmName"
,
"foo"
)
driver
:=
state
.
Get
(
"driver"
)
.
(
*
DriverMock
)
// Test the run
if
action
:=
step
.
Run
(
state
);
action
!=
multistep
.
ActionContinue
{
t
.
Fatalf
(
"bad action: %#v"
,
action
)
}
if
_
,
ok
:=
state
.
GetOk
(
"error"
);
ok
{
t
.
Fatal
(
"should NOT have error"
)
}
if
len
(
driver
.
VBoxManageCalls
)
!=
2
{
t
.
Fatal
(
"not enough calls to VBoxManage"
)
}
if
driver
.
VBoxManageCalls
[
0
][
0
]
!=
"storagectl"
{
t
.
Fatal
(
"bad call"
)
}
if
driver
.
VBoxManageCalls
[
1
][
0
]
!=
"storageattach"
{
t
.
Fatal
(
"bad call"
)
}
// Test the cleanup
step
.
Cleanup
(
state
)
if
driver
.
VBoxManageCalls
[
2
][
0
]
!=
"storageattach"
{
t
.
Fatal
(
"bad call"
)
}
}
func
TestStepAttachFloppy_noFloppy
(
t
*
testing
.
T
)
{
state
:=
testState
(
t
)
step
:=
new
(
StepAttachFloppy
)
driver
:=
state
.
Get
(
"driver"
)
.
(
*
DriverMock
)
// Test the run
if
action
:=
step
.
Run
(
state
);
action
!=
multistep
.
ActionContinue
{
t
.
Fatalf
(
"bad action: %#v"
,
action
)
}
if
_
,
ok
:=
state
.
GetOk
(
"error"
);
ok
{
t
.
Fatal
(
"should NOT have error"
)
}
if
len
(
driver
.
VBoxManageCalls
)
>
0
{
t
.
Fatal
(
"should not call vboxmanage"
)
}
}
builder/virtualbox/iso/builder.go
View file @
79c0c6b5
...
@@ -381,7 +381,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -381,7 +381,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
new
(
stepCreateDisk
),
new
(
stepCreateDisk
),
new
(
stepAttachISO
),
new
(
stepAttachISO
),
new
(
stepAttachGuestAdditions
),
new
(
stepAttachGuestAdditions
),
new
(
s
tepAttachFloppy
),
new
(
vboxcommon
.
S
tepAttachFloppy
),
new
(
stepForwardSSH
),
new
(
stepForwardSSH
),
new
(
stepVBoxManage
),
new
(
stepVBoxManage
),
new
(
stepRun
),
new
(
stepRun
),
...
...
builder/virtualbox/ovf/builder.go
View file @
79c0c6b5
...
@@ -52,7 +52,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -52,7 +52,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
},
},
/*
/*
new(stepAttachGuestAdditions),
new(stepAttachGuestAdditions),
new(stepAttachFloppy),
*/
new
(
vboxcommon
.
StepAttachFloppy
),
/*
new(stepForwardSSH),
new(stepForwardSSH),
new(stepVBoxManage),
new(stepVBoxManage),
new(stepRun),
new(stepRun),
...
...
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