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
09db84eb
Commit
09db84eb
authored
Jun 07, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: Verify VMware is ready
parent
05e047a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
3 deletions
+47
-3
builder/vmware/builder.go
builder/vmware/builder.go
+6
-1
builder/vmware/driver.go
builder/vmware/driver.go
+41
-2
No files found.
builder/vmware/builder.go
View file @
09db84eb
...
...
@@ -196,5 +196,10 @@ func (b *Builder) Cancel() {
func
(
b
*
Builder
)
newDriver
()
(
Driver
,
error
)
{
fusionAppPath
:=
"/Applications/VMware Fusion.app"
return
&
Fusion5Driver
{
fusionAppPath
},
nil
driver
:=
&
Fusion5Driver
{
fusionAppPath
}
if
err
:=
driver
.
Verify
();
err
!=
nil
{
return
nil
,
err
}
return
driver
,
nil
}
builder/vmware/driver.go
View file @
09db84eb
...
...
@@ -2,6 +2,8 @@ package vmware
import
(
"bytes"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
...
...
@@ -20,6 +22,12 @@ type Driver interface {
// Stop stops a VM specified by the path to the VMX given.
Stop
(
string
)
error
// Verify checks to make sure that this driver should function
// properly. This should check that all the files it will use
// appear to exist and so on. If everything is okay, this doesn't
// return an error. Otherwise, this returns an error.
Verify
()
error
}
// Fusion5Driver is a driver that can run VMWare Fusion 5.
...
...
@@ -29,8 +37,7 @@ type Fusion5Driver struct {
}
func
(
d
*
Fusion5Driver
)
CreateDisk
(
output
string
,
size
string
)
error
{
vdiskPath
:=
filepath
.
Join
(
d
.
AppPath
,
"Contents"
,
"Library"
,
"vmware-vdiskmanager"
)
cmd
:=
exec
.
Command
(
vdiskPath
,
"-c"
,
"-s"
,
size
,
"-a"
,
"lsilogic"
,
"-t"
,
"1"
,
output
)
cmd
:=
exec
.
Command
(
d
.
vdiskManagerPath
(),
"-c"
,
"-s"
,
size
,
"-a"
,
"lsilogic"
,
"-t"
,
"1"
,
output
)
if
err
:=
cmd
.
Run
();
err
!=
nil
{
return
err
}
...
...
@@ -73,6 +80,38 @@ func (d *Fusion5Driver) Stop(vmxPath string) error {
return
nil
}
func
(
d
*
Fusion5Driver
)
Verify
()
error
{
if
_
,
err
:=
os
.
Stat
(
d
.
AppPath
);
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
return
fmt
.
Errorf
(
"Fusion application not found at path: %s"
,
d
.
AppPath
)
}
return
err
}
if
_
,
err
:=
os
.
Stat
(
d
.
vmrunPath
());
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
return
fmt
.
Errorf
(
"Critical application 'vmrun' not found at path: %s"
,
d
.
vmrunPath
())
}
return
err
}
if
_
,
err
:=
os
.
Stat
(
d
.
vdiskManagerPath
());
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
return
fmt
.
Errorf
(
"Critical application vdisk manager not found at path: %s"
,
d
.
vdiskManagerPath
())
}
return
err
}
return
nil
}
func
(
d
*
Fusion5Driver
)
vdiskManagerPath
()
string
{
return
filepath
.
Join
(
d
.
AppPath
,
"Contents"
,
"Library"
,
"vmware-vdiskmanager"
)
}
func
(
d
*
Fusion5Driver
)
vmrunPath
()
string
{
return
filepath
.
Join
(
d
.
AppPath
,
"Contents"
,
"Library"
,
"vmrun"
)
}
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