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
7a9499e1
Commit
7a9499e1
authored
Jun 11, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox: Attach the hard drive, not quite working yet
parent
b9cd48bb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
builder/virtualbox/step_create_disk.go
builder/virtualbox/step_create_disk.go
+23
-0
builder/virtualbox/step_create_vm.go
builder/virtualbox/step_create_vm.go
+6
-0
No files found.
builder/virtualbox/step_create_disk.go
View file @
7a9499e1
...
@@ -19,6 +19,7 @@ func (s *stepCreateDisk) Run(state map[string]interface{}) multistep.StepAction
...
@@ -19,6 +19,7 @@ func (s *stepCreateDisk) Run(state map[string]interface{}) multistep.StepAction
config
:=
state
[
"config"
]
.
(
*
config
)
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
)
format
:=
"VDI"
format
:=
"VDI"
path
:=
filepath
.
Join
(
config
.
OutputDir
,
fmt
.
Sprintf
(
"%s.%s"
,
config
.
VMName
,
strings
.
ToLower
(
format
)))
path
:=
filepath
.
Join
(
config
.
OutputDir
,
fmt
.
Sprintf
(
"%s.%s"
,
config
.
VMName
,
strings
.
ToLower
(
format
)))
...
@@ -41,6 +42,28 @@ func (s *stepCreateDisk) Run(state map[string]interface{}) multistep.StepAction
...
@@ -41,6 +42,28 @@ func (s *stepCreateDisk) Run(state map[string]interface{}) multistep.StepAction
// Set the path so that we can delete it later
// Set the path so that we can delete it later
s
.
diskPath
=
path
s
.
diskPath
=
path
// Add the IDE controller so we can later attach the disk
controllerName
:=
"IDE Controller"
err
=
driver
.
VBoxManage
(
"storagectl"
,
vmName
,
"--name"
,
controllerName
,
"--add"
,
"ide"
)
if
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error creating disk controller: %s"
,
err
))
return
multistep
.
ActionHalt
}
// Attach the disk to the controller
command
=
[]
string
{
"storagectl"
,
vmName
,
"--storagectl"
,
controllerName
,
"--port"
,
"0"
,
"--device"
,
"0"
,
"--type"
,
"hdd"
,
"--medium"
,
path
,
}
if
err
:=
driver
.
VBoxManage
(
command
...
);
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error attaching hard drive: %s"
,
err
))
return
multistep
.
ActionHalt
}
time
.
Sleep
(
15
*
time
.
Second
)
time
.
Sleep
(
15
*
time
.
Second
)
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
...
...
builder/virtualbox/step_create_vm.go
View file @
7a9499e1
...
@@ -7,6 +7,9 @@ import (
...
@@ -7,6 +7,9 @@ import (
)
)
// This step creates the actual virtual machine.
// This step creates the actual virtual machine.
//
// Produces:
// vmName string - The name of the VM
type
stepCreateVM
struct
{
type
stepCreateVM
struct
{
vmName
string
vmName
string
}
}
...
@@ -41,6 +44,9 @@ func (s *stepCreateVM) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -41,6 +44,9 @@ func (s *stepCreateVM) Run(state map[string]interface{}) multistep.StepAction {
}
}
}
}
// Set the final name in the state bag so others can use it
state
[
"vmName"
]
=
s
.
vmName
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