Usage example of cloudstack-go,
package main import ( "encoding/json" "fmt" "log" "github.com/apache/cloudstack-go/cloudstack" ) func main() { acs_url := "https://<IP>/client/api" api_key := "" api_secret := "" validate_ssl := false // Create a new API client cs := cloudstack.NewAsyncClient(acs_url, api_key, api_secret, validate_ssl) p := cs.Host.NewListHostsParams() hosts, err := cs.Host.ListHosts(p) if err != nil { log.Fatalf("Error listing volumes: %s", err) } b, err := json.MarshalIndent(hosts.Hosts, "", " ") if err != nil { fmt.Println(err) } fmt.Printf(string(b)) }
package main import ( "encoding/json" "fmt" "log" "github.com/apache/cloudstack-go/cloudstack" ) func main() { acs_url := "https://<IP>/client/api" api_key := "" api_secret := "" // Create a new API client cs := cloudstack.NewAsyncClient(acs_url, api_key, api_secret, false) p := cs.Volume.NewListVolumesParams() p.SetListall(true) p.SetProjectid("<ProjectID>") vols, err := cs.Volume.ListVolumes(p) if err != nil { log.Fatalf("Error listing volumes: %s", err) } b, err := json.MarshalIndent(vols.Volumes, "", " ") if err != nil { fmt.Println(err) } fmt.Printf(string(b)) }
There was an error while loading. Please reload this page.