Finalize Rackspace acceptance tests and fix various things
diff --git a/acceptance/rackspace/db/v1/backup_test.go b/acceptance/rackspace/db/v1/backup_test.go
index 7c50e19..af60620 100644
--- a/acceptance/rackspace/db/v1/backup_test.go
+++ b/acceptance/rackspace/db/v1/backup_test.go
@@ -3,6 +3,7 @@
 package v1
 
 import (
+	"github.com/rackspace/gophercloud"
 	"github.com/rackspace/gophercloud/acceptance/tools"
 	"github.com/rackspace/gophercloud/pagination"
 
@@ -10,7 +11,7 @@
 	"github.com/rackspace/gophercloud/rackspace/db/v1/instances"
 )
 
-func (c context) createBackup() {
+func (c *context) createBackup() {
 	opts := backups.CreateOpts{
 		Name:       tools.RandomString("backup_", 5),
 		InstanceID: c.instanceID,
@@ -21,16 +22,28 @@
 	c.Logf("Created backup %#v", backup)
 	c.AssertNoErr(err)
 
+	err = gophercloud.WaitFor(60, func() (bool, error) {
+		b, err := backups.Get(c.client, backup.ID).Extract()
+		if err != nil {
+			return false, err
+		}
+		if b.Status == "COMPLETED" {
+			return true, nil
+		}
+		return false, nil
+	})
+	c.AssertNoErr(err)
+
 	c.backupID = backup.ID
 }
 
-func (c context) getBackup() {
+func (c *context) getBackup() {
 	backup, err := backups.Get(c.client, c.backupID).Extract()
 	c.AssertNoErr(err)
 	c.Logf("Getting backup %s", backup.ID)
 }
 
-func (c context) listAllBackups() {
+func (c *context) listAllBackups() {
 	c.Logf("Listing backups")
 
 	err := backups.List(c.client, nil).EachPage(func(page pagination.Page) (bool, error) {
@@ -47,7 +60,7 @@
 	c.AssertNoErr(err)
 }
 
-func (c context) listInstanceBackups() {
+func (c *context) listInstanceBackups() {
 	c.Logf("Listing backups for instance %s", c.instanceID)
 
 	err := instances.ListBackups(c.client, c.instanceID).EachPage(func(page pagination.Page) (bool, error) {
@@ -64,7 +77,7 @@
 	c.AssertNoErr(err)
 }
 
-func (c context) deleteBackup() {
+func (c *context) deleteBackup() {
 	err := backups.Delete(c.client, c.backupID).ExtractErr()
 	c.AssertNoErr(err)
 	c.Logf("Deleted backup %s", c.backupID)
diff --git a/acceptance/rackspace/db/v1/common.go b/acceptance/rackspace/db/v1/common.go
index 3d10904..61ef485 100644
--- a/acceptance/rackspace/db/v1/common.go
+++ b/acceptance/rackspace/db/v1/common.go
@@ -3,25 +3,25 @@
 package v1
 
 import (
-	"os"
 	"testing"
 
 	"github.com/rackspace/gophercloud"
-	"github.com/rackspace/gophercloud/openstack"
+	"github.com/rackspace/gophercloud/acceptance/tools"
 	"github.com/rackspace/gophercloud/rackspace"
 	"github.com/rackspace/gophercloud/rackspace/db/v1/instances"
 	th "github.com/rackspace/gophercloud/testhelper"
 )
 
 func newClient(t *testing.T) *gophercloud.ServiceClient {
-	ao, err := openstack.AuthOptionsFromEnv()
+	opts, err := rackspace.AuthOptionsFromEnv()
 	th.AssertNoErr(t, err)
+	opts = tools.OnlyRS(opts)
 
-	client, err := openstack.AuthenticatedClient(ao)
+	client, err := rackspace.AuthenticatedClient(opts)
 	th.AssertNoErr(t, err)
 
 	c, err := rackspace.NewDBV1(client, gophercloud.EndpointOpts{
-		Region: os.Getenv("RS_REGION_NAME"),
+		Region: "IAD",
 	})
 	th.AssertNoErr(t, err)
 
@@ -47,7 +47,11 @@
 }
 
 func (c context) Logf(msg string, args ...interface{}) {
-	c.test.Logf(msg, args)
+	if len(args) > 0 {
+		c.test.Logf(msg, args...)
+	} else {
+		c.test.Log(msg)
+	}
 }
 
 func (c context) AssertNoErr(err error) {
diff --git a/acceptance/rackspace/db/v1/config_group_test.go b/acceptance/rackspace/db/v1/config_group_test.go
index fba46a9..72bb1db 100644
--- a/acceptance/rackspace/db/v1/config_group_test.go
+++ b/acceptance/rackspace/db/v1/config_group_test.go
@@ -9,7 +9,7 @@
 	"github.com/rackspace/gophercloud/rackspace/db/v1/instances"
 )
 
-func (c context) createConfigGrp() {
+func (c *context) createConfigGrp() {
 	opts := config.CreateOpts{
 		Name: tools.RandomString("config_", 5),
 		Values: map[string]interface{}{
@@ -26,13 +26,13 @@
 	c.configGroupID = cg.ID
 }
 
-func (c context) getConfigGrp() {
+func (c *context) getConfigGrp() {
 	cg, err := config.Get(c.client, c.configGroupID).Extract()
 	c.Logf("Getting config group: %#v", cg)
 	c.AssertNoErr(err)
 }
 
-func (c context) updateConfigGrp() {
+func (c *context) updateConfigGrp() {
 	opts := config.UpdateOpts{
 		Name: tools.RandomString("new_name_", 5),
 		Values: map[string]interface{}{
@@ -44,7 +44,7 @@
 	c.AssertNoErr(err)
 }
 
-func (c context) replaceConfigGrp() {
+func (c *context) replaceConfigGrp() {
 	opts := config.UpdateOpts{
 		Values: map[string]interface{}{
 			"expire_logs_days": 7,
@@ -56,13 +56,13 @@
 	c.AssertNoErr(err)
 }
 
-func (c context) associateInstanceWithConfigGrp() {
+func (c *context) associateInstanceWithConfigGrp() {
 	err := instances.AssociateWithConfigGroup(c.client, c.instanceID, c.configGroupID).ExtractErr()
 	c.Logf("Associated instance %s with config group %s", c.instanceID, c.configGroupID)
 	c.AssertNoErr(err)
 }
 
-func (c context) listConfigGrpInstances() {
+func (c *context) listConfigGrpInstances() {
 	c.Logf("Listing all instances associated with config group %s", c.configGroupID)
 
 	err := config.ListInstances(c.client, c.configGroupID).EachPage(func(page pagination.Page) (bool, error) {
@@ -79,8 +79,14 @@
 	c.AssertNoErr(err)
 }
 
-func (c context) deleteConfigGrp() {
+func (c *context) deleteConfigGrp() {
 	err := config.Delete(c.client, c.configGroupID).ExtractErr()
 	c.Logf("Deleted config group %s", c.configGroupID)
 	c.AssertNoErr(err)
 }
+
+func (c *context) detachInstanceFromGrp() {
+	err := instances.DetachFromConfigGroup(c.client, c.instanceID).ExtractErr()
+	c.Logf("Detached instance %s from config groups", c.instanceID)
+	c.AssertNoErr(err)
+}
diff --git a/acceptance/rackspace/db/v1/database_test.go b/acceptance/rackspace/db/v1/database_test.go
index faaa7ca..6ccb80e 100644
--- a/acceptance/rackspace/db/v1/database_test.go
+++ b/acceptance/rackspace/db/v1/database_test.go
@@ -8,7 +8,7 @@
 	"github.com/rackspace/gophercloud/pagination"
 )
 
-func (c context) createDBs() {
+func (c *context) createDBs() {
 	dbs := []string{
 		tools.RandomString("db_", 5),
 		tools.RandomString("db_", 5),
@@ -28,7 +28,7 @@
 	c.DBIDs = dbs
 }
 
-func (c context) listDBs() {
+func (c *context) listDBs() {
 	c.Logf("Listing databases on instance %s", c.instanceID)
 
 	err := db.List(c.client, c.instanceID).EachPage(func(page pagination.Page) (bool, error) {
@@ -45,7 +45,7 @@
 	c.AssertNoErr(err)
 }
 
-func (c context) deleteDBs() {
+func (c *context) deleteDBs() {
 	for _, id := range c.DBIDs {
 		err := db.Delete(c.client, c.instanceID, id).ExtractErr()
 		c.AssertNoErr(err)
diff --git a/acceptance/rackspace/db/v1/flavor_test.go b/acceptance/rackspace/db/v1/flavor_test.go
index e5131c7..6253b52 100644
--- a/acceptance/rackspace/db/v1/flavor_test.go
+++ b/acceptance/rackspace/db/v1/flavor_test.go
@@ -16,7 +16,7 @@
 		c.AssertNoErr(err)
 
 		for _, f := range flavorList {
-			c.Logf("Flavor: %#v", f)
+			c.Logf("Flavor: ID [%s] Name [%s] RAM [%d]", f.ID, f.Name, f.RAM)
 		}
 
 		return true, nil
@@ -26,7 +26,7 @@
 }
 
 func (c context) getFlavor() {
-	flavor, err := flavors.Get(c.client, 1).Extract()
+	flavor, err := flavors.Get(c.client, "1").Extract()
 	c.Logf("Getting flavor %s", flavor.ID)
 	c.AssertNoErr(err)
 }
diff --git a/acceptance/rackspace/db/v1/instance_test.go b/acceptance/rackspace/db/v1/instance_test.go
index 4bc44ab..a510017 100644
--- a/acceptance/rackspace/db/v1/instance_test.go
+++ b/acceptance/rackspace/db/v1/instance_test.go
@@ -5,6 +5,7 @@
 import (
 	"testing"
 
+	"github.com/rackspace/gophercloud"
 	"github.com/rackspace/gophercloud/acceptance/tools"
 	"github.com/rackspace/gophercloud/pagination"
 	"github.com/rackspace/gophercloud/rackspace/db/v1/instances"
@@ -48,6 +49,7 @@
 	c.replaceConfigGrp()
 	c.associateInstanceWithConfigGrp()
 	c.listConfigGrpInstances()
+	c.detachInstanceFromGrp()
 	c.deleteConfigGrp()
 
 	// DATABASE tests
@@ -67,10 +69,11 @@
 	// TEARDOWN
 	c.deleteUsers()
 	c.deleteDBs()
+	c.detachAndDeleteReplica()
 	c.deleteInstance()
 }
 
-func (c context) createInstance() {
+func (c *context) createInstance() {
 	opts := instances.CreateOpts{
 		FlavorRef: "1",
 		Size:      1,
@@ -80,22 +83,23 @@
 	instance, err := instances.Create(c.client, opts).Extract()
 	th.AssertNoErr(c.test, err)
 
-	c.Logf("Restarting %s. Waiting...", instance.ID)
+	c.Logf("Creating %s. Waiting...", instance.ID)
 	c.WaitUntilActive(instance.ID)
-	c.Logf("Created DB %#v", instance.ID)
+	c.Logf("Created instance %s", instance.ID)
 
 	c.instanceID = instance.ID
 }
 
-func (c context) listInstances() {
+func (c *context) listInstances() {
 	c.Logf("Listing instances")
 
 	err := instances.List(c.client).EachPage(func(page pagination.Page) (bool, error) {
 		instanceList, err := instances.ExtractInstances(page)
 		c.AssertNoErr(err)
 
-		for _, instance := range instanceList {
-			c.Logf("Instance: %#v", instance)
+		for _, i := range instanceList {
+			c.Logf("Instance: ID [%s] Name [%s] Status [%s] VolSize [%d] Datastore Type [%s]",
+				i.ID, i.Name, i.Status, i.Volume.Size, i.Datastore.Type)
 		}
 
 		return true, nil
@@ -104,31 +108,31 @@
 	c.AssertNoErr(err)
 }
 
-func (c context) getInstance() {
+func (c *context) getInstance() {
 	instance, err := instances.Get(c.client, c.instanceID).Extract()
 	c.AssertNoErr(err)
 	c.Logf("Getting instance: %#v", instance)
 }
 
-func (c context) deleteInstance() {
+func (c *context) deleteInstance() {
 	err := instances.Delete(c.client, c.instanceID).ExtractErr()
 	c.AssertNoErr(err)
 	c.Logf("Deleted instance %s", c.instanceID)
 }
 
-func (c context) enableRootUser() {
+func (c *context) enableRootUser() {
 	_, err := instances.EnableRootUser(c.client, c.instanceID).Extract()
 	c.AssertNoErr(err)
 	c.Logf("Enabled root user on %s", c.instanceID)
 }
 
-func (c context) isRootEnabled() {
+func (c *context) isRootEnabled() {
 	enabled, err := instances.IsRootEnabled(c.client, c.instanceID)
 	c.AssertNoErr(err)
 	c.Logf("Is root enabled? %s", enabled)
 }
 
-func (c context) restartInstance() {
+func (c *context) restartInstance() {
 	id := c.instanceID
 	err := instances.RestartService(c.client, id).ExtractErr()
 	c.AssertNoErr(err)
@@ -137,7 +141,7 @@
 	c.Logf("Restarted %s", id)
 }
 
-func (c context) resizeInstance() {
+func (c *context) resizeInstance() {
 	id := c.instanceID
 	err := instances.ResizeInstance(c.client, id, "2").ExtractErr()
 	c.AssertNoErr(err)
@@ -146,7 +150,7 @@
 	c.Logf("Resized %s with flavorRef %s", id, "2")
 }
 
-func (c context) resizeVol() {
+func (c *context) resizeVol() {
 	id := c.instanceID
 	err := instances.ResizeVolume(c.client, id, 2).ExtractErr()
 	c.AssertNoErr(err)
@@ -155,8 +159,30 @@
 	c.Logf("Resized the volume of %s to %d GB", id, 2)
 }
 
-func (c context) getDefaultConfig() {
+func (c *context) getDefaultConfig() {
 	config, err := instances.GetDefaultConfig(c.client, c.instanceID).Extract()
 	c.Logf("Default config group for instance %s: %#v", c.instanceID, config)
 	c.AssertNoErr(err)
 }
+
+func (c *context) detachAndDeleteReplica() {
+	err := instances.DetachReplica(c.client, c.replicaID).ExtractErr()
+	c.AssertNoErr(err)
+	c.Logf("Detached replica %s from instance %s", c.replicaID, c.instanceID)
+
+	err = instances.Delete(c.client, c.replicaID).ExtractErr()
+	c.AssertNoErr(err)
+	c.Logf("Deleted replica %s", c.replicaID)
+
+	// Check that it's deleted
+	err = gophercloud.WaitFor(60, func() (bool, error) {
+		_, err := instances.Get(c.client, c.replicaID).Extract()
+		if casted, ok := err.(*gophercloud.UnexpectedResponseCodeError); ok && casted.Actual == 404 {
+			return true, nil
+		}
+		if err != nil {
+			return false, err
+		}
+		return false, nil
+	})
+}
diff --git a/acceptance/rackspace/db/v1/replica_test.go b/acceptance/rackspace/db/v1/replica_test.go
index 3da2881..26f0043 100644
--- a/acceptance/rackspace/db/v1/replica_test.go
+++ b/acceptance/rackspace/db/v1/replica_test.go
@@ -8,9 +8,9 @@
 	th "github.com/rackspace/gophercloud/testhelper"
 )
 
-func (c context) createReplica() {
+func (c *context) createReplica() {
 	opts := instances.CreateOpts{
-		FlavorRef: "1",
+		FlavorRef: "2",
 		Size:      1,
 		Name:      tools.RandomString("gopher_db", 5),
 		ReplicaOf: c.instanceID,
@@ -26,7 +26,7 @@
 	c.replicaID = repl.ID
 }
 
-func (c context) detachReplica() {
+func (c *context) detachReplica() {
 	err := instances.DetachReplica(c.client, c.replicaID).ExtractErr()
 	c.Logf("Detached replica %s", c.replicaID)
 	c.AssertNoErr(err)
diff --git a/acceptance/rackspace/db/v1/user_test.go b/acceptance/rackspace/db/v1/user_test.go
index 53cebc1..8408e6c 100644
--- a/acceptance/rackspace/db/v1/user_test.go
+++ b/acceptance/rackspace/db/v1/user_test.go
@@ -10,7 +10,7 @@
 	"github.com/rackspace/gophercloud/rackspace/db/v1/users"
 )
 
-func (c context) createUsers() {
+func (c *context) createUsers() {
 	c.users = []string{
 		tools.RandomString("user_", 5),
 		tools.RandomString("user_", 5),
@@ -44,7 +44,7 @@
 	c.AssertNoErr(err)
 }
 
-func (c context) listUsers() {
+func (c *context) listUsers() {
 	c.Logf("Listing users on instance %s", c.instanceID)
 
 	err := os.List(c.client, c.instanceID).EachPage(func(page pagination.Page) (bool, error) {
@@ -61,7 +61,7 @@
 	c.AssertNoErr(err)
 }
 
-func (c context) deleteUsers() {
+func (c *context) deleteUsers() {
 	for _, id := range c.users {
 		err := users.Delete(c.client, c.instanceID, id).ExtractErr()
 		c.AssertNoErr(err)
@@ -69,7 +69,7 @@
 	}
 }
 
-func (c context) changeUserPwd() {
+func (c *context) changeUserPwd() {
 	opts := os.BatchCreateOpts{}
 
 	for _, name := range c.users[:1] {
@@ -81,22 +81,23 @@
 	c.AssertNoErr(err)
 }
 
-func (c context) getUser() {
+func (c *context) getUser() {
 	user, err := users.Get(c.client, c.instanceID, c.users[0]).Extract()
 	c.Logf("Getting user %s", user)
 	c.AssertNoErr(err)
 }
 
-func (c context) updateUser() {
-	opts := os.CreateOpts{Name: tools.RandomString("new_name_", 5)}
+func (c *context) updateUser() {
+	opts := users.UpdateOpts{Name: tools.RandomString("new_name_", 5)}
 	err := users.Update(c.client, c.instanceID, c.users[0], opts).ExtractErr()
 	c.Logf("Updated user %s", c.users[0])
 	c.AssertNoErr(err)
+	c.users[0] = opts.Name
 }
 
-func (c context) listUserAccess() {
+func (c *context) listUserAccess() {
 	err := users.ListAccess(c.client, c.instanceID, c.users[0]).EachPage(func(page pagination.Page) (bool, error) {
-		dbList, err := db.ExtractDBs(page)
+		dbList, err := users.ExtractDBs(page)
 		c.AssertNoErr(err)
 
 		for _, db := range dbList {
@@ -109,14 +110,14 @@
 	c.AssertNoErr(err)
 }
 
-func (c context) grantUserAccess() {
+func (c *context) grantUserAccess() {
 	opts := db.BatchCreateOpts{db.CreateOpts{Name: c.DBIDs[0]}}
 	err := users.GrantAccess(c.client, c.instanceID, c.users[0], opts).ExtractErr()
 	c.Logf("Granted access for user %s to DB %s", c.users[0], c.DBIDs[0])
 	c.AssertNoErr(err)
 }
 
-func (c context) revokeUserAccess() {
+func (c *context) revokeUserAccess() {
 	dbName, userName := c.DBIDs[0], c.users[0]
 	err := users.RevokeAccess(c.client, c.instanceID, userName, dbName).ExtractErr()
 	c.Logf("Revoked access for user %s to DB %s", userName, dbName)