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
286edcb2
Commit
286edcb2
authored
Dec 26, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware/vmx: configure VMX
parent
03fb5fb0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
89 additions
and
66 deletions
+89
-66
builder/vmware/common/vmx_config.go
builder/vmware/common/vmx_config.go
+37
-0
builder/vmware/common/vmx_config_test.go
builder/vmware/common/vmx_config_test.go
+22
-0
builder/vmware/iso/builder.go
builder/vmware/iso/builder.go
+24
-44
builder/vmware/iso/builder_test.go
builder/vmware/iso/builder_test.go
+0
-22
builder/vmware/vmx/builder.go
builder/vmware/vmx/builder.go
+4
-0
builder/vmware/vmx/config.go
builder/vmware/vmx/config.go
+2
-0
No files found.
builder/vmware/common/vmx_config.go
0 → 100644
View file @
286edcb2
package
common
import
(
"fmt"
"github.com/mitchellh/packer/packer"
)
type
VMXConfig
struct
{
VMXData
map
[
string
]
string
`mapstructure:"vmx_data"`
}
func
(
c
*
VMXConfig
)
Prepare
(
t
*
packer
.
ConfigTemplate
)
[]
error
{
errs
:=
make
([]
error
,
0
)
newVMXData
:=
make
(
map
[
string
]
string
)
for
k
,
v
:=
range
c
.
VMXData
{
var
err
error
k
,
err
=
t
.
Process
(
k
,
nil
)
if
err
!=
nil
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"Error processing VMX data key %s: %s"
,
k
,
err
))
continue
}
v
,
err
=
t
.
Process
(
v
,
nil
)
if
err
!=
nil
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"Error processing VMX data value '%s': %s"
,
v
,
err
))
continue
}
newVMXData
[
k
]
=
v
}
c
.
VMXData
=
newVMXData
return
errs
}
builder/vmware/common/vmx_config_test.go
0 → 100644
View file @
286edcb2
package
common
import
(
"testing"
)
func
TestVMXConfigPrepare
(
t
*
testing
.
T
)
{
c
:=
new
(
VMXConfig
)
c
.
VMXData
=
map
[
string
]
string
{
"one"
:
"foo"
,
"two"
:
"bar"
,
}
errs
:=
c
.
Prepare
(
testConfigTemplate
(
t
))
if
len
(
errs
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
errs
)
}
if
len
(
c
.
VMXData
)
!=
2
{
t
.
Fatal
(
"should have two items in VMXData"
)
}
}
builder/vmware/iso/builder.go
View file @
286edcb2
...
...
@@ -27,29 +27,29 @@ type config struct {
common
.
PackerConfig
`mapstructure:",squash"`
vmwcommon
.
OutputConfig
`mapstructure:",squash"`
vmwcommon
.
SSHConfig
`mapstructure:",squash"`
DiskName
string
`mapstructure:"vmdk_name"`
Disk
Size
uint
`mapstructure:"disk_siz
e"`
Disk
TypeId
string
`mapstructure:"disk_type_id
"`
FloppyFiles
[]
string
`mapstructure:"floppy_files
"`
GuestOSType
string
`mapstructure:"guest_os_type
"`
ISOChecksum
string
`mapstructure:"iso_checksum
"`
ISOChecksum
Type
string
`mapstructure:"iso_checksum_type
"`
ISO
Urls
[]
string
`mapstructure:"iso_urls
"`
VMName
string
`mapstructure:"vm_name
"`
Headless
bool
`mapstructure:"headless
"`
H
TTPDir
string
`mapstructure:"http_directory
"`
HTTP
PortMin
uint
`mapstructure:"http_port_min
"`
HTTPPortM
ax
uint
`mapstructure:"http_port_max
"`
BootCommand
[]
string
`mapstructure:"boot_command
"`
SkipCompaction
bool
`mapstructure:"skip_compaction
"`
S
hutdownCommand
string
`mapstructure:"shutdown_command
"`
ToolsUploadFlavor
string
`mapstructure:"tools_upload_flavor
"`
ToolsUpload
Path
string
`mapstructure:"tools_upload_path
"`
VMXData
map
[
string
]
string
`mapstructure:"vmx_data
"`
VMXTemplatePath
string
`mapstructure:"vmx_template_path"`
VNCPortMin
uint
`mapstructure:"vnc_port_min"`
VNCPortMax
uint
`mapstructure:"vnc_port_max"`
vmwcommon
.
VMXConfig
`mapstructure:",squash"`
Disk
Name
string
`mapstructure:"vmdk_nam
e"`
Disk
Size
uint
`mapstructure:"disk_size
"`
DiskTypeId
string
`mapstructure:"disk_type_id
"`
FloppyFiles
[]
string
`mapstructure:"floppy_files
"`
GuestOSType
string
`mapstructure:"guest_os_type
"`
ISOChecksum
string
`mapstructure:"iso_checksum
"`
ISO
ChecksumType
string
`mapstructure:"iso_checksum_type
"`
ISOUrls
[]
string
`mapstructure:"iso_urls
"`
VMName
string
`mapstructure:"vm_name
"`
H
eadless
bool
`mapstructure:"headless
"`
HTTP
Dir
string
`mapstructure:"http_directory
"`
HTTPPortM
in
uint
`mapstructure:"http_port_min
"`
HTTPPortMax
uint
`mapstructure:"http_port_max
"`
BootCommand
[]
string
`mapstructure:"boot_command
"`
S
kipCompaction
bool
`mapstructure:"skip_compaction
"`
ShutdownCommand
string
`mapstructure:"shutdown_command
"`
ToolsUpload
Flavor
string
`mapstructure:"tools_upload_flavor
"`
ToolsUploadPath
string
`mapstructure:"tools_upload_path
"`
VMXTemplatePath
string
`mapstructure:"vmx_template_path"`
VNCPortMin
uint
`mapstructure:"vnc_port_min"`
VNCPortMax
uint
`mapstructure:"vnc_port_max"`
RemoteType
string
`mapstructure:"remote_type"`
RemoteDatastore
string
`mapstructure:"remote_datastore"`
...
...
@@ -84,6 +84,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
OutputConfig
.
Prepare
(
b
.
config
.
tpl
,
&
b
.
config
.
PackerConfig
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
SSHConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
VMXConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
warnings
:=
make
([]
string
,
0
)
if
b
.
config
.
DiskName
==
""
{
...
...
@@ -207,27 +208,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
}
}
newVMXData
:=
make
(
map
[
string
]
string
)
for
k
,
v
:=
range
b
.
config
.
VMXData
{
k
,
err
=
b
.
config
.
tpl
.
Process
(
k
,
nil
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing VMX data key %s: %s"
,
k
,
err
))
continue
}
v
,
err
=
b
.
config
.
tpl
.
Process
(
v
,
nil
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing VMX data value '%s': %s"
,
v
,
err
))
continue
}
newVMXData
[
k
]
=
v
}
b
.
config
.
VMXData
=
newVMXData
if
b
.
config
.
HTTPPortMin
>
b
.
config
.
HTTPPortMax
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"http_port_min must be less than http_port_max"
))
...
...
builder/vmware/iso/builder_test.go
View file @
286edcb2
...
...
@@ -568,25 +568,3 @@ func TestBuilderPrepare_VNCPort(t *testing.T) {
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
}
func
TestBuilderPrepare_VMXData
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
config
[
"vmx_data"
]
=
map
[
interface
{}]
interface
{}{
"one"
:
"foo"
,
"two"
:
"bar"
,
}
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
if
len
(
b
.
config
.
VMXData
)
!=
2
{
t
.
Fatal
(
"should have two items in VMXData"
)
}
}
builder/vmware/vmx/builder.go
View file @
286edcb2
...
...
@@ -58,6 +58,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
Path
:
b
.
config
.
SourcePath
,
VMName
:
b
.
config
.
VMName
,
},
&
vmwcommon
.
StepConfigureVMX
{
CustomData
:
b
.
config
.
VMXData
,
},
&
vmwcommon
.
StepSuppressMessages
{},
}
// Run the steps.
...
...
builder/vmware/vmx/config.go
View file @
286edcb2
...
...
@@ -14,6 +14,7 @@ type Config struct {
common
.
PackerConfig
`mapstructure:",squash"`
vmwcommon
.
OutputConfig
`mapstructure:",squash"`
vmwcommon
.
SSHConfig
`mapstructure:",squash"`
vmwcommon
.
VMXConfig
`mapstructure:",squash"`
SourcePath
string
`mapstructure:"source_path"`
VMName
string
`mapstructure:"vm_name"`
...
...
@@ -43,6 +44,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
errs
:=
common
.
CheckUnusedConfig
(
md
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
OutputConfig
.
Prepare
(
c
.
tpl
,
&
c
.
PackerConfig
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
SSHConfig
.
Prepare
(
c
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
VMXConfig
.
Prepare
(
c
.
tpl
)
...
)
templates
:=
map
[
string
]
*
string
{
"source_path"
:
&
c
.
SourcePath
,
...
...
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