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
9e4a5a22
Commit
9e4a5a22
authored
Jun 11, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox: support boot_wait
parent
4d351eda
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
1 deletion
+36
-1
builder/virtualbox/builder.go
builder/virtualbox/builder.go
+11
-0
builder/virtualbox/builder_test.go
builder/virtualbox/builder_test.go
+19
-0
builder/virtualbox/step_run.go
builder/virtualbox/step_run.go
+6
-1
No files found.
builder/virtualbox/builder.go
View file @
9e4a5a22
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
"os"
"os"
"os/exec"
"os/exec"
"strings"
"strings"
"time"
)
)
const
BuilderId
=
"mitchellh.virtualbox"
const
BuilderId
=
"mitchellh.virtualbox"
...
@@ -22,6 +23,7 @@ type Builder struct {
...
@@ -22,6 +23,7 @@ type Builder struct {
}
}
type
config
struct
{
type
config
struct
{
BootWait
time
.
Duration
``
GuestOSType
string
`mapstructure:"guest_os_type"`
GuestOSType
string
`mapstructure:"guest_os_type"`
ISOMD5
string
`mapstructure:"iso_md5"`
ISOMD5
string
`mapstructure:"iso_md5"`
ISOUrl
string
`mapstructure:"iso_url"`
ISOUrl
string
`mapstructure:"iso_url"`
...
@@ -30,6 +32,8 @@ type config struct {
...
@@ -30,6 +32,8 @@ type config struct {
SSHHostPortMax
uint
`mapstructure:"ssh_host_port_max"`
SSHHostPortMax
uint
`mapstructure:"ssh_host_port_max"`
SSHPort
uint
`mapstructure:"ssh_port"`
SSHPort
uint
`mapstructure:"ssh_port"`
VMName
string
`mapstructure:"vm_name"`
VMName
string
`mapstructure:"vm_name"`
RawBootWait
string
`mapstructure:"boot_wait"`
}
}
func
(
b
*
Builder
)
Prepare
(
raw
interface
{})
error
{
func
(
b
*
Builder
)
Prepare
(
raw
interface
{})
error
{
...
@@ -109,6 +113,13 @@ func (b *Builder) Prepare(raw interface{}) error {
...
@@ -109,6 +113,13 @@ func (b *Builder) Prepare(raw interface{}) error {
}
}
}
}
if
b
.
config
.
RawBootWait
!=
""
{
b
.
config
.
BootWait
,
err
=
time
.
ParseDuration
(
b
.
config
.
RawBootWait
)
if
err
!=
nil
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"Failed parsing boot_wait: %s"
,
err
))
}
}
if
b
.
config
.
SSHHostPortMin
>
b
.
config
.
SSHHostPortMax
{
if
b
.
config
.
SSHHostPortMin
>
b
.
config
.
SSHHostPortMax
{
errs
=
append
(
errs
,
errors
.
New
(
"ssh_host_port_min must be less than ssh_host_port_max"
))
errs
=
append
(
errs
,
errors
.
New
(
"ssh_host_port_min must be less than ssh_host_port_max"
))
}
}
...
...
builder/virtualbox/builder_test.go
View file @
9e4a5a22
...
@@ -55,6 +55,25 @@ func TestBuilderPrepare_Defaults(t *testing.T) {
...
@@ -55,6 +55,25 @@ func TestBuilderPrepare_Defaults(t *testing.T) {
}
}
}
}
func
TestBuilderPrepare_BootWait
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
// Test with a bad boot_wait
config
[
"boot_wait"
]
=
"this is not good"
err
:=
b
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
// Test with a good one
config
[
"boot_wait"
]
=
"5s"
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
}
func
TestBuilderPrepare_ISOMD5
(
t
*
testing
.
T
)
{
func
TestBuilderPrepare_ISOMD5
(
t
*
testing
.
T
)
{
var
b
Builder
var
b
Builder
config
:=
testConfig
()
config
:=
testConfig
()
...
...
builder/virtualbox/step_run.go
View file @
9e4a5a22
...
@@ -17,6 +17,7 @@ type stepRun struct{
...
@@ -17,6 +17,7 @@ type stepRun struct{
}
}
func
(
s
*
stepRun
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
func
(
s
*
stepRun
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
config
)
driver
:=
state
[
"driver"
]
.
(
Driver
)
driver
:=
state
[
"driver"
]
.
(
Driver
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
vmName
:=
state
[
"vmName"
]
.
(
string
)
vmName
:=
state
[
"vmName"
]
.
(
string
)
...
@@ -30,7 +31,11 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -30,7 +31,11 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction {
s
.
vmName
=
vmName
s
.
vmName
=
vmName
time
.
Sleep
(
15
*
time
.
Second
)
if
int64
(
config
.
BootWait
)
>
0
{
ui
.
Say
(
fmt
.
Sprintf
(
"Waiting %s for boot..."
,
config
.
BootWait
))
time
.
Sleep
(
config
.
BootWait
)
}
return
multistep
.
ActionContinue
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