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
9c27f585
Commit
9c27f585
authored
Jun 05, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: Better commenting
parent
5d465c2f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
0 deletions
+64
-0
builder/vmware/step_create_disk.go
builder/vmware/step_create_disk.go
+8
-0
builder/vmware/step_create_vmx.go
builder/vmware/step_create_vmx.go
+2
-0
builder/vmware/step_run.go
builder/vmware/step_run.go
+54
-0
No files found.
builder/vmware/step_create_disk.go
View file @
9c27f585
...
@@ -8,6 +8,14 @@ import (
...
@@ -8,6 +8,14 @@ import (
"path/filepath"
"path/filepath"
)
)
// This step creates the virtual disks for the VM.
//
// Uses:
// config *config
// ui packer.Ui
//
// Produces:
// <nothing>
type
stepCreateDisk
struct
{}
type
stepCreateDisk
struct
{}
func
(
stepCreateDisk
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
func
(
stepCreateDisk
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
...
...
builder/vmware/step_create_vmx.go
View file @
9c27f585
...
@@ -24,6 +24,7 @@ type vmxTemplateData struct {
...
@@ -24,6 +24,7 @@ type vmxTemplateData struct {
// ui packer.Ui
// ui packer.Ui
//
//
// Produces:
// Produces:
// vmx_path string - The path to the VMX file.
// vnc_port uint - The port the VM is configured to listen on for VNC.
// vnc_port uint - The port the VM is configured to listen on for VNC.
type
stepCreateVMX
struct
{}
type
stepCreateVMX
struct
{}
...
@@ -51,6 +52,7 @@ func (stepCreateVMX) Run(state map[string]interface{}) multistep.StepAction {
...
@@ -51,6 +52,7 @@ func (stepCreateVMX) Run(state map[string]interface{}) multistep.StepAction {
t
:=
template
.
Must
(
template
.
New
(
"vmx"
)
.
Parse
(
DefaultVMXTemplate
))
t
:=
template
.
Must
(
template
.
New
(
"vmx"
)
.
Parse
(
DefaultVMXTemplate
))
t
.
Execute
(
f
,
tplData
)
t
.
Execute
(
f
,
tplData
)
state
[
"vmx_path"
]
=
vmx_path
state
[
"vnc_port"
]
=
vncPort
state
[
"vnc_port"
]
=
vncPort
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
...
...
builder/vmware/step_run.go
0 → 100644
View file @
9c27f585
package
vmware
import
(
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"os/exec"
)
// This step runs the created virtual machine.
//
// Uses:
// ui packer.Ui
// vmx_path string
//
// Produces:
// <nothing>
type
stepRun
struct
{
vmxPath
string
}
func
(
s
*
stepRun
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
vmxPath
:=
state
[
"vmx_path"
]
.
(
string
)
vmrun_path
:=
"/Applications/VMware Fusion.app/Contents/Library/vmrun"
ui
.
Say
(
"Starting virtual machine..."
)
cmd
:=
exec
.
Command
(
vmrun_path
,
"-T"
,
"fusion"
,
"start"
,
vmxPath
,
"gui"
)
if
err
:=
cmd
.
Run
();
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error starting VM: %s"
,
err
))
return
multistep
.
ActionHalt
}
// Set the VMX path so that we know we started the machine
s
.
vmxPath
=
vmxPath
return
multistep
.
ActionContinue
}
func
(
s
*
stepRun
)
Cleanup
(
state
map
[
string
]
interface
{})
{
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
vmrun_path
:=
"/Applications/VMware Fusion.app/Contents/Library/vmrun"
// If we started the machine... stop it.
if
s
.
vmxPath
!=
""
{
ui
.
Say
(
"Stopping virtual machine..."
)
cmd
:=
exec
.
Command
(
vmrun_path
,
"-T"
,
"fusion"
,
"start"
,
s
.
vmxPath
,
"gui"
)
if
err
:=
cmd
.
Run
();
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error stopping VM: %s"
,
err
))
}
}
}
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