Commit 9a622691 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge pull request #900 from pmyjavec/ws10-linux-driver

VMWare Workstation 10 driver for Linux
parents adee47a7 3ea4aa1a
...@@ -75,6 +75,11 @@ func NewDriver(dconfig *DriverConfig, config *SSHConfig) (Driver, error) { ...@@ -75,6 +75,11 @@ func NewDriver(dconfig *DriverConfig, config *SSHConfig) (Driver, error) {
} }
case "linux": case "linux":
drivers = []Driver{ drivers = []Driver{
&Workstation10Driver {
Workstation9Driver: Workstation9Driver {
SSHConfig: config,
},
},
&Workstation9Driver{ &Workstation9Driver{
SSHConfig: config, SSHConfig: config,
}, },
......
package common
import (
"os/exec"
"bytes"
"regexp"
"fmt"
"log"
"strings"
"runtime"
)
// Workstation10Driver is a driver that can run VMware Workstation 10
// installations. Current only tested for UNIX
type Workstation10Driver struct {
Workstation9Driver
}
func (d *Workstation10Driver) Clone(dst, src string) error {
cmd := exec.Command(d.Workstation9Driver.VmrunPath,
"-T", "ws",
"clone", src, dst,
"full")
if _, _, err := runAndLog(cmd); err != nil {
return err
}
return nil
}
func (d *Workstation10Driver) Verify() error {
if runtime.GOOS != "linux" {
return fmt.Errorf("can't used driver WS 10 not yet supported on: %s", runtime.GOOS)
}
if err := d.Workstation9Driver.Verify(); err != nil {
return err
}
//TODO(pmyjavec) there is a better way to find this, how?
//the default will suffice for now.
vmxpath := "/usr/lib/vmware/bin/vmware-vmx"
var stderr bytes.Buffer
cmd := exec.Command(vmxpath, "-v")
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return err
}
versionRe := regexp.MustCompile(`(?i)VMware Workstation (\d+\.\d+\.\d+)\s`)
matches := versionRe.FindStringSubmatch(stderr.String())
if matches == nil {
return fmt.Errorf(
"Couldn't find VMware WS version in output: %s", stderr.String())
}
log.Printf("Detected VMware WS version: %s", matches[1])
if !strings.HasPrefix(matches[1], "10.") {
return fmt.Errorf(
"WS 10 not detected. Got version: %s", matches[1])
}
return nil
}
// +build !windows // +build !windows
// These functions are compatible with WS 9 and 10 on *NIX
package common package common
import ( import (
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment