Add logging around the DHCP discovery process

pull/3660/head
Thomas Stromberg 2019-02-12 13:57:02 -08:00
parent 0a5b64eeaf
commit f346e5628b
1 changed files with 6 additions and 0 deletions

View File

@ -25,6 +25,8 @@ import (
"os/exec"
"regexp"
"strings"
"github.com/docker/machine/libmachine/log"
)
const (
@ -46,6 +48,7 @@ func GetIPAddressByMACAddress(mac string) (string, error) {
}
func getIpAddressFromFile(mac, path string) (string, error) {
log.Infof("Searching for %s in %s ...", mac, path)
file, err := os.Open(path)
if err != nil {
return "", err
@ -56,8 +59,11 @@ func getIpAddressFromFile(mac, path string) (string, error) {
if err != nil {
return "", err
}
log.Infof("Found %d entries in %s!", len(dhcpEntries), path)
for _, dhcpEntry := range dhcpEntries {
log.Infof("dhcp entry: %+v", dhcpEntry)
if dhcpEntry.HWAddress == mac {
log.Infof("Found match: %s", mac)
return dhcpEntry.IPAddress, nil
}
}