fix(datasource/CloudSigma): Make sure DHCP has run

This commit is contained in:
Kiril Vladimirov 2014-11-17 15:27:26 +02:00
parent b6062f0644
commit ea95920f31

View File

@ -21,6 +21,7 @@ import (
"encoding/base64"
"encoding/json"
"errors"
"io/ioutil"
"net"
"os"
"strings"
@ -54,7 +55,8 @@ func (_ *serverContextService) IsAvailable() bool {
}
productName := make([]byte, 10)
_, err = productNameFile.Read(productName)
return err == nil && string(productName) == "CloudSigma"
return err == nil && string(productName) == "CloudSigma" && hasDHCPLeases()
}
func (_ *serverContextService) AvailabilityChanges() bool {
@ -197,3 +199,8 @@ func isBase64Encoded(field string, userdata map[string]string) bool {
}
return false
}
func hasDHCPLeases() bool {
files, err := ioutil.ReadDir("/run/systemd/netif/leases/")
return err == nil && len(files) > 0
}