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
081b0d68
Commit
081b0d68
authored
Jun 11, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox: Attach ISO
parent
54057b7b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
9 deletions
+65
-9
builder/virtualbox/builder.go
builder/virtualbox/builder.go
+5
-4
builder/virtualbox/driver.go
builder/virtualbox/driver.go
+1
-1
builder/virtualbox/step_attach_iso.go
builder/virtualbox/step_attach_iso.go
+57
-0
builder/virtualbox/step_create_disk.go
builder/virtualbox/step_create_disk.go
+1
-3
builder/virtualbox/step_create_vm.go
builder/virtualbox/step_create_vm.go
+1
-1
No files found.
builder/virtualbox/builder.go
View file @
081b0d68
...
...
@@ -113,6 +113,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) packer
new
(
stepSuppressMessages
),
new
(
stepCreateVM
),
new
(
stepCreateDisk
),
new
(
stepAttachISO
),
}
// Setup the state bag
...
...
builder/virtualbox/driver.go
View file @
081b0d68
builder/virtualbox/step_attach_iso.go
0 → 100644
View file @
081b0d68
package
virtualbox
import
(
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"time"
)
// This step attaches the ISO to the virtual machine.
//
// Uses:
//
// Produces:
type
stepAttachISO
struct
{
diskPath
string
}
func
(
s
*
stepAttachISO
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
driver
:=
state
[
"driver"
]
.
(
Driver
)
isoPath
:=
state
[
"iso_path"
]
.
(
string
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
vmName
:=
state
[
"vmName"
]
.
(
string
)
// Attach the disk to the controller
command
:=
[]
string
{
"storageattach"
,
vmName
,
"--storagectl"
,
"IDE Controller"
,
"--port"
,
"0"
,
"--device"
,
"1"
,
"--type"
,
"dvddrive"
,
"--medium"
,
isoPath
,
}
if
err
:=
driver
.
VBoxManage
(
command
...
);
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error attaching hard drive: %s"
,
err
))
return
multistep
.
ActionHalt
}
// Track the path so that we can unregister it from VirtualBox later
s
.
diskPath
=
isoPath
time
.
Sleep
(
15
*
time
.
Second
)
return
multistep
.
ActionContinue
}
func
(
s
*
stepAttachISO
)
Cleanup
(
state
map
[
string
]
interface
{})
{
if
s
.
diskPath
==
""
{
return
}
driver
:=
state
[
"driver"
]
.
(
Driver
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
if
err
:=
driver
.
VBoxManage
(
"closemedium"
,
"disk"
,
s
.
diskPath
);
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error unregistering ISO: %s"
,
err
))
}
}
builder/virtualbox/step_create_disk.go
View file @
081b0d68
...
...
@@ -6,12 +6,11 @@ import (
"github.com/mitchellh/packer/packer"
"path/filepath"
"strings"
"time"
)
// This step creates the virtual disk that will be used as the
// hard drive for the virtual machine.
type
stepCreateDisk
struct
{
type
stepCreateDisk
struct
{
diskPath
string
}
...
...
@@ -64,7 +63,6 @@ func (s *stepCreateDisk) Run(state map[string]interface{}) multistep.StepAction
return
multistep
.
ActionHalt
}
time
.
Sleep
(
15
*
time
.
Second
)
return
multistep
.
ActionContinue
}
...
...
builder/virtualbox/step_create_vm.go
View file @
081b0d68
...
...
@@ -10,7 +10,7 @@ import (
//
// Produces:
// vmName string - The name of the VM
type
stepCreateVM
struct
{
type
stepCreateVM
struct
{
vmName
string
}
...
...
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