28
28
29
29
from neutron .db import ipam_backend_mixin
30
30
from neutron .db import ipam_pluggable_backend
31
+ from neutron .ipam import exceptions as ipam_exc
31
32
from neutron .ipam import requests as ipam_req
32
33
from neutron .objects import network as network_obj
33
34
from neutron .objects import ports as port_obj
@@ -382,6 +383,7 @@ def test_test_fixed_ips_for_port_pd_gateway(self):
382
383
subnet ['network_id' ],
383
384
fixed_ips ,
384
385
constants .DEVICE_OWNER_ROUTER_INTF ,
386
+ "aa:bb:cc:dd:ee:ff" ,
385
387
[subnet ]))
386
388
# Assert that ports created on prefix delegation subnets
387
389
# will be returned without an ip address. This prevents router
@@ -390,6 +392,31 @@ def test_test_fixed_ips_for_port_pd_gateway(self):
390
392
self .assertEqual (subnet ['id' ], filtered_ips [0 ]['subnet_id' ])
391
393
self .assertNotIn ('ip_address' , filtered_ips [0 ])
392
394
395
+ def test_test_fixed_ips_for_port_allocation_on_auto_address_subnet (self ):
396
+ context = mock .Mock ()
397
+ pluggable_backend = ipam_pluggable_backend .IpamPluggableBackend ()
398
+ with self .subnet (cidr = "2001:db8::/64" ,
399
+ ip_version = constants .IP_VERSION_6 ,
400
+ ipv6_ra_mode = constants .IPV6_SLAAC ,
401
+ ipv6_address_mode = constants .IPV6_SLAAC ) as subnet :
402
+ subnet = subnet ['subnet' ]
403
+ bad_fixed_ip = [{'subnet_id' : subnet ['id' ],
404
+ 'ip_address' : '2001:db8::22' }]
405
+ eui64_fixed_ip = [{'subnet_id' : subnet ['id' ],
406
+ 'ip_address' : '2001:db8::a8bb:ccff:fedd:eeff' }]
407
+ self .assertRaises (
408
+ ipam_exc .AllocationOnAutoAddressSubnet ,
409
+ pluggable_backend ._test_fixed_ips_for_port ,
410
+ context , subnet ['network_id' ], bad_fixed_ip ,
411
+ "device_owner" , "aa:bb:cc:dd:ee:ff" ,
412
+ [subnet ])
413
+
414
+ filtered_ips = pluggable_backend ._test_fixed_ips_for_port (
415
+ context , subnet ['network_id' ], eui64_fixed_ip , "device_owner" ,
416
+ "aa:bb:cc:dd:ee:ff" , [subnet ])
417
+ self .assertEqual (1 , len (filtered_ips ))
418
+ self .assertEqual (subnet ['id' ], filtered_ips [0 ]['subnet_id' ])
419
+
393
420
@mock .patch ('neutron.ipam.driver.Pool' )
394
421
def test_create_subnet_over_ipam (self , pool_mock ):
395
422
mocks = self ._prepare_mocks_with_pool_mock (pool_mock )
@@ -686,6 +713,7 @@ def test_update_ips_for_port_passes_port_dict_to_factory(self, pool_mock):
686
713
mocks ['ipam' ]._update_ips_for_pd_subnet = mock .Mock (return_value = [])
687
714
688
715
port_dict = {'device_owner' : uuidutils .generate_uuid (),
716
+ 'mac_address' : 'aa:bb:cc:dd:ee:ff' ,
689
717
'network_id' : uuidutils .generate_uuid ()}
690
718
691
719
mocks ['ipam' ]._update_ips_for_port (context , port_dict , None ,
@@ -726,6 +754,7 @@ def test_update_ips_for_port_ovn_distributed_svc(self, pool_mock):
726
754
port_dict = {
727
755
'device_owner' : constants .DEVICE_OWNER_DISTRIBUTED ,
728
756
'device_id' : 'ovnmeta-%s' % uuidutils .generate_uuid (),
757
+ 'mac_address' : 'aa:bb:cc:dd:ee:ff' ,
729
758
'network_id' : uuidutils .generate_uuid ()}
730
759
731
760
mocks ['ipam' ]._update_ips_for_port (context , port_dict , None ,
@@ -749,6 +778,7 @@ def test_update_ips_for_port_passes_port_id_to_factory(self, pool_mock):
749
778
'subnet_id' : uuidutils .generate_uuid ()}
750
779
port_dict = {'port' : {'device_owner' : uuidutils .generate_uuid (),
751
780
'network_id' : network_id ,
781
+ 'mac_address' : 'aa:bb:cc:dd:ee:ff' ,
752
782
'fixed_ips' : [ip_dict ]}}
753
783
subnets = [{'id' : ip_dict ['subnet_id' ],
754
784
'network_id' : network_id ,
0 commit comments