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
b9cd48bb
Commit
b9cd48bb
authored
Jun 11, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox: Create a virtual disk
parent
7fe40cfc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
2 deletions
+61
-2
builder/virtualbox/builder.go
builder/virtualbox/builder.go
+1
-0
builder/virtualbox/step_create_disk.go
builder/virtualbox/step_create_disk.go
+60
-0
builder/virtualbox/step_create_vm.go
builder/virtualbox/step_create_vm.go
+0
-2
No files found.
builder/virtualbox/builder.go
View file @
b9cd48bb
...
...
@@ -60,6 +60,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) packer
new
(
stepPrepareOutputDir
),
new
(
stepSuppressMessages
),
new
(
stepCreateVM
),
new
(
stepCreateDisk
),
}
// Setup the state bag
...
...
builder/virtualbox/step_create_disk.go
0 → 100644
View file @
b9cd48bb
package
virtualbox
import
(
"fmt"
"github.com/mitchellh/multistep"
"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
{
diskPath
string
}
func
(
s
*
stepCreateDisk
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
config
)
driver
:=
state
[
"driver"
]
.
(
Driver
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
format
:=
"VDI"
path
:=
filepath
.
Join
(
config
.
OutputDir
,
fmt
.
Sprintf
(
"%s.%s"
,
config
.
VMName
,
strings
.
ToLower
(
format
)))
command
:=
[]
string
{
"createhd"
,
"--filename"
,
path
,
"--size"
,
"40"
,
"--format"
,
format
,
"--variant"
,
"Standard"
,
}
ui
.
Say
(
"Creating hard drive..."
)
err
:=
driver
.
VBoxManage
(
command
...
)
if
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error creating hard drive: %s"
,
err
))
return
multistep
.
ActionHalt
}
// Set the path so that we can delete it later
s
.
diskPath
=
path
time
.
Sleep
(
15
*
time
.
Second
)
return
multistep
.
ActionContinue
}
func
(
s
*
stepCreateDisk
)
Cleanup
(
state
map
[
string
]
interface
{})
{
if
s
.
diskPath
==
""
{
return
}
driver
:=
state
[
"driver"
]
.
(
Driver
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
.
Say
(
"Unregistering and deleting hard disk..."
)
if
err
:=
driver
.
VBoxManage
(
"closemedium"
,
"disk"
,
s
.
diskPath
,
"--delete"
);
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error deleting hard drive: %s"
,
err
))
}
}
builder/virtualbox/step_create_vm.go
View file @
b9cd48bb
...
...
@@ -4,7 +4,6 @@ import (
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"time"
)
// This step creates the actual virtual machine.
...
...
@@ -42,7 +41,6 @@ func (s *stepCreateVM) Run(state map[string]interface{}) multistep.StepAction {
}
}
time
.
Sleep
(
15
*
time
.
Second
)
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