Add support for keypairs
Adds support for the following keypair operations:
- ListKeyPairs yields the list of available keypairs.
- CreateKeyPairs will create or generate a new keypair.
- DeleteKeyPair wil delete a keypair.
- ShowKeyPair will yield the named keypair.
diff --git a/acceptance/16-create-delete-keypair.go b/acceptance/16-create-delete-keypair.go
new file mode 100644
index 0000000..efba4cf
--- /dev/null
+++ b/acceptance/16-create-delete-keypair.go
@@ -0,0 +1,43 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "github.com/rackspace/gophercloud"
+)
+
+var quiet = flag.Bool("quiet", false, "Quiet mode for acceptance testing. $? non-zero on error though.")
+var rgn = flag.String("r", "DFW", "Datacenter region to interrogate.")
+
+func main() {
+ flag.Parse()
+
+ withIdentity(false, func(auth gophercloud.AccessProvider) {
+ withServerApi(auth, func(servers gophercloud.CloudServersProvider) {
+ name := randomString("ACPTTEST", 16)
+ kp := gophercloud.NewKeyPair{
+ Name: name,
+ }
+ keypair, err := servers.CreateKeyPair(kp)
+ if err != nil {
+ panic(err)
+ }
+ if !*quiet {
+ fmt.Printf("%s,%s,%s\n", keypair.Name, keypair.FingerPrint, keypair.PublicKey)
+ }
+
+ keypair, err = servers.ShowKeyPair(name)
+ if err != nil {
+ panic(err)
+ }
+ if !*quiet {
+ fmt.Printf("%s,%s,%s\n", keypair.Name, keypair.FingerPrint, keypair.PublicKey)
+ }
+
+ err = servers.DeleteKeyPair(name)
+ if err != nil {
+ panic(err)
+ }
+ })
+ })
+}