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