blob: 77008ab11c44de30014ebc393dad3ae4ea19bcbd [file] [log] [blame]
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +04001# Copyright 2014 OpenStack Foundation
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16import netaddr
17import random
18
Matthew Treinish71426682015-04-23 11:19:38 -040019import six
Masayuki Igawad9388762015-01-20 14:56:42 +090020
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040021from tempest.api.network import base
Fei Long Wangd39431f2015-05-14 11:30:48 +120022from tempest.common.utils import data_utils
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040023from tempest import config
Andrea Frittoli (andreaf)db9672e2016-02-23 14:07:24 -050024from tempest.lib import exceptions as lib_exc
Chris Hoge7579c1a2015-02-26 14:12:15 -080025from tempest import test
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040026
27CONF = config.CONF
28
29
30class NetworksTestDHCPv6(base.BaseNetworkTest):
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040031 _ip_version = 6
32
33 """ Test DHCPv6 specific features using SLAAC, stateless and
34 stateful settings for subnets. Also it shall check dual-stack
35 functionality (IPv4 + IPv6 together).
36 The tests include:
37 generating of SLAAC EUI-64 address in subnets with various settings
38 receiving SLAAC addresses in combinations of various subnets
39 receiving stateful IPv6 addresses
40 addressing in subnets with router
41 """
42
43 @classmethod
Sergey Shnaidman64303102014-12-23 13:09:09 +030044 def skip_checks(cls):
Rohan Kanadea565e452015-01-27 14:00:13 +053045 super(NetworksTestDHCPv6, cls).skip_checks()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040046 msg = None
47 if not CONF.network_feature_enabled.ipv6:
48 msg = "IPv6 is not enabled"
49 elif not CONF.network_feature_enabled.ipv6_subnet_attributes:
50 msg = "DHCPv6 attributes are not enabled."
51 if msg:
52 raise cls.skipException(msg)
Sergey Shnaidman64303102014-12-23 13:09:09 +030053
54 @classmethod
55 def resource_setup(cls):
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040056 super(NetworksTestDHCPv6, cls).resource_setup()
57 cls.network = cls.create_network()
58
59 def _remove_from_list_by_index(self, things_list, elem):
60 for index, i in enumerate(things_list):
61 if i['id'] == elem['id']:
62 break
63 del things_list[index]
64
65 def _clean_network(self):
John Warren49c0fe52015-10-22 12:35:54 -040066 body = self.ports_client.list_ports()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040067 ports = body['ports']
68 for port in ports:
Leonardo Maycotte1692c102016-02-21 15:18:04 -060069 if (port['device_owner'].startswith('network:router_interface') and
70 port['device_id'] in [r['id'] for r in self.routers]):
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000071 self.routers_client.remove_router_interface(port['device_id'],
72 port_id=port['id'])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040073 else:
74 if port['id'] in [p['id'] for p in self.ports]:
John Warren49c0fe52015-10-22 12:35:54 -040075 self.ports_client.delete_port(port['id'])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040076 self._remove_from_list_by_index(self.ports, port)
John Warren3961acd2015-10-02 14:38:53 -040077 body = self.subnets_client.list_subnets()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040078 subnets = body['subnets']
79 for subnet in subnets:
80 if subnet['id'] in [s['id'] for s in self.subnets]:
John Warren3961acd2015-10-02 14:38:53 -040081 self.subnets_client.delete_subnet(subnet['id'])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040082 self._remove_from_list_by_index(self.subnets, subnet)
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000083 body = self.routers_client.list_routers()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040084 routers = body['routers']
85 for router in routers:
86 if router['id'] in [r['id'] for r in self.routers]:
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000087 self.routers_client.delete_router(router['id'])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040088 self._remove_from_list_by_index(self.routers, router)
89
90 def _get_ips_from_subnet(self, **kwargs):
91 subnet = self.create_subnet(self.network, **kwargs)
92 port_mac = data_utils.rand_mac_address()
93 port = self.create_port(self.network, mac_address=port_mac)
94 real_ip = next(iter(port['fixed_ips']), None)['ip_address']
95 eui_ip = data_utils.get_ipv6_addr_by_EUI64(subnet['cidr'],
96 port_mac).format()
97 return real_ip, eui_ip
98
Chris Hoge7579c1a2015-02-26 14:12:15 -080099 @test.idempotent_id('e5517e62-6f16-430d-a672-f80875493d4c')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400100 def test_dhcpv6_stateless_eui64(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000101 # NOTE: When subnets configured with RAs SLAAC (AOM=100) and DHCP
102 # stateless (AOM=110) both for radvd and dnsmasq, port shall receive
103 # IP address calculated from its MAC.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400104 for ra_mode, add_mode in (
105 ('slaac', 'slaac'),
106 ('dhcpv6-stateless', 'dhcpv6-stateless'),
107 ):
108 kwargs = {'ipv6_ra_mode': ra_mode,
109 'ipv6_address_mode': add_mode}
110 real_ip, eui_ip = self._get_ips_from_subnet(**kwargs)
111 self._clean_network()
112 self.assertEqual(eui_ip, real_ip,
113 ('Real port IP is %s, but shall be %s when '
114 'ipv6_ra_mode=%s and ipv6_address_mode=%s') % (
115 real_ip, eui_ip, ra_mode, add_mode))
116
Chris Hoge7579c1a2015-02-26 14:12:15 -0800117 @test.idempotent_id('ae2f4a5d-03ff-4c42-a3b0-ce2fcb7ea832')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400118 def test_dhcpv6_stateless_no_ra(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000119 # NOTE: When subnets configured with dnsmasq SLAAC and DHCP stateless
120 # and there is no radvd, port shall receive IP address calculated
121 # from its MAC and mask of subnet.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400122 for ra_mode, add_mode in (
123 (None, 'slaac'),
124 (None, 'dhcpv6-stateless'),
125 ):
126 kwargs = {'ipv6_ra_mode': ra_mode,
127 'ipv6_address_mode': add_mode}
Jordan Pittieredee6502015-09-22 17:16:31 +0200128 kwargs = dict((k, v) for k, v in six.iteritems(kwargs) if v)
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400129 real_ip, eui_ip = self._get_ips_from_subnet(**kwargs)
130 self._clean_network()
131 self.assertEqual(eui_ip, real_ip,
132 ('Real port IP %s shall be equal to EUI-64 %s'
133 'when ipv6_ra_mode=%s,ipv6_address_mode=%s') % (
134 real_ip, eui_ip,
135 ra_mode if ra_mode else "Off",
136 add_mode if add_mode else "Off"))
137
Chris Hoge7579c1a2015-02-26 14:12:15 -0800138 @test.idempotent_id('81f18ef6-95b5-4584-9966-10d480b7496a')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400139 def test_dhcpv6_invalid_options(self):
140 """Different configurations for radvd and dnsmasq are not allowed"""
141 for ra_mode, add_mode in (
142 ('dhcpv6-stateless', 'dhcpv6-stateful'),
143 ('dhcpv6-stateless', 'slaac'),
144 ('slaac', 'dhcpv6-stateful'),
145 ('dhcpv6-stateful', 'dhcpv6-stateless'),
146 ('dhcpv6-stateful', 'slaac'),
147 ('slaac', 'dhcpv6-stateless'),
148 ):
149 kwargs = {'ipv6_ra_mode': ra_mode,
150 'ipv6_address_mode': add_mode}
Masayuki Igawa4b29e472015-02-16 10:41:54 +0900151 self.assertRaises(lib_exc.BadRequest,
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400152 self.create_subnet,
153 self.network,
154 **kwargs)
155
Chris Hoge7579c1a2015-02-26 14:12:15 -0800156 @test.idempotent_id('21635b6f-165a-4d42-bf49-7d195e47342f')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400157 def test_dhcpv6_stateless_no_ra_no_dhcp(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000158 # NOTE: If no radvd option and no dnsmasq option is configured
159 # port shall receive IP from fixed IPs list of subnet.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400160 real_ip, eui_ip = self._get_ips_from_subnet()
161 self._clean_network()
162 self.assertNotEqual(eui_ip, real_ip,
163 ('Real port IP %s equal to EUI-64 %s when '
164 'ipv6_ra_mode=Off and ipv6_address_mode=Off,'
165 'but shall be taken from fixed IPs') % (
166 real_ip, eui_ip))
167
Chris Hoge7579c1a2015-02-26 14:12:15 -0800168 @test.idempotent_id('4544adf7-bb5f-4bdc-b769-b3e77026cef2')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400169 def test_dhcpv6_two_subnets(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000170 # NOTE: When one IPv6 subnet configured with dnsmasq SLAAC or DHCP
171 # stateless and other IPv6 is with DHCP stateful, port shall receive
172 # EUI-64 IP addresses from first subnet and DHCP address from second
173 # one. Order of subnet creating should be unimportant.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400174 for order in ("slaac_first", "dhcp_first"):
175 for ra_mode, add_mode in (
176 ('slaac', 'slaac'),
177 ('dhcpv6-stateless', 'dhcpv6-stateless'),
178 ):
179 kwargs = {'ipv6_ra_mode': ra_mode,
180 'ipv6_address_mode': add_mode}
181 kwargs_dhcp = {'ipv6_address_mode': 'dhcpv6-stateful'}
182 if order == "slaac_first":
183 subnet_slaac = self.create_subnet(self.network, **kwargs)
184 subnet_dhcp = self.create_subnet(
185 self.network, **kwargs_dhcp)
186 else:
187 subnet_dhcp = self.create_subnet(
188 self.network, **kwargs_dhcp)
189 subnet_slaac = self.create_subnet(self.network, **kwargs)
190 port_mac = data_utils.rand_mac_address()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400191 eui_ip = data_utils.get_ipv6_addr_by_EUI64(
192 subnet_slaac['cidr'],
193 port_mac
194 ).format()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400195 port = self.create_port(self.network, mac_address=port_mac)
196 real_ips = dict([(k['subnet_id'], k['ip_address'])
197 for k in port['fixed_ips']])
198 real_dhcp_ip, real_eui_ip = [real_ips[sub['id']]
Matthew Treinishbec20d82015-04-23 10:55:35 -0400199 for sub in [subnet_dhcp,
200 subnet_slaac]]
John Warren49c0fe52015-10-22 12:35:54 -0400201 self.ports_client.delete_port(port['id'])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400202 self.ports.pop()
John Warren49c0fe52015-10-22 12:35:54 -0400203 body = self.ports_client.list_ports()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400204 ports_id_list = [i['id'] for i in body['ports']]
205 self.assertNotIn(port['id'], ports_id_list)
206 self._clean_network()
207 self.assertEqual(real_eui_ip,
208 eui_ip,
209 'Real IP is {0}, but shall be {1}'.format(
210 real_eui_ip,
211 eui_ip))
Yaroslav Lobankov5d50d132015-05-26 17:04:40 +0300212 msg = ('Real IP address is {0} and it is NOT on '
213 'subnet {1}'.format(real_dhcp_ip, subnet_dhcp['cidr']))
214 self.assertIn(netaddr.IPAddress(real_dhcp_ip),
215 netaddr.IPNetwork(subnet_dhcp['cidr']), msg)
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400216
Chris Hoge7579c1a2015-02-26 14:12:15 -0800217 @test.idempotent_id('4256c61d-c538-41ea-9147-3c450c36669e')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400218 def test_dhcpv6_64_subnets(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000219 # NOTE: When one IPv6 subnet configured with dnsmasq SLAAC or DHCP
220 # stateless and other IPv4 is with DHCP of IPv4, port shall receive
221 # EUI-64 IP addresses from first subnet and IPv4 DHCP address from
222 # second one. Order of subnet creating should be unimportant.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400223 for order in ("slaac_first", "dhcp_first"):
224 for ra_mode, add_mode in (
225 ('slaac', 'slaac'),
226 ('dhcpv6-stateless', 'dhcpv6-stateless'),
227 ):
228 kwargs = {'ipv6_ra_mode': ra_mode,
229 'ipv6_address_mode': add_mode}
230 if order == "slaac_first":
231 subnet_slaac = self.create_subnet(self.network, **kwargs)
232 subnet_dhcp = self.create_subnet(
233 self.network, ip_version=4)
234 else:
235 subnet_dhcp = self.create_subnet(
236 self.network, ip_version=4)
237 subnet_slaac = self.create_subnet(self.network, **kwargs)
238 port_mac = data_utils.rand_mac_address()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400239 eui_ip = data_utils.get_ipv6_addr_by_EUI64(
240 subnet_slaac['cidr'],
241 port_mac
242 ).format()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400243 port = self.create_port(self.network, mac_address=port_mac)
244 real_ips = dict([(k['subnet_id'], k['ip_address'])
245 for k in port['fixed_ips']])
246 real_dhcp_ip, real_eui_ip = [real_ips[sub['id']]
Matthew Treinishbec20d82015-04-23 10:55:35 -0400247 for sub in [subnet_dhcp,
248 subnet_slaac]]
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400249 self._clean_network()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400250 self.assertEqual(real_eui_ip,
251 eui_ip,
252 'Real IP is {0}, but shall be {1}'.format(
253 real_eui_ip,
254 eui_ip))
Yaroslav Lobankov5d50d132015-05-26 17:04:40 +0300255 msg = ('Real IP address is {0} and it is NOT on '
256 'subnet {1}'.format(real_dhcp_ip, subnet_dhcp['cidr']))
257 self.assertIn(netaddr.IPAddress(real_dhcp_ip),
258 netaddr.IPNetwork(subnet_dhcp['cidr']), msg)
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400259
Chris Hoge7579c1a2015-02-26 14:12:15 -0800260 @test.idempotent_id('4ab211a0-276f-4552-9070-51e27f58fecf')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400261 def test_dhcp_stateful(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000262 # NOTE: With all options below, DHCPv6 shall allocate address from
263 # subnet pool to port.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400264 for ra_mode, add_mode in (
265 ('dhcpv6-stateful', 'dhcpv6-stateful'),
266 ('dhcpv6-stateful', None),
267 (None, 'dhcpv6-stateful'),
268 ):
269 kwargs = {'ipv6_ra_mode': ra_mode,
270 'ipv6_address_mode': add_mode}
Jordan Pittieredee6502015-09-22 17:16:31 +0200271 kwargs = dict((k, v) for k, v in six.iteritems(kwargs) if v)
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400272 subnet = self.create_subnet(self.network, **kwargs)
273 port = self.create_port(self.network)
274 port_ip = next(iter(port['fixed_ips']), None)['ip_address']
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400275 self._clean_network()
Yaroslav Lobankov5d50d132015-05-26 17:04:40 +0300276 msg = ('Real IP address is {0} and it is NOT on '
277 'subnet {1}'.format(port_ip, subnet['cidr']))
278 self.assertIn(netaddr.IPAddress(port_ip),
279 netaddr.IPNetwork(subnet['cidr']), msg)
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400280
Chris Hoge7579c1a2015-02-26 14:12:15 -0800281 @test.idempotent_id('51a5e97f-f02e-4e4e-9a17-a69811d300e3')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400282 def test_dhcp_stateful_fixedips(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000283 # NOTE: With all options below, port shall be able to get
284 # requested IP from fixed IP range not depending on
285 # DHCP stateful (not SLAAC!) settings configured.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400286 for ra_mode, add_mode in (
287 ('dhcpv6-stateful', 'dhcpv6-stateful'),
288 ('dhcpv6-stateful', None),
289 (None, 'dhcpv6-stateful'),
290 ):
291 kwargs = {'ipv6_ra_mode': ra_mode,
292 'ipv6_address_mode': add_mode}
Jordan Pittieredee6502015-09-22 17:16:31 +0200293 kwargs = dict((k, v) for k, v in six.iteritems(kwargs) if v)
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400294 subnet = self.create_subnet(self.network, **kwargs)
295 ip_range = netaddr.IPRange(subnet["allocation_pools"][0]["start"],
296 subnet["allocation_pools"][0]["end"])
297 ip = netaddr.IPAddress(random.randrange(ip_range.first,
298 ip_range.last)).format()
299 port = self.create_port(self.network,
300 fixed_ips=[{'subnet_id': subnet['id'],
301 'ip_address': ip}])
302 port_ip = next(iter(port['fixed_ips']), None)['ip_address']
303 self._clean_network()
304 self.assertEqual(port_ip, ip,
305 ("Port IP %s is not as fixed IP from "
306 "port create request: %s") % (
307 port_ip, ip))
308
Chris Hoge7579c1a2015-02-26 14:12:15 -0800309 @test.idempotent_id('98244d88-d990-4570-91d4-6b25d70d08af')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400310 def test_dhcp_stateful_fixedips_outrange(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000311 # NOTE: When port gets IP address from fixed IP range it
312 # shall be checked if it's from subnets range.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400313 kwargs = {'ipv6_ra_mode': 'dhcpv6-stateful',
314 'ipv6_address_mode': 'dhcpv6-stateful'}
315 subnet = self.create_subnet(self.network, **kwargs)
316 ip_range = netaddr.IPRange(subnet["allocation_pools"][0]["start"],
317 subnet["allocation_pools"][0]["end"])
318 ip = netaddr.IPAddress(random.randrange(
319 ip_range.last + 1, ip_range.last + 10)).format()
Masayuki Igawa4b29e472015-02-16 10:41:54 +0900320 self.assertRaises(lib_exc.BadRequest,
Qin Zhaoa4cae612015-01-28 16:27:00 +0800321 self.create_port,
322 self.network,
323 fixed_ips=[{'subnet_id': subnet['id'],
324 'ip_address': ip}])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400325
Chris Hoge7579c1a2015-02-26 14:12:15 -0800326 @test.idempotent_id('57b8302b-cba9-4fbb-8835-9168df029051')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400327 def test_dhcp_stateful_fixedips_duplicate(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000328 # NOTE: When port gets IP address from fixed IP range it
329 # shall be checked if it's not duplicate.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400330 kwargs = {'ipv6_ra_mode': 'dhcpv6-stateful',
331 'ipv6_address_mode': 'dhcpv6-stateful'}
332 subnet = self.create_subnet(self.network, **kwargs)
333 ip_range = netaddr.IPRange(subnet["allocation_pools"][0]["start"],
334 subnet["allocation_pools"][0]["end"])
335 ip = netaddr.IPAddress(random.randrange(
336 ip_range.first, ip_range.last)).format()
337 self.create_port(self.network,
338 fixed_ips=[
339 {'subnet_id': subnet['id'],
340 'ip_address': ip}])
reedip6fb7e1a2016-03-10 13:32:01 +0900341 self.assertRaisesRegex(lib_exc.Conflict,
342 "object with that identifier already exists",
343 self.create_port,
344 self.network,
345 fixed_ips=[{'subnet_id': subnet['id'],
346 'ip_address': ip}])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400347
348 def _create_subnet_router(self, kwargs):
349 subnet = self.create_subnet(self.network, **kwargs)
350 router = self.create_router(
351 router_name=data_utils.rand_name("routerv6-"),
352 admin_state_up=True)
353 port = self.create_router_interface(router['id'],
354 subnet['id'])
John Warren49c0fe52015-10-22 12:35:54 -0400355 body = self.ports_client.show_port(port['port_id'])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400356 return subnet, body['port']
357
Chris Hoge7579c1a2015-02-26 14:12:15 -0800358 @test.idempotent_id('e98f65db-68f4-4330-9fea-abd8c5192d4d')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400359 def test_dhcp_stateful_router(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000360 # NOTE: With all options below the router interface shall
361 # receive DHCPv6 IP address from allocation pool.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400362 for ra_mode, add_mode in (
363 ('dhcpv6-stateful', 'dhcpv6-stateful'),
364 ('dhcpv6-stateful', None),
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400365 ):
366 kwargs = {'ipv6_ra_mode': ra_mode,
367 'ipv6_address_mode': add_mode}
Jordan Pittieredee6502015-09-22 17:16:31 +0200368 kwargs = dict((k, v) for k, v in six.iteritems(kwargs) if v)
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400369 subnet, port = self._create_subnet_router(kwargs)
370 port_ip = next(iter(port['fixed_ips']), None)['ip_address']
371 self._clean_network()
372 self.assertEqual(port_ip, subnet['gateway_ip'],
373 ("Port IP %s is not as first IP from "
374 "subnets allocation pool: %s") % (
375 port_ip, subnet['gateway_ip']))
376
377 def tearDown(self):
378 self._clean_network()
379 super(NetworksTestDHCPv6, self).tearDown()