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
6b04876e
Commit
6b04876e
authored
Jun 20, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: Log the output of various commands
parent
8b728794
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
7 deletions
+21
-7
builder/vmware/driver.go
builder/vmware/driver.go
+21
-7
No files found.
builder/vmware/driver.go
View file @
6b04876e
...
...
@@ -3,6 +3,7 @@ package vmware
import
(
"bytes"
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
...
...
@@ -38,7 +39,7 @@ type Fusion5Driver struct {
func
(
d
*
Fusion5Driver
)
CreateDisk
(
output
string
,
size
string
)
error
{
cmd
:=
exec
.
Command
(
d
.
vdiskManagerPath
(),
"-c"
,
"-s"
,
size
,
"-a"
,
"lsilogic"
,
"-t"
,
"1"
,
output
)
if
err
:=
cmd
.
Run
(
);
err
!=
nil
{
if
_
,
_
,
err
:=
d
.
runAndLog
(
cmd
);
err
!=
nil
{
return
err
}
...
...
@@ -51,14 +52,13 @@ func (d *Fusion5Driver) IsRunning(vmxPath string) (bool, error) {
return
false
,
err
}
stdout
:=
new
(
bytes
.
Buffer
)
cmd
:=
exec
.
Command
(
d
.
vmrunPath
(),
"-T"
,
"fusion"
,
"list"
)
cmd
.
Stdout
=
stdout
if
err
:=
cmd
.
Run
();
err
!=
nil
{
stdout
,
_
,
err
:=
d
.
runAndLog
(
cmd
)
if
err
!=
nil
{
return
false
,
err
}
for
_
,
line
:=
range
strings
.
Split
(
stdout
.
String
()
,
"
\n
"
)
{
for
_
,
line
:=
range
strings
.
Split
(
stdout
,
"
\n
"
)
{
if
line
==
vmxPath
{
return
true
,
nil
}
...
...
@@ -69,7 +69,7 @@ func (d *Fusion5Driver) IsRunning(vmxPath string) (bool, error) {
func
(
d
*
Fusion5Driver
)
Start
(
vmxPath
string
)
error
{
cmd
:=
exec
.
Command
(
d
.
vmrunPath
(),
"-T"
,
"fusion"
,
"start"
,
vmxPath
,
"gui"
)
if
err
:=
cmd
.
Run
(
);
err
!=
nil
{
if
_
,
_
,
err
:=
d
.
runAndLog
(
cmd
);
err
!=
nil
{
return
err
}
...
...
@@ -78,7 +78,7 @@ func (d *Fusion5Driver) Start(vmxPath string) error {
func
(
d
*
Fusion5Driver
)
Stop
(
vmxPath
string
)
error
{
cmd
:=
exec
.
Command
(
d
.
vmrunPath
(),
"-T"
,
"fusion"
,
"stop"
,
vmxPath
,
"hard"
)
if
err
:=
cmd
.
Run
(
);
err
!=
nil
{
if
_
,
_
,
err
:=
d
.
runAndLog
(
cmd
);
err
!=
nil
{
return
err
}
...
...
@@ -120,3 +120,17 @@ func (d *Fusion5Driver) vdiskManagerPath() string {
func
(
d
*
Fusion5Driver
)
vmrunPath
()
string
{
return
filepath
.
Join
(
d
.
AppPath
,
"Contents"
,
"Library"
,
"vmrun"
)
}
func
(
d
*
Fusion5Driver
)
runAndLog
(
cmd
*
exec
.
Cmd
)
(
string
,
string
,
error
)
{
var
stdout
,
stderr
bytes
.
Buffer
log
.
Printf
(
"Executing: %s %v"
,
cmd
.
Path
,
cmd
.
Args
[
1
:
])
cmd
.
Stdout
=
&
stdout
cmd
.
Stderr
=
&
stderr
err
:=
cmd
.
Run
()
log
.
Printf
(
"stdout: %s"
,
strings
.
TrimSpace
(
stdout
.
String
()))
log
.
Printf
(
"stderr: %s"
,
strings
.
TrimSpace
(
stderr
.
String
()))
return
stdout
.
String
(),
stderr
.
String
(),
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