createServer() takes a key now.
diff --git a/acceptance/rackspace/compute/v2/servers_test.go b/acceptance/rackspace/compute/v2/servers_test.go
index af4bbe0..5359450 100644
--- a/acceptance/rackspace/compute/v2/servers_test.go
+++ b/acceptance/rackspace/compute/v2/servers_test.go
@@ -38,14 +38,20 @@
th.AssertNoErr(t, err)
name := tools.RandomString("Gophercloud-", 8)
- t.Logf("Creating server [%s].", name)
- s, err := servers.Create(client, &servers.CreateOpts{
+
+ opts := &servers.CreateOpts{
Name: name,
ImageRef: options.imageID,
FlavorRef: options.flavorID,
- KeyPair: keyName,
DiskConfig: diskconfig.Manual,
- }).Extract()
+ }
+
+ if keyName != "" {
+ opts.KeyPair = keyName
+ }
+
+ t.Logf("Creating server [%s].", name)
+ s, err := servers.Create(client, opts).Extract()
th.AssertNoErr(t, err)
t.Logf("Creating server.")
diff --git a/acceptance/rackspace/compute/v2/virtualinterfaces_test.go b/acceptance/rackspace/compute/v2/virtualinterfaces_test.go
index 446d3a3..39475e1 100644
--- a/acceptance/rackspace/compute/v2/virtualinterfaces_test.go
+++ b/acceptance/rackspace/compute/v2/virtualinterfaces_test.go
@@ -3,51 +3,51 @@
package v2
import (
- "testing"
+ "testing"
- "github.com/rackspace/gophercloud/pagination"
- "github.com/rackspace/gophercloud/rackspace/compute/v2/networks"
- "github.com/rackspace/gophercloud/rackspace/compute/v2/virtualinterfaces"
- th "github.com/rackspace/gophercloud/testhelper"
+ "github.com/rackspace/gophercloud/pagination"
+ "github.com/rackspace/gophercloud/rackspace/compute/v2/networks"
+ "github.com/rackspace/gophercloud/rackspace/compute/v2/virtualinterfaces"
+ th "github.com/rackspace/gophercloud/testhelper"
)
func TestVirtualInterfaces(t *testing.T) {
- client, err := newClient()
- th.AssertNoErr(t, err)
+ client, err := newClient()
+ th.AssertNoErr(t, err)
- // Create a server
- server := createServer(t, client)
- t.Logf("Created Server: %v\n", server)
- defer deleteServer(t, client, server)
- serverID := server.ID
+ // Create a server
+ server := createServer(t, client, "")
+ t.Logf("Created Server: %v\n", server)
+ defer deleteServer(t, client, server)
+ serverID := server.ID
- // Create a network
- n, err := networks.Create(client, networks.CreateOpts{Label: "sample_network", CIDR: "172.20.0.0/24"}).Extract()
- th.AssertNoErr(t, err)
- t.Logf("Created Network: %v\n", n)
- defer networks.Delete(client, n.ID)
- networkID := n.ID
+ // Create a network
+ n, err := networks.Create(client, networks.CreateOpts{Label: "sample_network", CIDR: "172.20.0.0/24"}).Extract()
+ th.AssertNoErr(t, err)
+ t.Logf("Created Network: %v\n", n)
+ defer networks.Delete(client, n.ID)
+ networkID := n.ID
- // Create a virtual interface
- vi, err := virtualinterfaces.Create(client, serverID, networkID).Extract()
- th.AssertNoErr(t, err)
- t.Logf("Created virtual interface: %+v\n", vi)
- defer virtualinterfaces.Delete(client, serverID, vi.ID)
+ // Create a virtual interface
+ vi, err := virtualinterfaces.Create(client, serverID, networkID).Extract()
+ th.AssertNoErr(t, err)
+ t.Logf("Created virtual interface: %+v\n", vi)
+ defer virtualinterfaces.Delete(client, serverID, vi.ID)
- // List virtual interfaces
- pager := virtualinterfaces.List(client, serverID)
- err = pager.EachPage(func(page pagination.Page) (bool, error) {
- t.Logf("--- Page ---")
+ // List virtual interfaces
+ pager := virtualinterfaces.List(client, serverID)
+ err = pager.EachPage(func(page pagination.Page) (bool, error) {
+ t.Logf("--- Page ---")
- virtualinterfacesList, err := virtualinterfaces.ExtractVirtualInterfaces(page)
- th.AssertNoErr(t, err)
+ virtualinterfacesList, err := virtualinterfaces.ExtractVirtualInterfaces(page)
+ th.AssertNoErr(t, err)
- for _, vi := range virtualinterfacesList {
- t.Logf("Virtual Interface: ID [%s] MAC Address [%s] IP Addresses [%v]",
- vi.ID, vi.MACAddress, vi.IPAddresses)
- }
+ for _, vi := range virtualinterfacesList {
+ t.Logf("Virtual Interface: ID [%s] MAC Address [%s] IP Addresses [%v]",
+ vi.ID, vi.MACAddress, vi.IPAddresses)
+ }
- return true, nil
- })
- th.CheckNoErr(t, err)
+ return true, nil
+ })
+ th.CheckNoErr(t, err)
}