@@ -38,160 +38,165 @@ def setUp(self):
3838
3939class TestCreateSubnet (TestSubnet ):
4040
41- project = identity_fakes_v3 .FakeProject .create_one_project ()
42- domain = identity_fakes_v3 .FakeDomain .create_one_domain ()
43- # An IPv4 subnet to be created with mostly default values
44- _subnet = network_fakes .FakeSubnet .create_one_subnet (
45- attrs = {
46- 'tenant_id' : project .id ,
47- }
48- )
41+ def _init_subnet_variables (self ):
42+ self .project = identity_fakes_v3 .FakeProject .create_one_project ()
43+ self .domain = identity_fakes_v3 .FakeDomain .create_one_domain ()
44+ # An IPv4 subnet to be created with mostly default values
45+ self ._subnet = network_fakes .FakeSubnet .create_one_subnet (
46+ attrs = {
47+ 'tenant_id' : self .project .id ,
48+ }
49+ )
4950
50- # Subnet pool to be used to create a subnet from a pool
51- _subnet_pool = network_fakes .FakeSubnetPool .create_one_subnet_pool ()
52-
53- # An IPv4 subnet to be created using a specific subnet pool
54- _subnet_from_pool = network_fakes .FakeSubnet .create_one_subnet (
55- attrs = {
56- 'tenant_id' : project .id ,
57- 'subnetpool_id' : _subnet_pool .id ,
58- 'dns_nameservers' : ['8.8.8.8' ,
59- '8.8.4.4' ],
60- 'host_routes' : [{'destination' : '10.20.20.0/24' ,
61- 'nexthop' : '10.20.20.1' },
62- {'destination' : '10.30.30.0/24' ,
63- 'nexthop' : '10.30.30.1' }],
64- 'service_types' : ['network:router_gateway' ,
65- 'network:floatingip_agent_gateway' ],
66- }
67- )
51+ # Subnet pool to be used to create a subnet from a pool
52+ self ._subnet_pool = \
53+ network_fakes .FakeSubnetPool .create_one_subnet_pool ()
6854
69- # An IPv6 subnet to be created with most options specified
70- _subnet_ipv6 = network_fakes .FakeSubnet .create_one_subnet (
71- attrs = {
72- 'tenant_id' : project .id ,
73- 'cidr' : 'fe80:0:0:a00a::/64' ,
74- 'enable_dhcp' : True ,
75- 'dns_nameservers' : ['fe80:27ff:a00a:f00f::ffff' ,
76- 'fe80:37ff:a00a:f00f::ffff' ],
77- 'allocation_pools' : [{'start' : 'fe80::a00a:0:c0de:0:100' ,
78- 'end' : 'fe80::a00a:0:c0de:0:f000' },
79- {'start' : 'fe80::a00a:0:c0de:1:100' ,
80- 'end' : 'fe80::a00a:0:c0de:1:f000' }],
81- 'host_routes' : [{'destination' : 'fe80:27ff:a00a:f00f::/64' ,
82- 'nexthop' : 'fe80:27ff:a00a:f00f::1' },
83- {'destination' : 'fe80:37ff:a00a:f00f::/64' ,
84- 'nexthop' : 'fe80:37ff:a00a:f00f::1' }],
85- 'ip_version' : 6 ,
86- 'gateway_ip' : 'fe80::a00a:0:c0de:0:1' ,
87- 'ipv6_address_mode' : 'slaac' ,
88- 'ipv6_ra_mode' : 'slaac' ,
89- 'subnetpool_id' : 'None' ,
90- 'service_types' : ['network:router_gateway' ,
91- 'network:floatingip_agent_gateway' ],
92- }
93- )
55+ # An IPv4 subnet to be created using a specific subnet pool
56+ self ._subnet_from_pool = network_fakes .FakeSubnet .create_one_subnet (
57+ attrs = {
58+ 'tenant_id' : self .project .id ,
59+ 'subnetpool_id' : self ._subnet_pool .id ,
60+ 'dns_nameservers' : ['8.8.8.8' ,
61+ '8.8.4.4' ],
62+ 'host_routes' : [{'destination' : '10.20.20.0/24' ,
63+ 'nexthop' : '10.20.20.1' },
64+ {'destination' : '10.30.30.0/24' ,
65+ 'nexthop' : '10.30.30.1' }],
66+ 'service_types' : ['network:router_gateway' ,
67+ 'network:floatingip_agent_gateway' ],
68+ }
69+ )
9470
95- # The network to be returned from find_network
96- _network = network_fakes .FakeNetwork .create_one_network (
97- attrs = {
98- 'id' : _subnet .network_id ,
99- }
100- )
71+ # An IPv6 subnet to be created with most options specified
72+ self ._subnet_ipv6 = network_fakes .FakeSubnet .create_one_subnet (
73+ attrs = {
74+ 'tenant_id' : self .project .id ,
75+ 'cidr' : 'fe80:0:0:a00a::/64' ,
76+ 'enable_dhcp' : True ,
77+ 'dns_nameservers' : ['fe80:27ff:a00a:f00f::ffff' ,
78+ 'fe80:37ff:a00a:f00f::ffff' ],
79+ 'allocation_pools' : [{'start' : 'fe80::a00a:0:c0de:0:100' ,
80+ 'end' : 'fe80::a00a:0:c0de:0:f000' },
81+ {'start' : 'fe80::a00a:0:c0de:1:100' ,
82+ 'end' : 'fe80::a00a:0:c0de:1:f000' }],
83+ 'host_routes' : [{'destination' : 'fe80:27ff:a00a:f00f::/64' ,
84+ 'nexthop' : 'fe80:27ff:a00a:f00f::1' },
85+ {'destination' : 'fe80:37ff:a00a:f00f::/64' ,
86+ 'nexthop' : 'fe80:37ff:a00a:f00f::1' }],
87+ 'ip_version' : 6 ,
88+ 'gateway_ip' : 'fe80::a00a:0:c0de:0:1' ,
89+ 'ipv6_address_mode' : 'slaac' ,
90+ 'ipv6_ra_mode' : 'slaac' ,
91+ 'subnetpool_id' : 'None' ,
92+ 'service_types' : ['network:router_gateway' ,
93+ 'network:floatingip_agent_gateway' ],
94+ }
95+ )
10196
102- # The network segment to be returned from find_segment
103- _network_segment = \
104- network_fakes .FakeNetworkSegment .create_one_network_segment (
97+ # The network to be returned from find_network
98+ self ._network = network_fakes .FakeNetwork .create_one_network (
10599 attrs = {
106- 'network_id ' : _subnet .network_id ,
100+ 'id ' : self . _subnet .network_id ,
107101 }
108102 )
109103
110- columns = (
111- 'allocation_pools' ,
112- 'cidr' ,
113- 'description' ,
114- 'dns_nameservers' ,
115- 'enable_dhcp' ,
116- 'gateway_ip' ,
117- 'host_routes' ,
118- 'id' ,
119- 'ip_version' ,
120- 'ipv6_address_mode' ,
121- 'ipv6_ra_mode' ,
122- 'name' ,
123- 'network_id' ,
124- 'project_id' ,
125- 'segment_id' ,
126- 'service_types' ,
127- 'subnetpool_id' ,
128- 'tags' ,
129- )
104+ # The network segment to be returned from find_segment
105+ self ._network_segment = \
106+ network_fakes .FakeNetworkSegment .create_one_network_segment (
107+ attrs = {
108+ 'network_id' : self ._subnet .network_id ,
109+ }
110+ )
111+
112+ self .columns = (
113+ 'allocation_pools' ,
114+ 'cidr' ,
115+ 'description' ,
116+ 'dns_nameservers' ,
117+ 'enable_dhcp' ,
118+ 'gateway_ip' ,
119+ 'host_routes' ,
120+ 'id' ,
121+ 'ip_version' ,
122+ 'ipv6_address_mode' ,
123+ 'ipv6_ra_mode' ,
124+ 'name' ,
125+ 'network_id' ,
126+ 'project_id' ,
127+ 'segment_id' ,
128+ 'service_types' ,
129+ 'subnetpool_id' ,
130+ 'tags' ,
131+ )
130132
131- data = (
132- subnet_v2 ._format_allocation_pools (_subnet .allocation_pools ),
133- _subnet .cidr ,
134- _subnet .description ,
135- utils .format_list (_subnet .dns_nameservers ),
136- _subnet .enable_dhcp ,
137- _subnet .gateway_ip ,
138- subnet_v2 ._format_host_routes (_subnet .host_routes ),
139- _subnet .id ,
140- _subnet .ip_version ,
141- _subnet .ipv6_address_mode ,
142- _subnet .ipv6_ra_mode ,
143- _subnet .name ,
144- _subnet .network_id ,
145- _subnet .project_id ,
146- _subnet .segment_id ,
147- utils .format_list (_subnet .service_types ),
148- _subnet .subnetpool_id ,
149- utils .format_list (_subnet .tags ),
150- )
133+ self . data = (
134+ subnet_v2 ._format_allocation_pools (self . _subnet .allocation_pools ),
135+ self . _subnet .cidr ,
136+ self . _subnet .description ,
137+ utils .format_list (self . _subnet .dns_nameservers ),
138+ self . _subnet .enable_dhcp ,
139+ self . _subnet .gateway_ip ,
140+ subnet_v2 ._format_host_routes (self . _subnet .host_routes ),
141+ self . _subnet .id ,
142+ self . _subnet .ip_version ,
143+ self . _subnet .ipv6_address_mode ,
144+ self . _subnet .ipv6_ra_mode ,
145+ self . _subnet .name ,
146+ self . _subnet .network_id ,
147+ self . _subnet .project_id ,
148+ self . _subnet .segment_id ,
149+ utils .format_list (self . _subnet .service_types ),
150+ self . _subnet .subnetpool_id ,
151+ utils .format_list (self . _subnet .tags ),
152+ )
151153
152- data_subnet_pool = (
153- subnet_v2 ._format_allocation_pools (_subnet_from_pool .allocation_pools ),
154- _subnet_from_pool .cidr ,
155- _subnet_from_pool .description ,
156- utils .format_list (_subnet_from_pool .dns_nameservers ),
157- _subnet_from_pool .enable_dhcp ,
158- _subnet_from_pool .gateway_ip ,
159- subnet_v2 ._format_host_routes (_subnet_from_pool .host_routes ),
160- _subnet_from_pool .id ,
161- _subnet_from_pool .ip_version ,
162- _subnet_from_pool .ipv6_address_mode ,
163- _subnet_from_pool .ipv6_ra_mode ,
164- _subnet_from_pool .name ,
165- _subnet_from_pool .network_id ,
166- _subnet_from_pool .project_id ,
167- _subnet_from_pool .segment_id ,
168- utils .format_list (_subnet_from_pool .service_types ),
169- _subnet_from_pool .subnetpool_id ,
170- utils .format_list (_subnet .tags ),
171- )
154+ self .data_subnet_pool = (
155+ subnet_v2 ._format_allocation_pools (
156+ self ._subnet_from_pool .allocation_pools ),
157+ self ._subnet_from_pool .cidr ,
158+ self ._subnet_from_pool .description ,
159+ utils .format_list (self ._subnet_from_pool .dns_nameservers ),
160+ self ._subnet_from_pool .enable_dhcp ,
161+ self ._subnet_from_pool .gateway_ip ,
162+ subnet_v2 ._format_host_routes (self ._subnet_from_pool .host_routes ),
163+ self ._subnet_from_pool .id ,
164+ self ._subnet_from_pool .ip_version ,
165+ self ._subnet_from_pool .ipv6_address_mode ,
166+ self ._subnet_from_pool .ipv6_ra_mode ,
167+ self ._subnet_from_pool .name ,
168+ self ._subnet_from_pool .network_id ,
169+ self ._subnet_from_pool .project_id ,
170+ self ._subnet_from_pool .segment_id ,
171+ utils .format_list (self ._subnet_from_pool .service_types ),
172+ self ._subnet_from_pool .subnetpool_id ,
173+ utils .format_list (self ._subnet .tags ),
174+ )
172175
173- data_ipv6 = (
174- subnet_v2 ._format_allocation_pools (_subnet_ipv6 .allocation_pools ),
175- _subnet_ipv6 .cidr ,
176- _subnet_ipv6 .description ,
177- utils .format_list (_subnet_ipv6 .dns_nameservers ),
178- _subnet_ipv6 .enable_dhcp ,
179- _subnet_ipv6 .gateway_ip ,
180- subnet_v2 ._format_host_routes (_subnet_ipv6 .host_routes ),
181- _subnet_ipv6 .id ,
182- _subnet_ipv6 .ip_version ,
183- _subnet_ipv6 .ipv6_address_mode ,
184- _subnet_ipv6 .ipv6_ra_mode ,
185- _subnet_ipv6 .name ,
186- _subnet_ipv6 .network_id ,
187- _subnet_ipv6 .project_id ,
188- _subnet_ipv6 .segment_id ,
189- utils .format_list (_subnet_ipv6 .service_types ),
190- _subnet_ipv6 .subnetpool_id ,
191- utils .format_list (_subnet .tags ),
192- )
176+ self .data_ipv6 = (
177+ subnet_v2 ._format_allocation_pools (
178+ self ._subnet_ipv6 .allocation_pools ),
179+ self ._subnet_ipv6 .cidr ,
180+ self ._subnet_ipv6 .description ,
181+ utils .format_list (self ._subnet_ipv6 .dns_nameservers ),
182+ self ._subnet_ipv6 .enable_dhcp ,
183+ self ._subnet_ipv6 .gateway_ip ,
184+ subnet_v2 ._format_host_routes (self ._subnet_ipv6 .host_routes ),
185+ self ._subnet_ipv6 .id ,
186+ self ._subnet_ipv6 .ip_version ,
187+ self ._subnet_ipv6 .ipv6_address_mode ,
188+ self ._subnet_ipv6 .ipv6_ra_mode ,
189+ self ._subnet_ipv6 .name ,
190+ self ._subnet_ipv6 .network_id ,
191+ self ._subnet_ipv6 .project_id ,
192+ self ._subnet_ipv6 .segment_id ,
193+ utils .format_list (self ._subnet_ipv6 .service_types ),
194+ self ._subnet_ipv6 .subnetpool_id ,
195+ utils .format_list (self ._subnet .tags ),
196+ )
193197
194198 def setUp (self ):
199+ self ._init_subnet_variables ()
195200 super (TestCreateSubnet , self ).setUp ()
196201
197202 # Get the command object to test
0 commit comments