blob: ad569882d7df87701406f7683e5170eada2fb4ba [file] [log] [blame]
Samuel A. Falvo IIbc3f10f2013-07-11 17:13:24 -07001package main
2
3import (
4 "fmt"
5 "flag"
6 "github.com/rackspace/gophercloud"
7)
8
9var quiet = flag.Bool("quiet", false, "Quiet mode for acceptance testing. $? non-zero on error though.")
10var rgn = flag.String("r", "DFW", "Datacenter region to interrogate.")
11
12func main() {
13 provider, username, password := getCredentials()
14 flag.Parse()
15
16 auth, err := gophercloud.Authenticate(
17 provider,
18 gophercloud.AuthOptions{
19 Username: username,
20 Password: password,
21 },
22 )
23 if err != nil {
24 panic(err)
25 }
26
27 servers, err := gophercloud.ServersApi(auth, gophercloud.ApiCriteria{
28 Name: "cloudServersOpenStack",
29 Region: *rgn,
30 VersionId: "2",
31 UrlChoice: gophercloud.PublicURL,
32 })
33 if err != nil {
34 panic(err)
35 }
36
37 flavors, err := servers.ListFlavors()
38 if err != nil {
39 panic(err)
40 }
41
42 if !*quiet {
43 fmt.Println("ID,Name,MinRam,MinDisk")
44 for _, f := range flavors {
45 fmt.Printf("%s,\"%s\",%d,%d\n", f.Id, f.Name, f.Ram, f.Disk)
46 }
47 }
48}