Mark Peek | 5a9151f | 2013-08-17 18:59:59 -0700 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "flag" |
| 5 | "fmt" |
Max Lincoln | 75e06ec | 2013-12-13 00:00:12 -0300 | [diff] [blame] | 6 | "github.com/maxlinc/gophercloud" |
Mark Peek | 5a9151f | 2013-08-17 18:59:59 -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.") |
Mark Peek | 5a9151f | 2013-08-17 18:59:59 -0700 | [diff] [blame] | 11 | |
| 12 | func main() { |
| 13 | flag.Parse() |
| 14 | |
| 15 | withIdentity(false, func(auth gophercloud.AccessProvider) { |
| 16 | withServerApi(auth, func(servers gophercloud.CloudServersProvider) { |
| 17 | keypairs, err := servers.ListKeyPairs() |
| 18 | if err != nil { |
| 19 | panic(err) |
| 20 | } |
| 21 | |
| 22 | if !*quiet { |
| 23 | fmt.Println("name,fingerprint,publickey") |
| 24 | for _, key := range keypairs { |
| 25 | fmt.Printf("%s,%s,%s\n", key.Name, key.FingerPrint, key.PublicKey) |
| 26 | } |
| 27 | } |
| 28 | }) |
| 29 | }) |
| 30 | } |