blob: e2924735c942026a430065400b1c39a944ceaa7d [file] [log] [blame]
Mark Peek5a9151f2013-08-17 18:59:59 -07001package main
2
3import (
4 "flag"
5 "fmt"
6 "github.com/rackspace/gophercloud"
7)
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 name := randomString("ACPTTEST", 16)
18 kp := gophercloud.NewKeyPair{
19 Name: name,
20 }
21 keypair, err := servers.CreateKeyPair(kp)
22 if err != nil {
23 panic(err)
24 }
25 if !*quiet {
26 fmt.Printf("%s,%s,%s\n", keypair.Name, keypair.FingerPrint, keypair.PublicKey)
27 }
28
29 keypair, err = servers.ShowKeyPair(name)
30 if err != nil {
31 panic(err)
32 }
33 if !*quiet {
34 fmt.Printf("%s,%s,%s\n", keypair.Name, keypair.FingerPrint, keypair.PublicKey)
35 }
36
37 err = servers.DeleteKeyPair(name)
38 if err != nil {
39 panic(err)
40 }
41 })
42 })
43}