really update content
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-10-26 14:46:41 +11:00
parent 579b08162a
commit 28c533a5ec

26
main.go
View File

@@ -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, "<html><head></head><body>", "", 1)
h = strings.Replace(h, "</body></html>", "", 1)
h = strings.Replace(h, "<html><head></head><body>", "", -1)
h = strings.Replace(h, "</body></html>", "", -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)