fix(datasource/CloudSigma): Make sure DHCP has run
This commit is contained in:
parent
b6062f0644
commit
ea95920f31
@ -21,6 +21,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@ -54,7 +55,8 @@ func (_ *serverContextService) IsAvailable() bool {
|
|||||||
}
|
}
|
||||||
productName := make([]byte, 10)
|
productName := make([]byte, 10)
|
||||||
_, err = productNameFile.Read(productName)
|
_, err = productNameFile.Read(productName)
|
||||||
return err == nil && string(productName) == "CloudSigma"
|
|
||||||
|
return err == nil && string(productName) == "CloudSigma" && hasDHCPLeases()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ *serverContextService) AvailabilityChanges() bool {
|
func (_ *serverContextService) AvailabilityChanges() bool {
|
||||||
@ -197,3 +199,8 @@ func isBase64Encoded(field string, userdata map[string]string) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hasDHCPLeases() bool {
|
||||||
|
files, err := ioutil.ReadDir("/run/systemd/netif/leases/")
|
||||||
|
return err == nil && len(files) > 0
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user