fix invalid properties
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
14
main.go
14
main.go
@@ -166,7 +166,7 @@ func main() {
|
|||||||
var hostProperties []mo.HostSystem
|
var hostProperties []mo.HostSystem
|
||||||
err = dcView.Retrieve(ctx, []string{"HostSystem"}, []string{"name", "hardware.systemInfo", "configManager"}, &hostProperties)
|
err = dcView.Retrieve(ctx, []string{"HostSystem"}, []string{"name", "hardware.systemInfo", "configManager"}, &hostProperties)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to retrieve host properties: %v", err)
|
log.Printf("Failed to retrieve host properties in datacenter %s: %v", dc.Name, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,20 +175,20 @@ func main() {
|
|||||||
clusterName := ""
|
clusterName := ""
|
||||||
var hs mo.HostSystem
|
var hs mo.HostSystem
|
||||||
|
|
||||||
err = host.Properties(ctx, host.Reference(), []string{"name", "Parent"}, &hs)
|
err = host.Properties(ctx, host.Reference(), []string{"name", "parent"}, &hs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to retrieve host properties: %v", err)
|
log.Printf("Failed to retrieve host %s parent properties: %v", hs.Name, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
dts, err := host.ConfigManager().DateTimeSystem(ctx)
|
dts, err := host.ConfigManager().DateTimeSystem(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("error: %s\n", err)
|
log.Printf("Failed to get datetime system for host %s: %v", hs.Name, err)
|
||||||
os.Exit(1)
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the current ESXi time which is UTC
|
||||||
hostTime, err := dts.Query(ctx)
|
hostTime, err := dts.Query(ctx)
|
||||||
//fmt.Printf(" - Host: %s; Time: %v\n", hs.Name, hostTime)
|
|
||||||
|
|
||||||
// Convert ESXi UTC time to local time
|
// Convert ESXi UTC time to local time
|
||||||
esxiTimeLocal := hostTime.Local()
|
esxiTimeLocal := hostTime.Local()
|
||||||
@@ -217,6 +217,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hostTimeErrors = append(hostTimeErrors, thisResult)
|
hostTimeErrors = append(hostTimeErrors, thisResult)
|
||||||
|
} else {
|
||||||
|
log.Printf("[%s] Host: %s; Time: %v\n", dc.Name, hs.Name, hostTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user