From 0e221eb9faba3f9565e53196af0a6219183723f9 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Mon, 10 Mar 2025 15:05:19 +1100 Subject: [PATCH] optimisation --- main.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index d74d1ab..50c11ac 100644 --- a/main.go +++ b/main.go @@ -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 {