Add HostIP implementation for parallels driver
parent
49905d8fea
commit
c22a92f9bf
|
@ -72,6 +72,25 @@ func HostIP(host *host.Host) (net.IP, error) {
|
|||
re = regexp.MustCompile(`(?s)Name:\s*` + iface + `.+IPAddress:\s*(\S+)`)
|
||||
ip := re.FindStringSubmatch(string(ipList))[1]
|
||||
return net.ParseIP(ip), nil
|
||||
case driver.Parallels:
|
||||
cmd := "prlsrvctl"
|
||||
var cmdPath string
|
||||
if fullPath, err := exec.LookPath(cmd); err != nil {
|
||||
cmdPath = fullPath
|
||||
} else {
|
||||
cmdPath = cmd
|
||||
}
|
||||
out, err := exec.Command(cmdPath, "net", "info", "Shared").Output()
|
||||
if err != nil {
|
||||
return []byte{}, errors.Wrap(err, "Error reading the info of Parallels Shared network interface")
|
||||
}
|
||||
re := regexp.MustCompile(`IPv4 address: (.*)`)
|
||||
ipMatch := re.FindStringSubmatch(string(out))
|
||||
if len(ipMatch) < 2 {
|
||||
return []byte{}, errors.Wrap(err, "Error getting the IP address of Parallels Shared network interface")
|
||||
}
|
||||
ip := ipMatch[1]
|
||||
return net.ParseIP(ip), nil
|
||||
case driver.HyperKit:
|
||||
return net.ParseIP("192.168.64.1"), nil
|
||||
case driver.VMware:
|
||||
|
|
Loading…
Reference in New Issue