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

12
main.go
View File

@@ -85,8 +85,9 @@ func getScsiBusSharingVMs(client *govmomi.Client) error {
//f := find.NewFinder(client.Client, true) //f := find.NewFinder(client.Client, true)
pc := property.DefaultCollector(client.Client) pc := property.DefaultCollector(client.Client)
fmt.Printf("getScsiBusSharingVMs : Preparing views\n")
// Get a view of all the VMs // Get a view of all the VMs
fmt.Printf("Getting VM listing\n")
vms, err := m.CreateContainerView(ctx, client.ServiceContent.RootFolder, []string{"VirtualMachine"}, true) vms, err := m.CreateContainerView(ctx, client.ServiceContent.RootFolder, []string{"VirtualMachine"}, true)
if err != nil { if err != nil {
return err return err
@@ -94,7 +95,6 @@ func getScsiBusSharingVMs(client *govmomi.Client) error {
defer vms.Destroy(ctx) defer vms.Destroy(ctx)
// Get a view of all the hosts // Get a view of all the hosts
fmt.Printf("Getting host listing\n")
hs, err := m.CreateContainerView(ctx, client.ServiceContent.RootFolder, []string{"HostSystem"}, true) hs, err := m.CreateContainerView(ctx, client.ServiceContent.RootFolder, []string{"HostSystem"}, true)
if err != nil { if err != nil {
return err return err
@@ -102,6 +102,7 @@ func getScsiBusSharingVMs(client *govmomi.Client) error {
defer hs.Destroy(ctx) defer hs.Destroy(ctx)
// Retrieve all the VMs // Retrieve all the VMs
fmt.Printf("Getting VM listing\n")
var vmList []mo.VirtualMachine var vmList []mo.VirtualMachine
err = vms.Retrieve(ctx, []string{"VirtualMachine"}, nil, &vmList) err = vms.Retrieve(ctx, []string{"VirtualMachine"}, nil, &vmList)
if err != nil { if err != nil {
@@ -111,6 +112,7 @@ func getScsiBusSharingVMs(client *govmomi.Client) error {
fmt.Printf("Found %d VMs\n", len(vmList)) fmt.Printf("Found %d VMs\n", len(vmList))
// Retrieve all the hosts // Retrieve all the hosts
fmt.Printf("Getting host listing\n")
var hsList []mo.HostSystem var hsList []mo.HostSystem
err = hs.Retrieve(ctx, []string{"HostSystem"}, nil, &hsList) err = hs.Retrieve(ctx, []string{"HostSystem"}, nil, &hsList)
if err != nil { 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 // goquery produces implicit nodes when parsing the input html, remove them now
fmt.Printf("updateHtml whole doc : %s\n", h) fmt.Printf("updateHtml whole doc : %s\n", h)
h = strings.Replace(h, "<html><head></head><body>", "", 1) h = strings.Replace(h, "<html><head></head><body>", "", -1)
h = strings.Replace(h, "</body></html>", "", 1) h = strings.Replace(h, "</body></html>", "", -1)
return h return h
} }
@@ -363,7 +365,6 @@ func main() {
newContent := updateHtml(c.Body.Storage.Value, "wsdc-vc-npr.srv.westpac.com.au", newTable) newContent := updateHtml(c.Body.Storage.Value, "wsdc-vc-npr.srv.westpac.com.au", newTable)
fmt.Printf("New Content: %v\n", newContent) fmt.Printf("New Content: %v\n", newContent)
/*
c.Body.Storage.Value = newContent c.Body.Storage.Value = newContent
result, err := api.UpdateContent(c) result, err := api.UpdateContent(c)
@@ -372,7 +373,6 @@ func main() {
return return
} }
fmt.Printf("result: %v\n", result) fmt.Printf("result: %v\n", result)
*/
/* /*
err = getScsiBusSharingVMs(c) err = getScsiBusSharingVMs(c)