From 28c533a5ec0691dc8fc7363082803d9ea729cc41 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Thu, 26 Oct 2023 14:46:41 +1100 Subject: [PATCH] really update content --- main.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/main.go b/main.go index 033e523..d5a2d78 100644 --- a/main.go +++ b/main.go @@ -85,8 +85,9 @@ func getScsiBusSharingVMs(client *govmomi.Client) error { //f := find.NewFinder(client.Client, true) pc := property.DefaultCollector(client.Client) + fmt.Printf("getScsiBusSharingVMs : Preparing views\n") + // Get a view of all the VMs - fmt.Printf("Getting VM listing\n") vms, err := m.CreateContainerView(ctx, client.ServiceContent.RootFolder, []string{"VirtualMachine"}, true) if err != nil { return err @@ -94,7 +95,6 @@ func getScsiBusSharingVMs(client *govmomi.Client) error { defer vms.Destroy(ctx) // Get a view of all the hosts - fmt.Printf("Getting host listing\n") hs, err := m.CreateContainerView(ctx, client.ServiceContent.RootFolder, []string{"HostSystem"}, true) if err != nil { return err @@ -102,6 +102,7 @@ func getScsiBusSharingVMs(client *govmomi.Client) error { defer hs.Destroy(ctx) // Retrieve all the VMs + fmt.Printf("Getting VM listing\n") var vmList []mo.VirtualMachine err = vms.Retrieve(ctx, []string{"VirtualMachine"}, nil, &vmList) if err != nil { @@ -111,6 +112,7 @@ func getScsiBusSharingVMs(client *govmomi.Client) error { fmt.Printf("Found %d VMs\n", len(vmList)) // Retrieve all the hosts + fmt.Printf("Getting host listing\n") var hsList []mo.HostSystem err = hs.Retrieve(ctx, []string{"HostSystem"}, nil, &hsList) if err != nil { @@ -251,8 +253,8 @@ func updateHtml(htmlContent string, heading string, newTable string) string { // goquery produces implicit nodes when parsing the input html, remove them now fmt.Printf("updateHtml whole doc : %s\n", h) - h = strings.Replace(h, "", "", 1) - h = strings.Replace(h, "", "", 1) + h = strings.Replace(h, "", "", -1) + h = strings.Replace(h, "", "", -1) return h } @@ -363,16 +365,14 @@ func main() { newContent := updateHtml(c.Body.Storage.Value, "wsdc-vc-npr.srv.westpac.com.au", newTable) fmt.Printf("New Content: %v\n", newContent) - /* - c.Body.Storage.Value = newContent + c.Body.Storage.Value = newContent - result, err := api.UpdateContent(c) - if err != nil { - fmt.Println(err) - return - } - fmt.Printf("result: %v\n", result) - */ + result, err := api.UpdateContent(c) + if err != nil { + fmt.Println(err) + return + } + fmt.Printf("result: %v\n", result) /* err = getScsiBusSharingVMs(c)