mirror of
https://github.com/rancher/os.git
synced 2025-07-06 19:38:37 +00:00
ignore vmware datasource when guestinfo is empty
This commit is contained in:
parent
ab4e0e590b
commit
e8b6c69fbf
@ -78,9 +78,14 @@ func (v VMWare) IsAvailable() bool {
|
||||
}
|
||||
if v.ovfFileName != "" {
|
||||
_, v.lastError = os.Stat(v.ovfFileName)
|
||||
return !os.IsNotExist(v.lastError)
|
||||
if !os.IsNotExist(v.lastError) {
|
||||
// when GuestInfo is empty, the DataSource should not be available.
|
||||
return v.checkGuestInfo()
|
||||
}
|
||||
return false
|
||||
}
|
||||
return vmcheck.IsVirtualWorld()
|
||||
// when GuestInfo is empty, the DataSource should not be available.
|
||||
return vmcheck.IsVirtualWorld() && v.checkGuestInfo()
|
||||
}
|
||||
|
||||
func readConfig(key string) (string, error) {
|
||||
@ -107,3 +112,23 @@ func urlDownload(url string) ([]byte, error) {
|
||||
client := pkg.NewHTTPClient()
|
||||
return client.GetRetry(url)
|
||||
}
|
||||
|
||||
func (v VMWare) checkGuestInfo() bool {
|
||||
userData, err := v.FetchUserdata()
|
||||
if err == nil && string(userData) != "" {
|
||||
return true
|
||||
}
|
||||
metadata, err := v.FetchMetadata()
|
||||
if err == nil {
|
||||
if metadata.Hostname != "" {
|
||||
return true
|
||||
}
|
||||
if len(metadata.NetworkConfig.DNS.Nameservers) > 0 || len(metadata.NetworkConfig.DNS.Search) > 0 {
|
||||
return true
|
||||
}
|
||||
if len(metadata.NetworkConfig.Interfaces) > 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user