blob: 84c48ec065b30fbafe90e3caacc18ce559786c17 [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
Attila Fazekasd7e08a62016-10-07 13:05:05 +020023from tempest.common.utils import net_info
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040024from tempest import config
Andrea Frittoli (andreaf)db9672e2016-02-23 14:07:24 -050025from tempest.lib import exceptions as lib_exc
Chris Hoge7579c1a2015-02-26 14:12:15 -080026from tempest import test
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040027
28CONF = config.CONF
29
30
31class NetworksTestDHCPv6(base.BaseNetworkTest):
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040032 _ip_version = 6
33
Cao Xuan Hoangff678fb2016-09-29 13:03:27 +070034 """Test DHCPv6 specific features using SLAAC, stateless and
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040035 stateful settings for subnets. Also it shall check dual-stack
36 functionality (IPv4 + IPv6 together).
37 The tests include:
38 generating of SLAAC EUI-64 address in subnets with various settings
39 receiving SLAAC addresses in combinations of various subnets
40 receiving stateful IPv6 addresses
41 addressing in subnets with router
42 """
43
44 @classmethod
Sergey Shnaidman64303102014-12-23 13:09:09 +030045 def skip_checks(cls):
Rohan Kanadea565e452015-01-27 14:00:13 +053046 super(NetworksTestDHCPv6, cls).skip_checks()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040047 msg = None
48 if not CONF.network_feature_enabled.ipv6:
49 msg = "IPv6 is not enabled"
50 elif not CONF.network_feature_enabled.ipv6_subnet_attributes:
51 msg = "DHCPv6 attributes are not enabled."
52 if msg:
53 raise cls.skipException(msg)
Sergey Shnaidman64303102014-12-23 13:09:09 +030054
55 @classmethod
56 def resource_setup(cls):
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040057 super(NetworksTestDHCPv6, cls).resource_setup()
58 cls.network = cls.create_network()
59
60 def _remove_from_list_by_index(self, things_list, elem):
61 for index, i in enumerate(things_list):
62 if i['id'] == elem['id']:
63 break
64 del things_list[index]
65
66 def _clean_network(self):
John Warren49c0fe52015-10-22 12:35:54 -040067 body = self.ports_client.list_ports()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040068 ports = body['ports']
69 for port in ports:
Attila Fazekasd7e08a62016-10-07 13:05:05 +020070 if (net_info.is_router_interface_port(port) and
Leonardo Maycotte1692c102016-02-21 15:18:04 -060071 port['device_id'] in [r['id'] for r in self.routers]):
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000072 self.routers_client.remove_router_interface(port['device_id'],
73 port_id=port['id'])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040074 else:
75 if port['id'] in [p['id'] for p in self.ports]:
John Warren49c0fe52015-10-22 12:35:54 -040076 self.ports_client.delete_port(port['id'])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040077 self._remove_from_list_by_index(self.ports, port)
John Warren3961acd2015-10-02 14:38:53 -040078 body = self.subnets_client.list_subnets()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040079 subnets = body['subnets']
80 for subnet in subnets:
81 if subnet['id'] in [s['id'] for s in self.subnets]:
John Warren3961acd2015-10-02 14:38:53 -040082 self.subnets_client.delete_subnet(subnet['id'])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040083 self._remove_from_list_by_index(self.subnets, subnet)
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000084 body = self.routers_client.list_routers()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040085 routers = body['routers']
86 for router in routers:
87 if router['id'] in [r['id'] for r in self.routers]:
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000088 self.routers_client.delete_router(router['id'])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +040089 self._remove_from_list_by_index(self.routers, router)
90
91 def _get_ips_from_subnet(self, **kwargs):
92 subnet = self.create_subnet(self.network, **kwargs)
93 port_mac = data_utils.rand_mac_address()
94 port = self.create_port(self.network, mac_address=port_mac)
95 real_ip = next(iter(port['fixed_ips']), None)['ip_address']
96 eui_ip = data_utils.get_ipv6_addr_by_EUI64(subnet['cidr'],
97 port_mac).format()
98 return real_ip, eui_ip
99
Chris Hoge7579c1a2015-02-26 14:12:15 -0800100 @test.idempotent_id('e5517e62-6f16-430d-a672-f80875493d4c')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400101 def test_dhcpv6_stateless_eui64(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000102 # NOTE: When subnets configured with RAs SLAAC (AOM=100) and DHCP
103 # stateless (AOM=110) both for radvd and dnsmasq, port shall receive
104 # IP address calculated from its MAC.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400105 for ra_mode, add_mode in (
106 ('slaac', 'slaac'),
107 ('dhcpv6-stateless', 'dhcpv6-stateless'),
108 ):
109 kwargs = {'ipv6_ra_mode': ra_mode,
110 'ipv6_address_mode': add_mode}
111 real_ip, eui_ip = self._get_ips_from_subnet(**kwargs)
112 self._clean_network()
113 self.assertEqual(eui_ip, real_ip,
114 ('Real port IP is %s, but shall be %s when '
115 'ipv6_ra_mode=%s and ipv6_address_mode=%s') % (
116 real_ip, eui_ip, ra_mode, add_mode))
117
Chris Hoge7579c1a2015-02-26 14:12:15 -0800118 @test.idempotent_id('ae2f4a5d-03ff-4c42-a3b0-ce2fcb7ea832')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400119 def test_dhcpv6_stateless_no_ra(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000120 # NOTE: When subnets configured with dnsmasq SLAAC and DHCP stateless
121 # and there is no radvd, port shall receive IP address calculated
122 # from its MAC and mask of subnet.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400123 for ra_mode, add_mode in (
124 (None, 'slaac'),
125 (None, 'dhcpv6-stateless'),
126 ):
127 kwargs = {'ipv6_ra_mode': ra_mode,
128 'ipv6_address_mode': add_mode}
Jordan Pittieredee6502015-09-22 17:16:31 +0200129 kwargs = dict((k, v) for k, v in six.iteritems(kwargs) if v)
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400130 real_ip, eui_ip = self._get_ips_from_subnet(**kwargs)
131 self._clean_network()
132 self.assertEqual(eui_ip, real_ip,
133 ('Real port IP %s shall be equal to EUI-64 %s'
134 'when ipv6_ra_mode=%s,ipv6_address_mode=%s') % (
135 real_ip, eui_ip,
136 ra_mode if ra_mode else "Off",
137 add_mode if add_mode else "Off"))
138
Chris Hoge7579c1a2015-02-26 14:12:15 -0800139 @test.idempotent_id('81f18ef6-95b5-4584-9966-10d480b7496a')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400140 def test_dhcpv6_invalid_options(self):
141 """Different configurations for radvd and dnsmasq are not allowed"""
142 for ra_mode, add_mode in (
143 ('dhcpv6-stateless', 'dhcpv6-stateful'),
144 ('dhcpv6-stateless', 'slaac'),
145 ('slaac', 'dhcpv6-stateful'),
146 ('dhcpv6-stateful', 'dhcpv6-stateless'),
147 ('dhcpv6-stateful', 'slaac'),
148 ('slaac', 'dhcpv6-stateless'),
149 ):
150 kwargs = {'ipv6_ra_mode': ra_mode,
151 'ipv6_address_mode': add_mode}
Masayuki Igawa4b29e472015-02-16 10:41:54 +0900152 self.assertRaises(lib_exc.BadRequest,
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400153 self.create_subnet,
154 self.network,
155 **kwargs)
156
Chris Hoge7579c1a2015-02-26 14:12:15 -0800157 @test.idempotent_id('21635b6f-165a-4d42-bf49-7d195e47342f')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400158 def test_dhcpv6_stateless_no_ra_no_dhcp(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000159 # NOTE: If no radvd option and no dnsmasq option is configured
160 # port shall receive IP from fixed IPs list of subnet.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400161 real_ip, eui_ip = self._get_ips_from_subnet()
162 self._clean_network()
163 self.assertNotEqual(eui_ip, real_ip,
164 ('Real port IP %s equal to EUI-64 %s when '
165 'ipv6_ra_mode=Off and ipv6_address_mode=Off,'
166 'but shall be taken from fixed IPs') % (
167 real_ip, eui_ip))
168
Chris Hoge7579c1a2015-02-26 14:12:15 -0800169 @test.idempotent_id('4544adf7-bb5f-4bdc-b769-b3e77026cef2')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400170 def test_dhcpv6_two_subnets(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000171 # NOTE: When one IPv6 subnet configured with dnsmasq SLAAC or DHCP
172 # stateless and other IPv6 is with DHCP stateful, port shall receive
173 # EUI-64 IP addresses from first subnet and DHCP address from second
174 # one. Order of subnet creating should be unimportant.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400175 for order in ("slaac_first", "dhcp_first"):
176 for ra_mode, add_mode in (
177 ('slaac', 'slaac'),
178 ('dhcpv6-stateless', 'dhcpv6-stateless'),
179 ):
180 kwargs = {'ipv6_ra_mode': ra_mode,
181 'ipv6_address_mode': add_mode}
182 kwargs_dhcp = {'ipv6_address_mode': 'dhcpv6-stateful'}
183 if order == "slaac_first":
184 subnet_slaac = self.create_subnet(self.network, **kwargs)
185 subnet_dhcp = self.create_subnet(
186 self.network, **kwargs_dhcp)
187 else:
188 subnet_dhcp = self.create_subnet(
189 self.network, **kwargs_dhcp)
190 subnet_slaac = self.create_subnet(self.network, **kwargs)
191 port_mac = data_utils.rand_mac_address()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400192 eui_ip = data_utils.get_ipv6_addr_by_EUI64(
193 subnet_slaac['cidr'],
194 port_mac
195 ).format()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400196 port = self.create_port(self.network, mac_address=port_mac)
197 real_ips = dict([(k['subnet_id'], k['ip_address'])
198 for k in port['fixed_ips']])
199 real_dhcp_ip, real_eui_ip = [real_ips[sub['id']]
Matthew Treinishbec20d82015-04-23 10:55:35 -0400200 for sub in [subnet_dhcp,
201 subnet_slaac]]
John Warren49c0fe52015-10-22 12:35:54 -0400202 self.ports_client.delete_port(port['id'])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400203 self.ports.pop()
John Warren49c0fe52015-10-22 12:35:54 -0400204 body = self.ports_client.list_ports()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400205 ports_id_list = [i['id'] for i in body['ports']]
206 self.assertNotIn(port['id'], ports_id_list)
207 self._clean_network()
208 self.assertEqual(real_eui_ip,
209 eui_ip,
210 'Real IP is {0}, but shall be {1}'.format(
211 real_eui_ip,
212 eui_ip))
Yaroslav Lobankov5d50d132015-05-26 17:04:40 +0300213 msg = ('Real IP address is {0} and it is NOT on '
214 'subnet {1}'.format(real_dhcp_ip, subnet_dhcp['cidr']))
215 self.assertIn(netaddr.IPAddress(real_dhcp_ip),
216 netaddr.IPNetwork(subnet_dhcp['cidr']), msg)
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400217
Chris Hoge7579c1a2015-02-26 14:12:15 -0800218 @test.idempotent_id('4256c61d-c538-41ea-9147-3c450c36669e')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400219 def test_dhcpv6_64_subnets(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000220 # NOTE: When one IPv6 subnet configured with dnsmasq SLAAC or DHCP
221 # stateless and other IPv4 is with DHCP of IPv4, port shall receive
222 # EUI-64 IP addresses from first subnet and IPv4 DHCP address from
223 # second one. Order of subnet creating should be unimportant.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400224 for order in ("slaac_first", "dhcp_first"):
225 for ra_mode, add_mode in (
226 ('slaac', 'slaac'),
227 ('dhcpv6-stateless', 'dhcpv6-stateless'),
228 ):
229 kwargs = {'ipv6_ra_mode': ra_mode,
230 'ipv6_address_mode': add_mode}
231 if order == "slaac_first":
232 subnet_slaac = self.create_subnet(self.network, **kwargs)
233 subnet_dhcp = self.create_subnet(
234 self.network, ip_version=4)
235 else:
236 subnet_dhcp = self.create_subnet(
237 self.network, ip_version=4)
238 subnet_slaac = self.create_subnet(self.network, **kwargs)
239 port_mac = data_utils.rand_mac_address()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400240 eui_ip = data_utils.get_ipv6_addr_by_EUI64(
241 subnet_slaac['cidr'],
242 port_mac
243 ).format()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400244 port = self.create_port(self.network, mac_address=port_mac)
245 real_ips = dict([(k['subnet_id'], k['ip_address'])
246 for k in port['fixed_ips']])
247 real_dhcp_ip, real_eui_ip = [real_ips[sub['id']]
Matthew Treinishbec20d82015-04-23 10:55:35 -0400248 for sub in [subnet_dhcp,
249 subnet_slaac]]
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400250 self._clean_network()
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400251 self.assertEqual(real_eui_ip,
252 eui_ip,
253 'Real IP is {0}, but shall be {1}'.format(
254 real_eui_ip,
255 eui_ip))
Yaroslav Lobankov5d50d132015-05-26 17:04:40 +0300256 msg = ('Real IP address is {0} and it is NOT on '
257 'subnet {1}'.format(real_dhcp_ip, subnet_dhcp['cidr']))
258 self.assertIn(netaddr.IPAddress(real_dhcp_ip),
259 netaddr.IPNetwork(subnet_dhcp['cidr']), msg)
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400260
Chris Hoge7579c1a2015-02-26 14:12:15 -0800261 @test.idempotent_id('4ab211a0-276f-4552-9070-51e27f58fecf')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400262 def test_dhcp_stateful(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000263 # NOTE: With all options below, DHCPv6 shall allocate address from
264 # subnet pool to port.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400265 for ra_mode, add_mode in (
266 ('dhcpv6-stateful', 'dhcpv6-stateful'),
267 ('dhcpv6-stateful', None),
268 (None, 'dhcpv6-stateful'),
269 ):
270 kwargs = {'ipv6_ra_mode': ra_mode,
271 'ipv6_address_mode': add_mode}
Jordan Pittieredee6502015-09-22 17:16:31 +0200272 kwargs = dict((k, v) for k, v in six.iteritems(kwargs) if v)
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400273 subnet = self.create_subnet(self.network, **kwargs)
274 port = self.create_port(self.network)
275 port_ip = next(iter(port['fixed_ips']), None)['ip_address']
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400276 self._clean_network()
Yaroslav Lobankov5d50d132015-05-26 17:04:40 +0300277 msg = ('Real IP address is {0} and it is NOT on '
278 'subnet {1}'.format(port_ip, subnet['cidr']))
279 self.assertIn(netaddr.IPAddress(port_ip),
280 netaddr.IPNetwork(subnet['cidr']), msg)
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400281
Chris Hoge7579c1a2015-02-26 14:12:15 -0800282 @test.idempotent_id('51a5e97f-f02e-4e4e-9a17-a69811d300e3')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400283 def test_dhcp_stateful_fixedips(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000284 # NOTE: With all options below, port shall be able to get
285 # requested IP from fixed IP range not depending on
286 # DHCP stateful (not SLAAC!) settings configured.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400287 for ra_mode, add_mode in (
288 ('dhcpv6-stateful', 'dhcpv6-stateful'),
289 ('dhcpv6-stateful', None),
290 (None, 'dhcpv6-stateful'),
291 ):
292 kwargs = {'ipv6_ra_mode': ra_mode,
293 'ipv6_address_mode': add_mode}
Jordan Pittieredee6502015-09-22 17:16:31 +0200294 kwargs = dict((k, v) for k, v in six.iteritems(kwargs) if v)
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400295 subnet = self.create_subnet(self.network, **kwargs)
296 ip_range = netaddr.IPRange(subnet["allocation_pools"][0]["start"],
297 subnet["allocation_pools"][0]["end"])
298 ip = netaddr.IPAddress(random.randrange(ip_range.first,
299 ip_range.last)).format()
300 port = self.create_port(self.network,
301 fixed_ips=[{'subnet_id': subnet['id'],
302 'ip_address': ip}])
303 port_ip = next(iter(port['fixed_ips']), None)['ip_address']
304 self._clean_network()
305 self.assertEqual(port_ip, ip,
306 ("Port IP %s is not as fixed IP from "
307 "port create request: %s") % (
308 port_ip, ip))
309
Chris Hoge7579c1a2015-02-26 14:12:15 -0800310 @test.idempotent_id('98244d88-d990-4570-91d4-6b25d70d08af')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400311 def test_dhcp_stateful_fixedips_outrange(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000312 # NOTE: When port gets IP address from fixed IP range it
313 # shall be checked if it's from subnets range.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400314 kwargs = {'ipv6_ra_mode': 'dhcpv6-stateful',
315 'ipv6_address_mode': 'dhcpv6-stateful'}
316 subnet = self.create_subnet(self.network, **kwargs)
317 ip_range = netaddr.IPRange(subnet["allocation_pools"][0]["start"],
318 subnet["allocation_pools"][0]["end"])
319 ip = netaddr.IPAddress(random.randrange(
320 ip_range.last + 1, ip_range.last + 10)).format()
Masayuki Igawa4b29e472015-02-16 10:41:54 +0900321 self.assertRaises(lib_exc.BadRequest,
Qin Zhaoa4cae612015-01-28 16:27:00 +0800322 self.create_port,
323 self.network,
324 fixed_ips=[{'subnet_id': subnet['id'],
325 'ip_address': ip}])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400326
Chris Hoge7579c1a2015-02-26 14:12:15 -0800327 @test.idempotent_id('57b8302b-cba9-4fbb-8835-9168df029051')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400328 def test_dhcp_stateful_fixedips_duplicate(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000329 # NOTE: When port gets IP address from fixed IP range it
330 # shall be checked if it's not duplicate.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400331 kwargs = {'ipv6_ra_mode': 'dhcpv6-stateful',
332 'ipv6_address_mode': 'dhcpv6-stateful'}
333 subnet = self.create_subnet(self.network, **kwargs)
334 ip_range = netaddr.IPRange(subnet["allocation_pools"][0]["start"],
335 subnet["allocation_pools"][0]["end"])
336 ip = netaddr.IPAddress(random.randrange(
337 ip_range.first, ip_range.last)).format()
338 self.create_port(self.network,
339 fixed_ips=[
340 {'subnet_id': subnet['id'],
341 'ip_address': ip}])
reedip6fb7e1a2016-03-10 13:32:01 +0900342 self.assertRaisesRegex(lib_exc.Conflict,
343 "object with that identifier already exists",
344 self.create_port,
345 self.network,
346 fixed_ips=[{'subnet_id': subnet['id'],
347 'ip_address': ip}])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400348
349 def _create_subnet_router(self, kwargs):
350 subnet = self.create_subnet(self.network, **kwargs)
zhufl39ac5682016-10-24 17:11:34 +0800351 router = self.create_router(admin_state_up=True)
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400352 port = self.create_router_interface(router['id'],
353 subnet['id'])
John Warren49c0fe52015-10-22 12:35:54 -0400354 body = self.ports_client.show_port(port['port_id'])
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400355 return subnet, body['port']
356
Chris Hoge7579c1a2015-02-26 14:12:15 -0800357 @test.idempotent_id('e98f65db-68f4-4330-9fea-abd8c5192d4d')
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400358 def test_dhcp_stateful_router(self):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +0000359 # NOTE: With all options below the router interface shall
360 # receive DHCPv6 IP address from allocation pool.
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400361 for ra_mode, add_mode in (
362 ('dhcpv6-stateful', 'dhcpv6-stateful'),
363 ('dhcpv6-stateful', None),
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400364 ):
365 kwargs = {'ipv6_ra_mode': ra_mode,
366 'ipv6_address_mode': add_mode}
Jordan Pittieredee6502015-09-22 17:16:31 +0200367 kwargs = dict((k, v) for k, v in six.iteritems(kwargs) if v)
Sergey Shnaidmanf0ce2252014-08-28 13:05:08 +0400368 subnet, port = self._create_subnet_router(kwargs)
369 port_ip = next(iter(port['fixed_ips']), None)['ip_address']
370 self._clean_network()
371 self.assertEqual(port_ip, subnet['gateway_ip'],
372 ("Port IP %s is not as first IP from "
373 "subnets allocation pool: %s") % (
374 port_ip, subnet['gateway_ip']))
375
376 def tearDown(self):
377 self._clean_network()
378 super(NetworksTestDHCPv6, self).tearDown()