1package testing
2
3import (
4	"github.com/gophercloud/gophercloud/openstack/networking/v2/subnets"
5)
6
7const SubnetListResult = `
8{
9    "subnets": [
10        {
11            "name": "private-subnet",
12            "enable_dhcp": true,
13            "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324",
14            "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
15            "dns_nameservers": [],
16            "allocation_pools": [
17                {
18                    "start": "10.0.0.2",
19                    "end": "10.0.0.254"
20                }
21            ],
22            "host_routes": [],
23            "ip_version": 4,
24            "gateway_ip": "10.0.0.1",
25            "cidr": "10.0.0.0/24",
26            "id": "08eae331-0402-425a-923c-34f7cfe39c1b"
27        },
28        {
29            "name": "my_subnet",
30            "enable_dhcp": true,
31            "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
32            "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
33            "dns_nameservers": [],
34            "allocation_pools": [
35                {
36                    "start": "192.0.0.2",
37                    "end": "192.255.255.254"
38                }
39            ],
40            "host_routes": [],
41            "ip_version": 4,
42            "gateway_ip": "192.0.0.1",
43            "cidr": "192.0.0.0/8",
44            "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0b"
45        },
46        {
47            "name": "my_gatewayless_subnet",
48            "enable_dhcp": true,
49            "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23",
50            "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
51            "dns_nameservers": [],
52            "allocation_pools": [
53                {
54                    "start": "192.168.1.2",
55                    "end": "192.168.1.254"
56                }
57            ],
58            "host_routes": [],
59            "ip_version": 4,
60            "gateway_ip": null,
61            "cidr": "192.168.1.0/24",
62            "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0c"
63        },
64        {
65            "name": "my_subnet_with_subnetpool",
66            "enable_dhcp": false,
67            "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23",
68            "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
69            "dns_nameservers": [],
70            "allocation_pools": [
71                {
72                    "start": "10.11.12.2",
73                    "end": "10.11.12.254"
74                }
75            ],
76            "host_routes": [],
77            "ip_version": 4,
78            "gateway_ip": null,
79            "cidr": "10.11.12.0/24",
80            "id": "38186a51-f373-4bbc-838b-6eaa1aa13eac",
81            "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b"
82        }
83    ]
84}
85`
86
87var Subnet1 = subnets.Subnet{
88	Name:           "private-subnet",
89	EnableDHCP:     true,
90	NetworkID:      "db193ab3-96e3-4cb3-8fc5-05f4296d0324",
91	TenantID:       "26a7980765d0414dbc1fc1f88cdb7e6e",
92	DNSNameservers: []string{},
93	AllocationPools: []subnets.AllocationPool{
94		{
95			Start: "10.0.0.2",
96			End:   "10.0.0.254",
97		},
98	},
99	HostRoutes: []subnets.HostRoute{},
100	IPVersion:  4,
101	GatewayIP:  "10.0.0.1",
102	CIDR:       "10.0.0.0/24",
103	ID:         "08eae331-0402-425a-923c-34f7cfe39c1b",
104}
105
106var Subnet2 = subnets.Subnet{
107	Name:           "my_subnet",
108	EnableDHCP:     true,
109	NetworkID:      "d32019d3-bc6e-4319-9c1d-6722fc136a22",
110	TenantID:       "4fd44f30292945e481c7b8a0c8908869",
111	DNSNameservers: []string{},
112	AllocationPools: []subnets.AllocationPool{
113		{
114			Start: "192.0.0.2",
115			End:   "192.255.255.254",
116		},
117	},
118	HostRoutes: []subnets.HostRoute{},
119	IPVersion:  4,
120	GatewayIP:  "192.0.0.1",
121	CIDR:       "192.0.0.0/8",
122	ID:         "54d6f61d-db07-451c-9ab3-b9609b6b6f0b",
123}
124
125var Subnet3 = subnets.Subnet{
126	Name:           "my_gatewayless_subnet",
127	EnableDHCP:     true,
128	NetworkID:      "d32019d3-bc6e-4319-9c1d-6722fc136a23",
129	TenantID:       "4fd44f30292945e481c7b8a0c8908869",
130	DNSNameservers: []string{},
131	AllocationPools: []subnets.AllocationPool{
132		{
133			Start: "192.168.1.2",
134			End:   "192.168.1.254",
135		},
136	},
137	HostRoutes: []subnets.HostRoute{},
138	IPVersion:  4,
139	GatewayIP:  "",
140	CIDR:       "192.168.1.0/24",
141	ID:         "54d6f61d-db07-451c-9ab3-b9609b6b6f0c",
142}
143
144var Subnet4 = subnets.Subnet{
145	Name:           "my_subnet_with_subnetpool",
146	EnableDHCP:     false,
147	NetworkID:      "d32019d3-bc6e-4319-9c1d-6722fc136a23",
148	TenantID:       "4fd44f30292945e481c7b8a0c8908869",
149	DNSNameservers: []string{},
150	AllocationPools: []subnets.AllocationPool{
151		{
152			Start: "10.11.12.2",
153			End:   "10.11.12.254",
154		},
155	},
156	HostRoutes:   []subnets.HostRoute{},
157	IPVersion:    4,
158	GatewayIP:    "",
159	CIDR:         "10.11.12.0/24",
160	ID:           "38186a51-f373-4bbc-838b-6eaa1aa13eac",
161	SubnetPoolID: "b80340c7-9960-4f67-a99c-02501656284b",
162}
163
164const SubnetGetResult = `
165{
166    "subnet": {
167        "name": "my_subnet",
168        "enable_dhcp": true,
169        "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
170        "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
171        "dns_nameservers": [],
172        "allocation_pools": [
173            {
174                "start": "192.0.0.2",
175                "end": "192.255.255.254"
176            }
177        ],
178        "host_routes": [],
179        "ip_version": 4,
180        "gateway_ip": "192.0.0.1",
181        "cidr": "192.0.0.0/8",
182        "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0b",
183        "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b"
184    }
185}
186`
187
188const SubnetCreateRequest = `
189{
190    "subnet": {
191        "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
192        "ip_version": 4,
193        "gateway_ip": "192.168.199.1",
194        "cidr": "192.168.199.0/24",
195        "dns_nameservers": ["foo"],
196        "allocation_pools": [
197            {
198                "start": "192.168.199.2",
199                "end": "192.168.199.254"
200            }
201        ],
202        "host_routes": [{"destination":"","nexthop": "bar"}],
203        "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b"
204    }
205}
206`
207
208const SubnetCreateResult = `
209{
210    "subnet": {
211        "name": "",
212        "enable_dhcp": true,
213        "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
214        "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
215        "dns_nameservers": [],
216        "allocation_pools": [
217            {
218                "start": "192.168.199.2",
219                "end": "192.168.199.254"
220            }
221        ],
222        "host_routes": [],
223        "ip_version": 4,
224        "gateway_ip": "192.168.199.1",
225        "cidr": "192.168.199.0/24",
226        "id": "3b80198d-4f7b-4f77-9ef5-774d54e17126",
227        "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b"
228    }
229}
230`
231
232const SubnetCreateWithNoGatewayRequest = `
233{
234    "subnet": {
235        "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23",
236        "ip_version": 4,
237        "cidr": "192.168.1.0/24",
238        "gateway_ip": null,
239        "allocation_pools": [
240            {
241                "start": "192.168.1.2",
242                "end": "192.168.1.254"
243            }
244        ]
245    }
246}
247`
248
249const SubnetCreateWithNoGatewayResponse = `
250{
251    "subnet": {
252        "name": "",
253        "enable_dhcp": true,
254        "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23",
255        "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
256        "allocation_pools": [
257            {
258                "start": "192.168.1.2",
259                "end": "192.168.1.254"
260            }
261        ],
262        "host_routes": [],
263        "ip_version": 4,
264        "gateway_ip": null,
265        "cidr": "192.168.1.0/24",
266        "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0c"
267    }
268}
269`
270
271const SubnetCreateWithDefaultGatewayRequest = `
272{
273    "subnet": {
274        "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23",
275        "ip_version": 4,
276        "cidr": "192.168.1.0/24",
277        "allocation_pools": [
278            {
279                "start": "192.168.1.2",
280                "end": "192.168.1.254"
281            }
282        ]
283    }
284}
285`
286
287const SubnetCreateWithDefaultGatewayResponse = `
288{
289    "subnet": {
290        "name": "",
291        "enable_dhcp": true,
292        "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a23",
293        "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
294        "allocation_pools": [
295            {
296                "start": "192.168.1.2",
297                "end": "192.168.1.254"
298            }
299        ],
300        "host_routes": [],
301        "ip_version": 4,
302        "gateway_ip": "192.168.1.1",
303        "cidr": "192.168.1.0/24",
304        "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0c"
305    }
306}
307`
308const SubnetCreateWithIPv6RaAddressModeRequest = `
309{
310    "subnet": {
311        "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
312        "ip_version": 6,
313        "gateway_ip": "2001:db8:0:a::1",
314        "cidr": "2001:db8:0:a:0:0:0:0/64",
315        "ipv6_address_mode": "slaac",
316        "ipv6_ra_mode": "slaac"
317    }
318}
319`
320const SubnetCreateWithIPv6RaAddressModeResponse = `
321{
322    "subnet": {
323        "name": "",
324        "enable_dhcp": true,
325        "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
326        "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
327        "dns_nameservers": [],
328        "host_routes": [],
329        "ip_version": 6,
330        "gateway_ip": "2001:db8:0:a::1",
331        "cidr": "2001:db8:0:a:0:0:0:0/64",
332        "id": "3b80198d-4f7b-4f77-9ef5-774d54e17126",
333        "ipv6_address_mode": "slaac",
334        "ipv6_ra_mode": "slaac"
335    }
336}
337`
338
339const SubnetCreateRequestWithNoCIDR = `
340{
341    "subnet": {
342        "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
343        "ip_version": 4,
344        "dns_nameservers": ["foo"],
345        "host_routes": [{"destination":"","nexthop": "bar"}],
346        "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b"
347    }
348}
349`
350
351const SubnetCreateRequestWithPrefixlen = `
352{
353    "subnet": {
354        "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
355        "ip_version": 4,
356        "dns_nameservers": ["foo"],
357        "host_routes": [{"destination":"","nexthop": "bar"}],
358        "subnetpool_id": "b80340c7-9960-4f67-a99c-02501656284b",
359        "prefixlen": 12
360    }
361}
362`
363
364const SubnetUpdateRequest = `
365{
366    "subnet": {
367        "name": "my_new_subnet",
368        "dns_nameservers": ["foo"],
369        "host_routes": [{"destination":"","nexthop": "bar"}]
370    }
371}
372`
373
374const SubnetUpdateResponse = `
375{
376    "subnet": {
377        "name": "my_new_subnet",
378        "enable_dhcp": true,
379        "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324",
380        "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
381        "dns_nameservers": [],
382        "allocation_pools": [
383            {
384                "start": "10.0.0.2",
385                "end": "10.0.0.254"
386            }
387        ],
388        "host_routes": [],
389        "ip_version": 4,
390        "gateway_ip": "10.0.0.1",
391        "cidr": "10.0.0.0/24",
392        "id": "08eae331-0402-425a-923c-34f7cfe39c1b"
393    }
394}
395`
396
397const SubnetUpdateGatewayRequest = `
398{
399    "subnet": {
400        "name": "my_new_subnet",
401        "gateway_ip": "10.0.0.1"
402    }
403}
404`
405
406const SubnetUpdateGatewayResponse = `
407{
408    "subnet": {
409        "name": "my_new_subnet",
410        "enable_dhcp": true,
411        "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324",
412        "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
413        "dns_nameservers": [],
414        "allocation_pools": [
415            {
416                "start": "10.0.0.2",
417                "end": "10.0.0.254"
418            }
419        ],
420        "host_routes": [],
421        "ip_version": 4,
422        "gateway_ip": "10.0.0.1",
423        "cidr": "10.0.0.0/24",
424        "id": "08eae331-0402-425a-923c-34f7cfe39c1b"
425    }
426}
427`
428
429const SubnetUpdateRemoveGatewayRequest = `
430{
431    "subnet": {
432        "name": "my_new_subnet",
433        "gateway_ip": null
434    }
435}
436`
437
438const SubnetUpdateRemoveGatewayResponse = `
439{
440    "subnet": {
441        "name": "my_new_subnet",
442        "enable_dhcp": true,
443        "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324",
444        "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
445        "dns_nameservers": [],
446        "allocation_pools": [
447            {
448                "start": "10.0.0.2",
449                "end": "10.0.0.254"
450            }
451        ],
452        "host_routes": [],
453        "ip_version": 4,
454        "gateway_ip": null,
455        "cidr": "10.0.0.0/24",
456        "id": "08eae331-0402-425a-923c-34f7cfe39c1b"
457    }
458}
459`
460
461const SubnetUpdateHostRoutesRequest = `
462{
463    "subnet": {
464        "name": "my_new_subnet",
465        "host_routes": [
466          {
467            "destination": "192.168.1.1/24",
468            "nexthop": "bar"
469          }
470        ]
471    }
472}
473`
474
475const SubnetUpdateHostRoutesResponse = `
476{
477    "subnet": {
478        "name": "my_new_subnet",
479        "enable_dhcp": true,
480        "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324",
481        "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
482        "dns_nameservers": [],
483        "allocation_pools": [
484            {
485                "start": "10.0.0.2",
486                "end": "10.0.0.254"
487            }
488        ],
489        "ip_version": 4,
490        "gateway_ip": "10.0.0.1",
491        "host_routes": [
492          {
493            "destination": "192.168.1.1/24",
494            "nexthop": "bar"
495          }
496        ],
497        "cidr": "10.0.0.0/24",
498        "id": "08eae331-0402-425a-923c-34f7cfe39c1b"
499    }
500}
501`
502
503const SubnetUpdateRemoveHostRoutesRequest = `
504{
505    "subnet": {
506        "host_routes": []
507    }
508}
509`
510
511const SubnetUpdateRemoveHostRoutesResponse = `
512{
513    "subnet": {
514        "name": "my_new_subnet",
515        "enable_dhcp": true,
516        "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324",
517        "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
518        "dns_nameservers": [],
519        "allocation_pools": [
520            {
521                "start": "10.0.0.2",
522                "end": "10.0.0.254"
523            }
524        ],
525        "host_routes": [],
526        "ip_version": 4,
527        "gateway_ip": null,
528        "cidr": "10.0.0.0/24",
529        "id": "08eae331-0402-425a-923c-34f7cfe39c1b"
530    }
531}
532`
533
534const SubnetUpdateAllocationPoolRequest = `
535{
536    "subnet": {
537        "name": "my_new_subnet",
538        "allocation_pools": [
539            {
540                "start": "10.1.0.2",
541                "end": "10.1.0.254"
542            }
543        ]
544    }
545}
546`
547
548const SubnetUpdateAllocationPoolResponse = `
549{
550    "subnet": {
551        "name": "my_new_subnet",
552        "enable_dhcp": true,
553        "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324",
554        "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
555        "dns_nameservers": [],
556        "allocation_pools": [
557            {
558                "start": "10.1.0.2",
559                "end": "10.1.0.254"
560            }
561        ],
562        "host_routes": [],
563        "ip_version": 4,
564        "gateway_ip": "10.0.0.1",
565        "cidr": "10.0.0.0/24",
566        "id": "08eae331-0402-425a-923c-34f7cfe39c1b"
567    }
568}
569`
570