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
38e880a1
Commit
38e880a1
authored
Mar 12, 2014
by
Jacob Helwig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to run vboxmanage commands just before exporting [GH-664]
parent
bb8d0a5e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
105 additions
and
20 deletions
+105
-20
builder/virtualbox/common/vboxmanage_post_config.go
builder/virtualbox/common/vboxmanage_post_config.go
+28
-0
builder/virtualbox/common/vboxmanage_post_config_test.go
builder/virtualbox/common/vboxmanage_post_config_test.go
+37
-0
builder/virtualbox/iso/builder.go
builder/virtualbox/iso/builder.go
+16
-10
builder/virtualbox/ovf/builder.go
builder/virtualbox/ovf/builder.go
+4
-0
builder/virtualbox/ovf/config.go
builder/virtualbox/ovf/config.go
+12
-10
website/source/docs/builders/virtualbox-iso.html.markdown
website/source/docs/builders/virtualbox-iso.html.markdown
+4
-0
website/source/docs/builders/virtualbox-ovf.html.markdown
website/source/docs/builders/virtualbox-ovf.html.markdown
+4
-0
No files found.
builder/virtualbox/common/vboxmanage_post_config.go
0 → 100644
View file @
38e880a1
package
common
import
(
"fmt"
"github.com/mitchellh/packer/packer"
)
type
VBoxManagePostConfig
struct
{
VBoxManagePost
[][]
string
`mapstructure:"vboxmanage_post"`
}
func
(
c
*
VBoxManagePostConfig
)
Prepare
(
t
*
packer
.
ConfigTemplate
)
[]
error
{
if
c
.
VBoxManagePost
==
nil
{
c
.
VBoxManagePost
=
make
([][]
string
,
0
)
}
errs
:=
make
([]
error
,
0
)
for
i
,
args
:=
range
c
.
VBoxManagePost
{
for
j
,
arg
:=
range
args
{
if
err
:=
t
.
Validate
(
arg
);
err
!=
nil
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"Error processing vboxmanage_post[%d][%d]: %s"
,
i
,
j
,
err
))
}
}
}
return
errs
}
builder/virtualbox/common/vboxmanage_post_config_test.go
0 → 100644
View file @
38e880a1
package
common
import
(
"reflect"
"testing"
)
func
TestVBoxManagePostConfigPrepare_VBoxManage
(
t
*
testing
.
T
)
{
// Test with empty
c
:=
new
(
VBoxManagePostConfig
)
errs
:=
c
.
Prepare
(
testConfigTemplate
(
t
))
if
len
(
errs
)
>
0
{
t
.
Fatalf
(
"err: %#v"
,
errs
)
}
if
!
reflect
.
DeepEqual
(
c
.
VBoxManagePost
,
[][]
string
{})
{
t
.
Fatalf
(
"bad: %#v"
,
c
.
VBoxManagePost
)
}
// Test with a good one
c
=
new
(
VBoxManagePostConfig
)
c
.
VBoxManagePost
=
[][]
string
{
{
"foo"
,
"bar"
,
"baz"
},
}
errs
=
c
.
Prepare
(
testConfigTemplate
(
t
))
if
len
(
errs
)
>
0
{
t
.
Fatalf
(
"err: %#v"
,
errs
)
}
expected
:=
[][]
string
{
[]
string
{
"foo"
,
"bar"
,
"baz"
},
}
if
!
reflect
.
DeepEqual
(
c
.
VBoxManagePost
,
expected
)
{
t
.
Fatalf
(
"bad: %#v"
,
c
.
VBoxManagePost
)
}
}
builder/virtualbox/iso/builder.go
View file @
38e880a1
...
...
@@ -27,16 +27,17 @@ type Builder struct {
}
type
config
struct
{
common
.
PackerConfig
`mapstructure:",squash"`
vboxcommon
.
ExportConfig
`mapstructure:",squash"`
vboxcommon
.
ExportOpts
`mapstructure:",squash"`
vboxcommon
.
FloppyConfig
`mapstructure:",squash"`
vboxcommon
.
OutputConfig
`mapstructure:",squash"`
vboxcommon
.
RunConfig
`mapstructure:",squash"`
vboxcommon
.
ShutdownConfig
`mapstructure:",squash"`
vboxcommon
.
SSHConfig
`mapstructure:",squash"`
vboxcommon
.
VBoxManageConfig
`mapstructure:",squash"`
vboxcommon
.
VBoxVersionConfig
`mapstructure:",squash"`
common
.
PackerConfig
`mapstructure:",squash"`
vboxcommon
.
ExportConfig
`mapstructure:",squash"`
vboxcommon
.
ExportOpts
`mapstructure:",squash"`
vboxcommon
.
FloppyConfig
`mapstructure:",squash"`
vboxcommon
.
OutputConfig
`mapstructure:",squash"`
vboxcommon
.
RunConfig
`mapstructure:",squash"`
vboxcommon
.
ShutdownConfig
`mapstructure:",squash"`
vboxcommon
.
SSHConfig
`mapstructure:",squash"`
vboxcommon
.
VBoxManageConfig
`mapstructure:",squash"`
vboxcommon
.
VBoxManagePostConfig
`mapstructure:",squash"`
vboxcommon
.
VBoxVersionConfig
`mapstructure:",squash"`
BootCommand
[]
string
`mapstructure:"boot_command"`
DiskSize
uint
`mapstructure:"disk_size"`
...
...
@@ -82,6 +83,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
ShutdownConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
SSHConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
VBoxManageConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
VBoxManagePostConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
VBoxVersionConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
warnings
:=
make
([]
string
,
0
)
...
...
@@ -318,6 +320,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
Timeout
:
b
.
config
.
ShutdownTimeout
,
},
new
(
vboxcommon
.
StepRemoveDevices
),
&
vboxcommon
.
StepVBoxManage
{
Commands
:
b
.
config
.
VBoxManagePost
,
Tpl
:
b
.
config
.
tpl
,
},
&
vboxcommon
.
StepExport
{
Format
:
b
.
config
.
Format
,
OutputDir
:
b
.
config
.
OutputDir
,
...
...
builder/virtualbox/ovf/builder.go
View file @
38e880a1
...
...
@@ -94,6 +94,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
Timeout
:
b
.
config
.
ShutdownTimeout
,
},
new
(
vboxcommon
.
StepRemoveDevices
),
&
vboxcommon
.
StepVBoxManage
{
Commands
:
b
.
config
.
VBoxManagePost
,
Tpl
:
b
.
config
.
tpl
,
},
&
vboxcommon
.
StepExport
{
Format
:
b
.
config
.
Format
,
OutputDir
:
b
.
config
.
OutputDir
,
...
...
builder/virtualbox/ovf/config.go
View file @
38e880a1
...
...
@@ -11,16 +11,17 @@ import (
// Config is the configuration structure for the builder.
type
Config
struct
{
common
.
PackerConfig
`mapstructure:",squash"`
vboxcommon
.
ExportConfig
`mapstructure:",squash"`
vboxcommon
.
ExportOpts
`mapstructure:",squash"`
vboxcommon
.
FloppyConfig
`mapstructure:",squash"`
vboxcommon
.
OutputConfig
`mapstructure:",squash"`
vboxcommon
.
RunConfig
`mapstructure:",squash"`
vboxcommon
.
SSHConfig
`mapstructure:",squash"`
vboxcommon
.
ShutdownConfig
`mapstructure:",squash"`
vboxcommon
.
VBoxManageConfig
`mapstructure:",squash"`
vboxcommon
.
VBoxVersionConfig
`mapstructure:",squash"`
common
.
PackerConfig
`mapstructure:",squash"`
vboxcommon
.
ExportConfig
`mapstructure:",squash"`
vboxcommon
.
ExportOpts
`mapstructure:",squash"`
vboxcommon
.
FloppyConfig
`mapstructure:",squash"`
vboxcommon
.
OutputConfig
`mapstructure:",squash"`
vboxcommon
.
RunConfig
`mapstructure:",squash"`
vboxcommon
.
SSHConfig
`mapstructure:",squash"`
vboxcommon
.
ShutdownConfig
`mapstructure:",squash"`
vboxcommon
.
VBoxManageConfig
`mapstructure:",squash"`
vboxcommon
.
VBoxManagePostConfig
`mapstructure:",squash"`
vboxcommon
.
VBoxVersionConfig
`mapstructure:",squash"`
SourcePath
string
`mapstructure:"source_path"`
VMName
string
`mapstructure:"vm_name"`
...
...
@@ -57,6 +58,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
ShutdownConfig
.
Prepare
(
c
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
SSHConfig
.
Prepare
(
c
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
VBoxManageConfig
.
Prepare
(
c
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
VBoxManagePostConfig
.
Prepare
(
c
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
VBoxVersionConfig
.
Prepare
(
c
.
tpl
)
...
)
templates
:=
map
[
string
]
*
string
{
...
...
website/source/docs/builders/virtualbox-iso.html.markdown
View file @
38e880a1
...
...
@@ -201,6 +201,10 @@ Optional:
where the
`Name`
variable is replaced with the VM name. More details on how
to use
`VBoxManage`
are below.
*
`vboxmanage_post`
(array of array of strings) - Identical to
`vboxmanage`
,
except that it is run after the virtual machine is shutdown, and before the
virtual machine is exported.
*
`virtualbox_version_file`
(string) - The path within the virtual machine
to upload a file that contains the VirtualBox version that was used to
create the machine. This information can be useful for provisioning.
...
...
website/source/docs/builders/virtualbox-ovf.html.markdown
View file @
38e880a1
...
...
@@ -136,6 +136,10 @@ Optional:
where the
`Name`
variable is replaced with the VM name. More details on how
to use
`VBoxManage`
are below.
*
`vboxmanage_post`
(array of array of strings) - Identical to
`vboxmanage`
,
except that it is run after the virtual machine is shutdown, and before the
virtual machine is exported.
*
`virtualbox_version_file`
(string) - The path within the virtual machine
to upload a file that contains the VirtualBox version that was used to
create the machine. This information can be useful for provisioning.
...
...
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