forked from docker/machine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
govc.go
41 lines (31 loc) · 786 Bytes
/
govc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* Copyright 2014 VMware, Inc. All rights reserved. Licensed under the Apache v2 License.
*/
package vmwarevsphere
import (
"bytes"
"os/exec"
"strings"
"github.com/docker/machine/libmachine/log"
)
var (
GovcCmd = "govc"
)
func govc(args ...string) error {
cmd := exec.Command(GovcCmd, args...)
log.Debugf("govc executing: %v %v", GovcCmd, strings.Join(args, " "))
if err := cmd.Run(); err != nil {
return err
}
return nil
}
func govcOutErr(args ...string) (string, string, error) {
cmd := exec.Command(GovcCmd, args...)
log.Debugf("govcOutErr executing: %v %v", GovcCmd, strings.Join(args, " "))
var stdout bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err := cmd.Run()
return stdout.String(), stderr.String(), err
}