Samuel A. Falvo II | bc3f10f | 2013-07-11 17:13:24 -0700 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
Samuel A. Falvo II | bc3f10f | 2013-07-11 17:13:24 -0700 | [diff] [blame] | 4 | "flag" |
Jon Perritt | 2be65d1 | 2013-12-13 17:21:09 -0600 | [diff] [blame] | 5 | "fmt" |
Max Lincoln | 28b4956 | 2013-12-13 13:23:44 -0300 | [diff] [blame] | 6 | "github.com/rackspace/gophercloud" |
Samuel A. Falvo II | bc3f10f | 2013-07-11 17:13:24 -0700 | [diff] [blame] | 7 | ) |
| 8 | |
| 9 | var quiet = flag.Bool("quiet", false, "Quiet mode for acceptance testing. $? non-zero on error though.") |
Samuel A. Falvo II | e4a3e42 | 2013-09-13 12:36:37 -0700 | [diff] [blame] | 10 | var rgn = flag.String("r", "", "Datacenter region to interrogate. Leave blank for provider-default region.") |
Samuel A. Falvo II | bc3f10f | 2013-07-11 17:13:24 -0700 | [diff] [blame] | 11 | |
| 12 | func main() { |
Samuel A. Falvo II | bc3f10f | 2013-07-11 17:13:24 -0700 | [diff] [blame] | 13 | flag.Parse() |
| 14 | |
Samuel A. Falvo II | 887d780 | 2013-07-29 17:55:37 -0700 | [diff] [blame] | 15 | withIdentity(false, func(auth gophercloud.AccessProvider) { |
| 16 | withServerApi(auth, func(servers gophercloud.CloudServersProvider) { |
| 17 | flavors, err := servers.ListFlavors() |
| 18 | if err != nil { |
| 19 | panic(err) |
| 20 | } |
Samuel A. Falvo II | bc3f10f | 2013-07-11 17:13:24 -0700 | [diff] [blame] | 21 | |
Samuel A. Falvo II | 887d780 | 2013-07-29 17:55:37 -0700 | [diff] [blame] | 22 | if !*quiet { |
| 23 | fmt.Println("ID,Name,MinRam,MinDisk") |
| 24 | for _, f := range flavors { |
| 25 | fmt.Printf("%s,\"%s\",%d,%d\n", f.Id, f.Name, f.Ram, f.Disk) |
| 26 | } |
| 27 | } |
| 28 | }) |
Samuel A. Falvo II | bc3f10f | 2013-07-11 17:13:24 -0700 | [diff] [blame] | 29 | }) |
Samuel A. Falvo II | bc3f10f | 2013-07-11 17:13:24 -0700 | [diff] [blame] | 30 | } |