mirror of
https://github.com/rancher/os.git
synced 2025-07-15 15:51:36 +00:00
Get dhcp lease only for ipv4
This commit is contained in:
parent
7250ee8ab4
commit
b5dd1d3f1c
@ -256,20 +256,21 @@ func getDhcpLease(iface string) (lease map[string]string) {
|
||||
}
|
||||
|
||||
func getDhcpLeaseString(iface string) []byte {
|
||||
cmd := exec.Command("dhcpcd", "-U", iface)
|
||||
args := defaultDhcpArgs
|
||||
args = append(args, "-U", iface)
|
||||
cmd := exec.Command(args[0], args[1:]...)
|
||||
//cmd.Stderr = os.Stderr
|
||||
out, err := cmd.Output()
|
||||
log.Debugf("Running dhcpcd -U %s, output: %s", iface, string(out))
|
||||
log.Debugf("Running cmd: %s, output: %s", args, string(out))
|
||||
if err != nil {
|
||||
// dhcpcd works fine, but gets an error: exit status 1
|
||||
log.Warnf("Got error with dhcpcd -U %s: %v", iface, err)
|
||||
log.Warnf("Failed to run cmd: %s, error: %v", args, err)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func hasDhcp(iface string) bool {
|
||||
out := getDhcpLeaseString(iface)
|
||||
log.Debugf("dhcpcd -U %s: %s", iface, out)
|
||||
return len(out) > 0
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user