blob: 7275a3259a09201c6b802c98cfec5c869fb71c61 [file] [log] [blame]
Jamie Hannaford6ee7d4a2015-02-09 17:26:49 +01001package instances
2
3import (
Jamie Hannaforde635b7d2015-02-18 14:11:46 +01004 "github.com/rackspace/gophercloud"
Jamie Hannaford52dbcee2015-10-06 16:09:56 +02005 "github.com/rackspace/gophercloud/openstack/db/v1/datastores"
Jamie Hannaford11108402015-02-23 10:31:41 +01006 "github.com/rackspace/gophercloud/openstack/db/v1/flavors"
Jamie Hannaforde635b7d2015-02-18 14:11:46 +01007 os "github.com/rackspace/gophercloud/openstack/db/v1/instances"
Jamie Hannaford6ee7d4a2015-02-09 17:26:49 +01008)
9
Jamie Hannaforde635b7d2015-02-18 14:11:46 +010010const instance = `
Jamie Hannaford39d4ffb2015-02-10 13:19:44 +010011{
12 "instance": {
13 "created": "2014-02-13T21:47:13",
14 "datastore": {
15 "type": "mysql",
16 "version": "5.6"
17 },
18 "flavor": {
19 "id": "1",
20 "links": [
21 {
22 "href": "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1",
23 "rel": "self"
24 },
25 {
26 "href": "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1",
27 "rel": "bookmark"
28 }
29 ]
30 },
31 "links": [
32 {
33 "href": "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1",
34 "rel": "self"
35 }
36 ],
37 "hostname": "e09ad9a3f73309469cf1f43d11e79549caf9acf2.rackspaceclouddb.com",
Jamie Hannaforde635b7d2015-02-18 14:11:46 +010038 "id": "{instanceID}",
Jamie Hannaford39d4ffb2015-02-10 13:19:44 +010039 "name": "json_rack_instance",
40 "status": "BUILD",
41 "updated": "2014-02-13T21:47:13",
42 "volume": {
43 "size": 2
44 }
45 }
46}
47`
48
Jamie Hannaforde635b7d2015-02-18 14:11:46 +010049var createReq = `
Jamie Hannaford6ee7d4a2015-02-09 17:26:49 +010050{
51 "instance": {
52 "databases": [
53 {
54 "character_set": "utf8",
55 "collate": "utf8_general_ci",
56 "name": "sampledb"
57 },
58 {
59 "name": "nextround"
60 }
61 ],
62 "flavorRef": "1",
63 "name": "json_rack_instance",
64 "users": [
65 {
66 "databases": [
67 {
68 "name": "sampledb"
69 }
70 ],
71 "name": "demouser",
72 "password": "demopassword"
73 }
74 ],
75 "volume": {
76 "size": 2
77 },
Jamie Hannaforde635b7d2015-02-18 14:11:46 +010078 "restorePoint": {
79 "backupRef": "1234567890"
80 }
Jamie Hannaford6ee7d4a2015-02-09 17:26:49 +010081 }
82}
Jamie Hannaforde635b7d2015-02-18 14:11:46 +010083`
Jamie Hannaford6ee7d4a2015-02-09 17:26:49 +010084
Jamie Hannaforde635b7d2015-02-18 14:11:46 +010085var createReplicaReq = `
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +010086{
87 "instance": {
88 "volume": {
89 "size": 1
90 },
91 "flavorRef": "9",
92 "name": "t2s1_ALT_GUEST",
93 "replica_of": "6bdca2fc-418e-40bd-a595-62abda61862d"
94 }
95}
Jamie Hannaforde635b7d2015-02-18 14:11:46 +010096`
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +010097
Jamie Hannaforde635b7d2015-02-18 14:11:46 +010098var createReplicaResp = `
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +010099{
100 "instance": {
101 "status": "BUILD",
102 "updated": "2014-10-14T18:42:15",
103 "name": "t2s1_ALT_GUEST",
104 "links": [
105 {
106 "href": "https://ord.databases.api.rackspacecloud.com/v1.0/5919009/instances/8367c312-7c40-4a66-aab1-5767478914fc",
107 "rel": "self"
108 },
109 {
110 "href": "https://ord.databases.api.rackspacecloud.com/instances/8367c312-7c40-4a66-aab1-5767478914fc",
111 "rel": "bookmark"
112 }
113 ],
114 "created": "2014-10-14T18:42:15",
115 "id": "8367c312-7c40-4a66-aab1-5767478914fc",
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100116 "volume": {
117 "size": 1
118 },
119 "flavor": {
120 "id": "9"
121 },
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +0100122 "datastore": {
123 "version": "5.6",
124 "type": "mysql"
125 },
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100126 "replica_of": {
127 "id": "6bdca2fc-418e-40bd-a595-62abda61862d"
128 }
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +0100129 }
130}
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100131`
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +0100132
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100133var listReplicasResp = `
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +0100134{
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100135 "instances": [
136 {
137 "status": "ACTIVE",
138 "name": "t1s1_ALT_GUEST",
139 "links": [
140 {
141 "href": "https://ord.databases.api.rackspacecloud.com/v1.0/1234/instances/3c691f06-bf9a-4618-b7ec-2817ce0cf254",
142 "rel": "self"
143 },
144 {
145 "href": "https://ord.databases.api.rackspacecloud.com/instances/3c691f06-bf9a-4618-b7ec-2817ce0cf254",
146 "rel": "bookmark"
147 }
148 ],
149 "ip": [
150 "10.0.0.3"
151 ],
152 "id": "3c691f06-bf9a-4618-b7ec-2817ce0cf254",
153 "volume": {
154 "size": 1
155 },
156 "flavor": {
157 "id": "9"
158 },
159 "datastore": {
160 "version": "5.6",
161 "type": "mysql"
162 },
163 "replica_of": {
164 "id": "8b499b45-52d6-402d-b398-f9d8f279c69a"
165 }
166 }
167 ]
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +0100168}
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100169`
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +0100170
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100171var getReplicaResp = `
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +0100172{
173 "instance": {
174 "status": "ACTIVE",
175 "updated": "2014-09-26T19:15:57",
176 "name": "t1_ALT_GUEST",
177 "created": "2014-09-26T19:15:50",
178 "ip": [
179 "10.0.0.2"
180 ],
181 "replicas": [
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100182 {
183 "id": "3c691f06-bf9a-4618-b7ec-2817ce0cf254"
184 }
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +0100185 ],
186 "id": "8b499b45-52d6-402d-b398-f9d8f279c69a",
187 "volume": {
188 "used": 0.54,
189 "size": 1
190 },
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100191 "flavor": {
192 "id": "9"
193 },
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +0100194 "datastore": {
195 "version": "5.6",
196 "type": "mysql"
197 }
198 }
199}
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100200`
201
202var detachReq = `
203{
204 "instance": {
205 "replica_of": "",
206 "slave_of": ""
207 }
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +0100208}
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100209`
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +0100210
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100211var getConfigResp = `
Jamie Hannaford936a5472015-02-10 14:38:28 +0100212{
213 "instance": {
214 "configuration": {
215 "basedir": "/usr",
216 "connect_timeout": "15",
217 "datadir": "/var/lib/mysql",
218 "default_storage_engine": "innodb",
219 "innodb_buffer_pool_instances": "1",
220 "innodb_buffer_pool_size": "175M",
221 "innodb_checksum_algorithm": "crc32",
222 "innodb_data_file_path": "ibdata1:10M:autoextend",
223 "innodb_file_per_table": "1",
224 "innodb_io_capacity": "200",
225 "innodb_log_file_size": "256M",
226 "innodb_log_files_in_group": "2",
227 "innodb_open_files": "8192",
228 "innodb_thread_concurrency": "0",
229 "join_buffer_size": "1M",
230 "key_buffer_size": "50M",
231 "local-infile": "0",
232 "log-error": "/var/log/mysql/mysqld.log",
233 "max_allowed_packet": "16M",
234 "max_connect_errors": "10000",
235 "max_connections": "40",
236 "max_heap_table_size": "16M",
237 "myisam-recover": "BACKUP",
238 "open_files_limit": "8192",
239 "performance_schema": "off",
240 "pid_file": "/var/run/mysqld/mysqld.pid",
241 "port": "3306",
242 "query_cache_limit": "1M",
243 "query_cache_size": "8M",
244 "query_cache_type": "1",
245 "read_buffer_size": "256K",
246 "read_rnd_buffer_size": "1M",
247 "server_id": "1",
248 "skip-external-locking": "1",
249 "skip_name_resolve": "1",
250 "sort_buffer_size": "256K",
251 "table_open_cache": "4096",
252 "thread_stack": "192K",
253 "tmp_table_size": "16M",
254 "tmpdir": "/var/tmp",
255 "user": "mysql",
256 "wait_timeout": "3600"
257 }
258 }
259}
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100260`
Jamie Hannafordf77fc102015-02-10 14:56:02 +0100261
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100262var associateReq = `{"instance": {"configuration": "{configGroupID}"}}`
Jamie Hannafordf77fc102015-02-10 14:56:02 +0100263
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100264var listBackupsResp = `
Jamie Hannaford2e817322015-02-16 15:29:17 +0100265{
266 "backups": [
267 {
268 "status": "COMPLETED",
269 "updated": "2014-06-18T21:24:39",
270 "description": "Backup from Restored Instance",
271 "datastore": {
272 "version": "5.1",
273 "type": "MySQL",
274 "version_id": "20000000-0000-0000-0000-000000000002"
275 },
276 "id": "87972694-4be2-40f5-83f8-501656e0032a",
277 "size": 0.141026,
278 "name": "restored_backup",
279 "created": "2014-06-18T21:23:35",
280 "instance_id": "29af2cd9-0674-48ab-b87a-b160f00208e6",
281 "parent_id": null,
282 "locationRef": "http://localhost/path/to/backup"
283 }
284 ]
285}
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100286`
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +0100287
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100288var (
289 createResp = instance
290 getResp = instance
291 associateResp = instance
292)
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +0100293
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100294var expectedReplica = &Instance{
295 Status: "BUILD",
296 Updated: "2014-10-14T18:42:15",
297 Name: "t2s1_ALT_GUEST",
298 Links: []gophercloud.Link{
299 gophercloud.Link{Rel: "self", Href: "https://ord.databases.api.rackspacecloud.com/v1.0/5919009/instances/8367c312-7c40-4a66-aab1-5767478914fc"},
300 gophercloud.Link{Rel: "bookmark", Href: "https://ord.databases.api.rackspacecloud.com/instances/8367c312-7c40-4a66-aab1-5767478914fc"},
301 },
302 Created: "2014-10-14T18:42:15",
303 ID: "8367c312-7c40-4a66-aab1-5767478914fc",
304 Volume: os.Volume{Size: 1},
Jamie Hannaford11108402015-02-23 10:31:41 +0100305 Flavor: flavors.Flavor{ID: "9"},
Jamie Hannaforde635b7d2015-02-18 14:11:46 +0100306 Datastore: datastores.DatastorePartial{Version: "5.6", Type: "mysql"},
307 ReplicaOf: &Instance{
308 ID: "6bdca2fc-418e-40bd-a595-62abda61862d",
309 },
Jamie Hannaford4ec6afe2015-02-16 16:52:49 +0100310}