blob: 3b8977a0842615a9b5ff9312ecbf6c57f249e2be [file] [log] [blame]
Mark Peek5a9151f2013-08-17 18:59:59 -07001package main
2
3import (
4 "flag"
5 "fmt"
Max Lincoln75e06ec2013-12-13 00:00:12 -03006 "github.com/maxlinc/gophercloud"
Mark Peek5a9151f2013-08-17 18:59:59 -07007)
8
9var quiet = flag.Bool("quiet", false, "Quiet mode for acceptance testing. $? non-zero on error though.")
Samuel A. Falvo IIe4a3e422013-09-13 12:36:37 -070010var rgn = flag.String("r", "", "Datacenter region to interrogate. Leave blank for provider-default region.")
Mark Peek5a9151f2013-08-17 18:59:59 -070011
12func 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}