blob: af972418292f1072d5749d39065294c9255320af [file] [log] [blame]
Jamie Hannaford80c70672015-10-06 16:09:33 +02001// +build acceptance db rackspace
Jamie Hannaford05d200d2015-02-20 14:49:05 +01002
3package v1
4
5import (
Jon Perritt27249f42016-02-18 10:35:59 -06006 "github.com/gophercloud/gophercloud/acceptance/tools"
7 "github.com/gophercloud/gophercloud/rackspace/db/v1/instances"
8 th "github.com/gophercloud/gophercloud/testhelper"
Jamie Hannaford05d200d2015-02-20 14:49:05 +01009)
10
Jamie Hannaford99eced52015-03-02 15:24:22 +010011func (c *context) createReplica() {
Jamie Hannaford05d200d2015-02-20 14:49:05 +010012 opts := instances.CreateOpts{
Jamie Hannaford99eced52015-03-02 15:24:22 +010013 FlavorRef: "2",
Jamie Hannaford05d200d2015-02-20 14:49:05 +010014 Size: 1,
15 Name: tools.RandomString("gopher_db", 5),
16 ReplicaOf: c.instanceID,
17 }
18
Jamie Hannaford11108402015-02-23 10:31:41 +010019 repl, err := instances.Create(c.client, opts).Extract()
Jamie Hannaford05d200d2015-02-20 14:49:05 +010020 th.AssertNoErr(c.test, err)
21
22 c.Logf("Creating replica of %s. Waiting...", c.instanceID)
Jamie Hannaford11108402015-02-23 10:31:41 +010023 c.WaitUntilActive(repl.ID)
Jamie Hannaford05d200d2015-02-20 14:49:05 +010024 c.Logf("Created replica %#v", repl)
25
26 c.replicaID = repl.ID
27}
28
Jamie Hannaford99eced52015-03-02 15:24:22 +010029func (c *context) detachReplica() {
Jamie Hannaford05d200d2015-02-20 14:49:05 +010030 err := instances.DetachReplica(c.client, c.replicaID).ExtractErr()
31 c.Logf("Detached replica %s", c.replicaID)
Jamie Hannaford11108402015-02-23 10:31:41 +010032 c.AssertNoErr(err)
Jamie Hannaford05d200d2015-02-20 14:49:05 +010033}