optimisation
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-03-10 15:05:19 +11:00
parent 5087c2a646
commit 0e221eb9fa

18
main.go
View File

@@ -120,8 +120,7 @@ func main() {
// Login to vcenter
c, err = govmomi.NewClient(ctx, u, *vInsecure)
if err != nil {
fmt.Fprintf(os.Stderr, "Logging in error: %s\n", err)
os.Exit(1)
log.Fatalf("Logging in error: %s\n", err)
}
defer c.Logout(ctx)
@@ -163,12 +162,15 @@ func main() {
}
// Retrieve host properties
var hostProperties []mo.HostSystem
err = dcView.Retrieve(ctx, []string{"HostSystem"}, []string{"name", "hardware.systemInfo", "configManager"}, &hostProperties)
if err != nil {
log.Printf("Failed to retrieve host properties in datacenter %s: %v", dc.Name, err)
continue
}
/*
var hostProperties []mo.HostSystem
err = dcView.Retrieve(ctx, []string{"HostSystem"}, []string{"name", "hardware.systemInfo", "configManager"}, &hostProperties)
if err != nil {
log.Printf("Failed to retrieve host properties in datacenter %s: %v", dc.Name, err)
continue
}
*/
log.Printf("DC %s contains %d hosts\n", dc.Name, len(hosts))
// Print hosts
for _, host := range hosts {