This repository was archived by the owner on Aug 1, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +56
-2
lines changed
openstack/networking/v2/subnets Expand file tree Collapse file tree 2 files changed +56
-2
lines changed Original file line number Diff line number Diff line change @@ -55,8 +55,8 @@ type AllocationPool struct {
55
55
// HostRoute represents a route that should be used by devices with IPs from
56
56
// a subnet (not including local subnet route).
57
57
type HostRoute struct {
58
- DestinationCIDR string `json:"destination"`
59
- NextHop string `json:"nexthop"`
58
+ DestinationCIDR string `mapstructure:"destination" json:"destination"`
59
+ NextHop string `mapstructure:"nexthop" json:"nexthop"`
60
60
}
61
61
62
62
// Subnet represents a subnet. See package documentation for a top-level
Original file line number Diff line number Diff line change
1
+ package subnets
2
+
3
+ import (
4
+ "encoding/json"
5
+ "github.com/rackspace/gophercloud"
6
+ th "github.com/rackspace/gophercloud/testhelper"
7
+ "testing"
8
+ )
9
+
10
+ func TestHostRoute (t * testing.T ) {
11
+ sejson := []byte (`
12
+ {"subnet": {
13
+ "name": "test-subnet",
14
+ "enable_dhcp": false,
15
+ "network_id": "3e66c41e-cbbd-4019-9aab-740b7e4150a0",
16
+ "tenant_id": "f86e123198cf42d19c8854c5f80c2f06",
17
+ "dns_nameservers": [],
18
+ "gateway_ip": "172.16.0.1",
19
+ "ipv6_ra_mode": null,
20
+ "allocation_pools": [
21
+ {
22
+ "start": "172.16.0.2",
23
+ "end": "172.16.255.254"
24
+ }
25
+ ],
26
+ "host_routes": [
27
+ {
28
+ "destination": "172.20.1.0/24",
29
+ "nexthop": "172.16.0.2"
30
+ }
31
+ ],
32
+ "ip_version": 4,
33
+ "ipv6_address_mode": null,
34
+ "cidr": "172.16.0.0/16",
35
+ "id": "6dcaa873-7115-41af-9ef5-915f73636e43",
36
+ "subnetpool_id": null
37
+ }}
38
+ ` )
39
+
40
+ var dejson interface {}
41
+ err := json .Unmarshal (sejson , & dejson )
42
+ if err != nil {
43
+ t .Fatalf ("%s" , err )
44
+ }
45
+
46
+ resp := commonResult {gophercloud.Result {Body : dejson }}
47
+ subnet , err := resp .Extract ()
48
+ if err != nil {
49
+ t .Fatalf ("%s" , err )
50
+ }
51
+ route := subnet .HostRoutes [0 ]
52
+ th .AssertEquals (t , route .NextHop , "172.16.0.2" )
53
+ th .AssertEquals (t , route .DestinationCIDR , "172.20.1.0/24" )
54
+ }
You can’t perform that action at this time.
0 commit comments