Samuel A. Falvo II | 0a6e45a | 2013-07-11 17:00:41 -0700 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "flag" |
| 6 | "github.com/rackspace/gophercloud" |
| 7 | ) |
| 8 | |
| 9 | var quiet = flag.Bool("quiet", false, "Quiet mode for acceptance testing. $? non-zero on error though.") |
| 10 | var rgn = flag.String("r", "DFW", "Datacenter region to interrogate.") |
| 11 | |
| 12 | func main() { |
Samuel A. Falvo II | 0a6e45a | 2013-07-11 17:00:41 -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 | images, err := servers.ListImages() |
| 18 | if err != nil { |
| 19 | panic(err) |
| 20 | } |
Samuel A. Falvo II | 0a6e45a | 2013-07-11 17:00:41 -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 _, image := range images { |
| 25 | fmt.Printf("%s,\"%s\",%d,%d\n", image.Id, image.Name, image.MinRam, image.MinRam) |
| 26 | } |
| 27 | } |
| 28 | }) |
Samuel A. Falvo II | 0a6e45a | 2013-07-11 17:00:41 -0700 | [diff] [blame] | 29 | }) |
Samuel A. Falvo II | 0a6e45a | 2013-07-11 17:00:41 -0700 | [diff] [blame] | 30 | } |