Jamie Hannaford | 05d200d | 2015-02-20 14:49:05 +0100 | [diff] [blame^] | 1 | // +build acceptance db |
| 2 | |
| 3 | package v1 |
| 4 | |
| 5 | import ( |
| 6 | config "github.com/rackspace/gophercloud/openstack/db/v1/configurations" |
| 7 | "github.com/rackspace/gophercloud/pagination" |
| 8 | ) |
| 9 | |
| 10 | func (c context) createConfigGrp() { |
| 11 | opts := config.CreateOpts{ |
| 12 | Name: tools.PrefixString("config_", 5), |
| 13 | Values: map[string]interface{}{ |
| 14 | "connect_timeout": 300, |
| 15 | "join_buffer_size": 900000, |
| 16 | }, |
| 17 | } |
| 18 | |
| 19 | cg, err := config.Create(c.client, opts) |
| 20 | |
| 21 | c.AssertNoErr(err) |
| 22 | c.Logf("Created config group %#v", cg) |
| 23 | |
| 24 | c.configGroupID = cg.ID |
| 25 | } |
| 26 | |
| 27 | func (c context) getConfigGrp() { |
| 28 | cg, err := config.Get(c.client, c.configGroupID) |
| 29 | c.Logf("Getting config group: %#v", cg) |
| 30 | c.AssertNoErr(err) |
| 31 | } |
| 32 | |
| 33 | func (c context) updateConfigGrp() { |
| 34 | opts := config.UpdateOpts{ |
| 35 | Name: tools.PrefixString("new_name_", 5), |
| 36 | Values: map[string]interface{}{ |
| 37 | "connect_timeout": 250, |
| 38 | }, |
| 39 | } |
| 40 | err := config.Update(c.client, c.configGroupID, opts).ExtractErr() |
| 41 | c.Logf("Updated config group %s", c.configGroupID) |
| 42 | c.AssertNoErr(err) |
| 43 | } |
| 44 | |
| 45 | func (c context) replaceConfigGrp() { |
| 46 | opts := config.UpdateOpts{ |
| 47 | Values: map[string]interface{}{ |
| 48 | "expire_logs_days": 7, |
| 49 | }, |
| 50 | } |
| 51 | |
| 52 | err := config.Replace(c.client, c.configGroupID, opts).ExtractErr() |
| 53 | c.Logf("Replaced values for config group %s", c.configGroupID) |
| 54 | c.AssertNoErr(err) |
| 55 | } |
| 56 | |
| 57 | func (c context) associateInstanceWithConfigGrp() { |
| 58 | err := config.AssociateWithConfigGroup(c.client, c.instanceID, c.configGroupID).ExtractErr() |
| 59 | c.Logf("Associated instance %s with config group %s", c.instanceID, c.configGroupID) |
| 60 | c.AssertNoErr(err) |
| 61 | } |
| 62 | |
| 63 | func (c context) listConfigGrpInstances() { |
| 64 | c.Logf("Listing all instances associated with config group %s", c.configGroupID) |
| 65 | |
| 66 | err := config.ListInstances(c.client, c.configGroupID).EachPage(func(page pagination.Page) (bool, error) { |
| 67 | instanceList, err := instances.ExtractInstances(page) |
| 68 | c.AssertNoErr(err) |
| 69 | |
| 70 | for _, n := range networkList { |
| 71 | c.Logf("Instance: %#v", instance) |
| 72 | } |
| 73 | |
| 74 | return true, nil |
| 75 | }) |
| 76 | |
| 77 | c.CheckNoErr(err) |
| 78 | } |
| 79 | |
| 80 | func (c context) deleteConfigGrp() { |
| 81 | err := config.Delete(c.client, c.configGroupID).ExtractErr() |
| 82 | c.Logf("Deleted config group %s", c.configGroupID) |
| 83 | c.AssertNoErr(err) |
| 84 | } |