Samuel A. Falvo II | 2dd7d2f | 2014-06-30 16:18:08 -0700 | [diff] [blame] | 1 | // +build acceptance,old |
| 2 | |
Mark Peek | 5a9151f | 2013-08-17 18:59:59 -0700 | [diff] [blame] | 3 | package main |
| 4 | |
| 5 | import ( |
| 6 | "flag" |
| 7 | "fmt" |
| 8 | "github.com/rackspace/gophercloud" |
| 9 | ) |
| 10 | |
| 11 | 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] | 12 | 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] | 13 | |
| 14 | func main() { |
| 15 | flag.Parse() |
| 16 | |
| 17 | withIdentity(false, func(auth gophercloud.AccessProvider) { |
| 18 | withServerApi(auth, func(servers gophercloud.CloudServersProvider) { |
| 19 | name := randomString("ACPTTEST", 16) |
| 20 | kp := gophercloud.NewKeyPair{ |
| 21 | Name: name, |
| 22 | } |
| 23 | keypair, err := servers.CreateKeyPair(kp) |
| 24 | if err != nil { |
| 25 | panic(err) |
| 26 | } |
| 27 | if !*quiet { |
| 28 | fmt.Printf("%s,%s,%s\n", keypair.Name, keypair.FingerPrint, keypair.PublicKey) |
| 29 | } |
| 30 | |
| 31 | keypair, err = servers.ShowKeyPair(name) |
| 32 | if err != nil { |
| 33 | panic(err) |
| 34 | } |
| 35 | if !*quiet { |
| 36 | fmt.Printf("%s,%s,%s\n", keypair.Name, keypair.FingerPrint, keypair.PublicKey) |
| 37 | } |
| 38 | |
| 39 | err = servers.DeleteKeyPair(name) |
| 40 | if err != nil { |
| 41 | panic(err) |
| 42 | } |
| 43 | }) |
| 44 | }) |
| 45 | } |