Merge pull request #6096 from arizvisa/GH-5882
Fixes the DHCP lease and configuration pathfinders for VMware Player.
This commit is contained in:
commit
f2df7a45ba
|
@ -296,6 +296,7 @@ func (d *VmwareDriver) GuestAddress(state multistep.StateBag) (string, error) {
|
|||
return "", errors.New("couldn't find MAC address in VMX")
|
||||
}
|
||||
}
|
||||
log.Printf("GuestAddress found MAC address in VMX: %s", macAddress)
|
||||
|
||||
res, err := net.ParseMAC(macAddress)
|
||||
if err != nil {
|
||||
|
@ -317,6 +318,11 @@ func (d *VmwareDriver) GuestIP(state multistep.StateBag) (string, error) {
|
|||
network := state.Get("vmnetwork").(string)
|
||||
devices, err := netmap.NameIntoDevices(network)
|
||||
|
||||
// log them to see what was detected
|
||||
for _, device := range devices {
|
||||
log.Printf("GuestIP discovered device matching %s: %s", network, device)
|
||||
}
|
||||
|
||||
// we were unable to find the device, maybe it's a custom one...
|
||||
// so, check to see if it's in the .vmx configuration
|
||||
if err != nil || network == "custom" {
|
||||
|
@ -332,6 +338,7 @@ func (d *VmwareDriver) GuestIP(state multistep.StateBag) (string, error) {
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
log.Printf("GuestIP discovered custom device matching %s: %s", network, device)
|
||||
}
|
||||
|
||||
// figure out our MAC address for looking up the guest address
|
||||
|
@ -415,6 +422,11 @@ func (d *VmwareDriver) HostAddress(state multistep.StateBag) (string, error) {
|
|||
network := state.Get("vmnetwork").(string)
|
||||
devices, err := netmap.NameIntoDevices(network)
|
||||
|
||||
// log them to see what was detected
|
||||
for _, device := range devices {
|
||||
log.Printf("HostAddress discovered device matching %s: %s", network, device)
|
||||
}
|
||||
|
||||
// we were unable to find the device, maybe it's a custom one...
|
||||
// so, check to see if it's in the .vmx configuration
|
||||
if err != nil || network == "custom" {
|
||||
|
@ -430,6 +442,7 @@ func (d *VmwareDriver) HostAddress(state multistep.StateBag) (string, error) {
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
log.Printf("HostAddress discovered custom device matching %s: %s", network, device)
|
||||
}
|
||||
|
||||
var lastError error
|
||||
|
@ -488,6 +501,11 @@ func (d *VmwareDriver) HostIP(state multistep.StateBag) (string, error) {
|
|||
network := state.Get("vmnetwork").(string)
|
||||
devices, err := netmap.NameIntoDevices(network)
|
||||
|
||||
// log them to see what was detected
|
||||
for _, device := range devices {
|
||||
log.Printf("HostIP discovered device matching %s: %s", network, device)
|
||||
}
|
||||
|
||||
// we were unable to find the device, maybe it's a custom one...
|
||||
// so, check to see if it's in the .vmx configuration
|
||||
if err != nil || network == "custom" {
|
||||
|
@ -503,6 +521,7 @@ func (d *VmwareDriver) HostIP(state multistep.StateBag) (string, error) {
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
log.Printf("HostIP discovered custom device matching %s: %s", network, device)
|
||||
}
|
||||
|
||||
var lastError error
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
@ -157,6 +158,7 @@ func (d *Fusion5Driver) Verify() error {
|
|||
if _, err := os.Stat(pathNetworking); err != nil {
|
||||
return nil, fmt.Errorf("Could not find networking conf file: %s", pathNetworking)
|
||||
}
|
||||
log.Printf("Located networkmapper configuration file using Fusion5: %s", pathNetworking)
|
||||
|
||||
fd, err := os.Open(pathNetworking)
|
||||
if err != nil {
|
||||
|
|
|
@ -83,6 +83,7 @@ func (d *Fusion6Driver) Verify() error {
|
|||
if _, err := os.Stat(pathNetworking); err != nil {
|
||||
return nil, fmt.Errorf("Could not find networking conf file: %s", pathNetworking)
|
||||
}
|
||||
log.Printf("Located networkmapper configuration file using Fusion6: %s", pathNetworking)
|
||||
|
||||
fd, err := os.Open(pathNetworking)
|
||||
if err != nil {
|
||||
|
|
|
@ -201,14 +201,9 @@ func (d *Player5Driver) Verify() error {
|
|||
if _, err := os.Stat(pathNetmap); err != nil {
|
||||
return nil, fmt.Errorf("Could not find netmap conf file: %s", pathNetmap)
|
||||
}
|
||||
log.Printf("Located networkmapper configuration file using Player: %s", pathNetmap)
|
||||
|
||||
fd, err := os.Open(pathNetmap)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer fd.Close()
|
||||
|
||||
return ReadNetworkMap(fd)
|
||||
return ReadNetmapConfig(pathNetmap)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
|
@ -44,7 +45,24 @@ func playerDhcpLeasesPath(device string) string {
|
|||
log.Printf("Error finding VMware root: %s", err)
|
||||
return ""
|
||||
}
|
||||
return filepath.Join(base, device, "dhcpd/dhcpd.leases")
|
||||
|
||||
// Build the base path to VMware configuration for specified device: `/etc/vmware/${device}`
|
||||
devicebase := filepath.Join(base, device)
|
||||
|
||||
// Walk through a list of paths searching for the correct permutation...
|
||||
// ...as it appears that in >= WS14 and < WS14, the leases file may be labelled differently.
|
||||
|
||||
// Docs say we should expect: dhcpd/dhcpd.leases
|
||||
paths := []string{"dhcpd/dhcpd.leases", "dhcpd/dhcp.leases", "dhcp/dhcpd.leases", "dhcp/dhcp.leases"}
|
||||
for _, p := range paths {
|
||||
fp := filepath.Join(devicebase, p)
|
||||
if _, err := os.Stat(fp); !os.IsNotExist(err) {
|
||||
return fp
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("Error finding VMWare DHCP Server Leases (dhcpd.leases) under device path: %s", devicebase)
|
||||
return ""
|
||||
}
|
||||
|
||||
func playerVmDhcpConfPath(device string) string {
|
||||
|
@ -53,7 +71,24 @@ func playerVmDhcpConfPath(device string) string {
|
|||
log.Printf("Error finding VMware root: %s", err)
|
||||
return ""
|
||||
}
|
||||
return filepath.Join(base, device, "dhcp/dhcp.conf")
|
||||
|
||||
// Build the base path to VMware configuration for specified device: `/etc/vmware/${device}`
|
||||
devicebase := filepath.Join(base, device)
|
||||
|
||||
// Walk through a list of paths searching for the correct permutation...
|
||||
// ...as it appears that in >= WS14 and < WS14, the dhcp config may be labelled differently.
|
||||
|
||||
// Docs say we should expect: dhcp/dhcp.conf
|
||||
paths := []string{"dhcp/dhcp.conf", "dhcp/dhcpd.conf", "dhcpd/dhcp.conf", "dhcpd/dhcpd.conf"}
|
||||
for _, p := range paths {
|
||||
fp := filepath.Join(devicebase, p)
|
||||
if _, err := os.Stat(fp); !os.IsNotExist(err) {
|
||||
return fp
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("Error finding VMWare DHCP Server Configuration (dhcp.conf) under device path: %s", devicebase)
|
||||
return ""
|
||||
}
|
||||
|
||||
func playerVmnetnatConfPath(device string) string {
|
||||
|
|
|
@ -162,14 +162,9 @@ func (d *Workstation9Driver) Verify() error {
|
|||
if _, err := os.Stat(pathNetmap); err != nil {
|
||||
return nil, fmt.Errorf("Could not find netmap conf file: %s", pathNetmap)
|
||||
}
|
||||
log.Printf("Located networkmapper configuration file using Workstation: %s", pathNetmap)
|
||||
|
||||
fd, err := os.Open(pathNetmap)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer fd.Close()
|
||||
|
||||
return ReadNetworkMap(fd)
|
||||
return ReadNetmapConfig(pathNetmap)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue