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
24895069
Commit
24895069
authored
Jun 11, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox: start the VM
parent
70df8c8c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
2 deletions
+48
-2
builder/virtualbox/builder.go
builder/virtualbox/builder.go
+1
-0
builder/virtualbox/step_forward_ssh.go
builder/virtualbox/step_forward_ssh.go
+0
-2
builder/virtualbox/step_run.go
builder/virtualbox/step_run.go
+47
-0
No files found.
builder/virtualbox/builder.go
View file @
24895069
...
...
@@ -130,6 +130,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) packer
new
(
stepCreateDisk
),
new
(
stepAttachISO
),
new
(
stepForwardSSH
),
new
(
stepRun
),
}
// Setup the state bag
...
...
builder/virtualbox/step_forward_ssh.go
View file @
24895069
...
...
@@ -7,7 +7,6 @@ import (
"log"
"math/rand"
"net"
"time"
)
// This step adds a NAT port forwarding definition so that SSH is available
...
...
@@ -52,7 +51,6 @@ func (s *stepForwardSSH) Run(state map[string]interface{}) multistep.StepAction
// Save the port we're using so that future steps can use it
state
[
"sshHostPort"
]
=
sshHostPort
time
.
Sleep
(
15
*
time
.
Second
)
return
multistep
.
ActionContinue
}
...
...
builder/virtualbox/step_run.go
0 → 100644
View file @
24895069
package
virtualbox
import
(
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"time"
)
// This step starts the virtual machine.
//
// Uses:
//
// Produces:
type
stepRun
struct
{
vmName
string
}
func
(
s
*
stepRun
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
driver
:=
state
[
"driver"
]
.
(
Driver
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
vmName
:=
state
[
"vmName"
]
.
(
string
)
ui
.
Say
(
"Starting the virtual machine..."
)
command
:=
[]
string
{
"startvm"
,
vmName
,
"--type"
,
"gui"
}
if
err
:=
driver
.
VBoxManage
(
command
...
);
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error starting VM: %s"
,
err
))
return
multistep
.
ActionHalt
}
s
.
vmName
=
vmName
time
.
Sleep
(
15
*
time
.
Second
)
return
multistep
.
ActionContinue
}
func
(
s
*
stepRun
)
Cleanup
(
state
map
[
string
]
interface
{})
{
if
s
.
vmName
==
""
{
return
}
driver
:=
state
[
"driver"
]
.
(
Driver
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
if
err
:=
driver
.
VBoxManage
(
"controlvm"
,
s
.
vmName
,
"poweroff"
);
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error shutting down VM: %s"
,
err
))
}
}
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