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
05a34d2f
Commit
05a34d2f
authored
Jun 04, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: Create disk and create VMX file
parent
2e57496a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
1 deletion
+131
-1
builder/vmware/builder.go
builder/vmware/builder.go
+11
-0
builder/vmware/step_create_disk.go
builder/vmware/step_create_disk.go
+1
-1
builder/vmware/step_create_vmx.go
builder/vmware/step_create_vmx.go
+119
-0
No files found.
builder/vmware/builder.go
View file @
05a34d2f
...
...
@@ -13,10 +13,20 @@ type Builder struct {
}
type
config
struct
{
DiskName
string
`mapstructure:"vmdk_name"`
VMName
string
`mapstructure:"vm_name"`
OutputDir
string
`mapstructure:"output_directory"`
}
func
(
b
*
Builder
)
Prepare
(
raw
interface
{})
(
err
error
)
{
if
b
.
config
.
DiskName
==
""
{
b
.
config
.
DiskName
=
"disk"
}
if
b
.
config
.
VMName
==
""
{
b
.
config
.
VMName
=
"packer"
}
if
b
.
config
.
OutputDir
==
""
{
b
.
config
.
OutputDir
=
"vmware"
}
...
...
@@ -28,6 +38,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook) packer.Artifact {
steps
:=
[]
multistep
.
Step
{
&
stepPrepareOutputDir
{},
&
stepCreateDisk
{},
&
stepCreateVMX
{},
}
// Setup the state bag
...
...
builder/vmware/step_create_disk.go
View file @
05a34d2f
...
...
@@ -18,7 +18,7 @@ func (stepCreateDisk) Run(state map[string]interface{}) multistep.StepAction {
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
vdisk_manager
:=
"/Applications/VMware Fusion.app/Contents/Library/vmware-vdiskmanager"
output
:=
filepath
.
Join
(
config
.
OutputDir
,
"disk
.vmdk"
)
output
:=
filepath
.
Join
(
config
.
OutputDir
,
config
.
DiskName
+
"
.vmdk"
)
ui
.
Say
(
"Creating virtual machine disk"
)
cmd
:=
exec
.
Command
(
vdisk_manager
,
"-c"
,
"-s"
,
"40000M"
,
"-a"
,
"lsilogic"
,
"-t"
,
"1"
,
output
)
...
...
builder/vmware/step_create_vmx.go
0 → 100644
View file @
05a34d2f
package
vmware
import
(
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"os"
"path/filepath"
"text/template"
)
type
vmxTemplateData
struct
{
Name
string
GuestOS
string
DiskName
string
}
type
stepCreateVMX
struct
{}
func
(
stepCreateVMX
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
config
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
vmx_path
:=
filepath
.
Join
(
config
.
OutputDir
,
config
.
VMName
+
".vmx"
)
f
,
err
:=
os
.
Create
(
vmx_path
)
if
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error creating VMX: %s"
,
err
))
return
multistep
.
ActionHalt
}
tplData
:=
&
vmxTemplateData
{
config
.
VMName
,
"ubuntu-64"
,
config
.
DiskName
,
}
t
:=
template
.
Must
(
template
.
New
(
"vmx"
)
.
Parse
(
DefaultVMXTemplate
))
t
.
Execute
(
f
,
tplData
)
return
multistep
.
ActionContinue
}
func
(
stepCreateVMX
)
Cleanup
(
map
[
string
]
interface
{})
{
}
// This is the default VMX template used if no other template is given.
// This is hardcoded here. If you wish to use a custom template please
// do so by specifying in the builder configuration.
const
DefaultVMXTemplate
=
`
.encoding = "UTF-8"
bios.bootOrder = "hdd,CDROM"
checkpoint.vmState = ""
cleanShutdown = "TRUE"
config.version = "8"
displayName = "{{ .Name }}"
ehci.pciSlotNumber = "34"
ehci.present = "TRUE"
ethernet0.addressType = "generated"
ethernet0.bsdName = "en0"
ethernet0.connectionType = "nat"
ethernet0.displayName = "Ethernet"
ethernet0.linkStatePropagation.enable = "FALSE"
ethernet0.pciSlotNumber = "33"
ethernet0.present = "TRUE"
ethernet0.virtualDev = "e1000"
ethernet0.wakeOnPcktRcv = "FALSE"
extendedConfigFile = "{{ .Name }}.vmxf"
floppy0.present = "FALSE"
guestOS = "{{ .GuestOS }}"
gui.fullScreenAtPowerOn = "FALSE"
gui.viewModeAtPowerOn = "windowed"
hgfs.linkRootShare = "TRUE"
hgfs.mapRootShare = "TRUE"
isolation.tools.hgfs.disable = "FALSE"
memsize = "512"
nvram = "{{ .Name }}.nvram"
pciBridge0.pciSlotNumber = "17"
pciBridge0.present = "TRUE"
pciBridge4.functions = "8"
pciBridge4.pciSlotNumber = "21"
pciBridge4.present = "TRUE"
pciBridge4.virtualDev = "pcieRootPort"
pciBridge5.functions = "8"
pciBridge5.pciSlotNumber = "22"
pciBridge5.present = "TRUE"
pciBridge5.virtualDev = "pcieRootPort"
pciBridge6.functions = "8"
pciBridge6.pciSlotNumber = "23"
pciBridge6.present = "TRUE"
pciBridge6.virtualDev = "pcieRootPort"
pciBridge7.functions = "8"
pciBridge7.pciSlotNumber = "24"
pciBridge7.present = "TRUE"
pciBridge7.virtualDev = "pcieRootPort"
powerType.powerOff = "soft"
powerType.powerOn = "soft"
powerType.reset = "soft"
powerType.suspend = "soft"
proxyApps.publishToHost = "FALSE"
replay.filename = ""
replay.supported = "FALSE"
scsi0.pciSlotNumber = "16"
scsi0.present = "TRUE"
scsi0.virtualDev = "lsilogic"
scsi0:0.fileName = "{{ .DiskName }}.vmdk"
scsi0:0.present = "TRUE"
scsi0:0.redo = ""
sound.startConnected = "FALSE"
tools.syncTime = "TRUE"
tools.upgrade.policy = "upgradeAtPowerCycle"
usb.pciSlotNumber = "32"
usb.present = "FALSE"
virtualHW.productCompatibility = "hosted"
virtualHW.version = "9"
vmci0.id = "1861462627"
vmci0.pciSlotNumber = "35"
vmci0.present = "TRUE"
vmotion.checkpointFBSize = "65536000"
`
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