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
3ba9d70b
Commit
3ba9d70b
authored
Jun 10, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1382 from sneal/AdditionalDisksForVMwareISO
Additional disks for vmware iso
parents
802a7668
e9a491ae
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
81 additions
and
9 deletions
+81
-9
builder/vmware/common/step_compact_disk.go
builder/vmware/common/step_compact_disk.go
+12
-0
builder/vmware/iso/builder.go
builder/vmware/iso/builder.go
+1
-0
builder/vmware/iso/step_create_disk.go
builder/vmware/iso/step_create_disk.go
+22
-0
builder/vmware/iso/step_create_vmx.go
builder/vmware/iso/step_create_vmx.go
+40
-9
website/source/docs/builders/vmware-iso.html.markdown
website/source/docs/builders/vmware-iso.html.markdown
+6
-0
No files found.
builder/vmware/common/step_compact_disk.go
View file @
3ba9d70b
...
...
@@ -36,6 +36,18 @@ func (s StepCompactDisk) Run(state multistep.StateBag) multistep.StepAction {
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Error compacting disk: %s"
,
err
))
return
multistep
.
ActionHalt
}
if
state
.
Get
(
"additional_disk_paths"
)
!=
nil
{
if
moreDisks
:=
state
.
Get
(
"additional_disk_paths"
)
.
([]
string
);
len
(
moreDisks
)
>
0
{
for
i
,
path
:=
range
moreDisks
{
ui
.
Say
(
fmt
.
Sprintf
(
"Compacting additional disk image %d"
,
i
+
1
))
if
err
:=
driver
.
CompactDisk
(
path
);
err
!=
nil
{
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Error compacting additional disk %d: %s"
,
i
+
1
,
err
))
return
multistep
.
ActionHalt
}
}
}
}
return
multistep
.
ActionContinue
}
...
...
builder/vmware/iso/builder.go
View file @
3ba9d70b
...
...
@@ -35,6 +35,7 @@ type Config struct {
vmwcommon
.
ToolsConfig
`mapstructure:",squash"`
vmwcommon
.
VMXConfig
`mapstructure:",squash"`
AdditionalDiskSize
[]
uint
`mapstructure:"additionaldisk_size"`
DiskName
string
`mapstructure:"vmdk_name"`
DiskSize
uint
`mapstructure:"disk_size"`
DiskTypeId
string
`mapstructure:"disk_type_id"`
...
...
builder/vmware/iso/step_create_disk.go
View file @
3ba9d70b
...
...
@@ -35,6 +35,28 @@ func (stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction {
state
.
Put
(
"full_disk_path"
,
full_disk_path
)
if
len
(
config
.
AdditionalDiskSize
)
>
0
{
// stash the disk paths we create
additional_paths
:=
make
([]
string
,
len
(
config
.
AdditionalDiskSize
))
ui
.
Say
(
"Creating additional hard drives..."
)
for
i
,
additionalsize
:=
range
config
.
AdditionalDiskSize
{
additionalpath
:=
filepath
.
Join
(
config
.
OutputDir
,
fmt
.
Sprintf
(
"%s-%d.vmdk"
,
config
.
DiskName
,
i
+
1
))
size
:=
fmt
.
Sprintf
(
"%dM"
,
uint64
(
additionalsize
))
if
err
:=
driver
.
CreateDisk
(
additionalpath
,
size
,
config
.
DiskTypeId
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error creating additional disk: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
additional_paths
[
i
]
=
additionalpath
}
state
.
Put
(
"additional_disk_paths"
,
additional_paths
)
}
return
multistep
.
ActionContinue
}
...
...
builder/vmware/iso/step_create_vmx.go
View file @
3ba9d70b
...
...
@@ -20,6 +20,11 @@ type vmxTemplateData struct {
Version
string
}
type
additionalDiskTemplateData
struct
{
DiskNumber
int
DiskName
string
}
// This step creates the VMX file for the VM.
//
// Uses:
...
...
@@ -40,15 +45,6 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction {
ui
.
Say
(
"Building and writing VMX file"
)
ctx
:=
config
.
ctx
ctx
.
Data
=
&
vmxTemplateData
{
Name
:
config
.
VMName
,
GuestOS
:
config
.
GuestOSType
,
DiskName
:
config
.
DiskName
,
Version
:
config
.
Version
,
ISOPath
:
isoPath
,
}
vmxTemplate
:=
DefaultVMXTemplate
if
config
.
VMXTemplatePath
!=
""
{
f
,
err
:=
os
.
Open
(
config
.
VMXTemplatePath
)
...
...
@@ -71,6 +67,35 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction {
vmxTemplate
=
string
(
rawBytes
)
}
ctx
:=
config
.
ctx
if
len
(
config
.
AdditionalDiskSize
)
>
0
{
for
i
,
_
:=
range
config
.
AdditionalDiskSize
{
ctx
.
Data
=
&
additionalDiskTemplateData
{
DiskNumber
:
i
+
1
,
DiskName
:
config
.
DiskName
,
}
diskTemplate
,
err
:=
interpolate
.
Render
(
DefaultAdditionalDiskTemplate
,
&
ctx
)
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error preparing VMX template for additional disk: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
vmxTemplate
+=
diskTemplate
}
}
ctx
.
Data
=
&
vmxTemplateData
{
Name
:
config
.
VMName
,
GuestOS
:
config
.
GuestOSType
,
DiskName
:
config
.
DiskName
,
Version
:
config
.
Version
,
ISOPath
:
isoPath
,
}
vmxContents
,
err
:=
interpolate
.
Render
(
vmxTemplate
,
&
ctx
)
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error procesing VMX template: %s"
,
err
)
...
...
@@ -191,3 +216,9 @@ vmci0.pciSlotNumber = "35"
vmci0.present = "TRUE"
vmotion.checkpointFBSize = "65536000"
`
const
DefaultAdditionalDiskTemplate
=
`
scsi0:{{ .DiskNumber }}.fileName = "{{ .DiskName}}-{{ .DiskNumber }}.vmdk"
scsi0:{{ .DiskNumber }}.present = "TRUE"
scsi0:{{ .DiskNumber }}.redo = ""
`
website/source/docs/builders/vmware-iso.html.markdown
View file @
3ba9d70b
...
...
@@ -72,6 +72,12 @@ each category, the available options are alphabetized and described.
### Optional:
*
`additionaldisk_size`
(array of integers) - The size(s) of any additional
hard disks for the VM in megabytes. If this is not specified then the VM will
only contain a primary hard disk. The builder uses expandable, not fixed-size
virtual hard disks, so the actual file representing the disk will not use the
full size unless it is full.
*
`boot_command`
(array of strings) - This is an array of commands to type
when the virtual machine is first booted. The goal of these commands should
be to type just enough to initialize the operating system installer. Special
...
...
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