16
16
from unittest import mock
17
17
18
18
from neutron_lib .api .definitions import external_net
19
+ from neutron_lib .api .definitions import l3 as l3_def
19
20
from neutron_lib .api .definitions import portbindings
20
21
from neutron_lib .api .definitions import provider_net as pnet
21
22
from neutron_lib .callbacks import events
26
27
from neutron_lib .exceptions import l3 as l3_exc
27
28
from neutron_lib .plugins import constants as plugin_constants
28
29
from neutron_lib .plugins import directory
30
+ from neutron_lib .services .qos import constants as qos_consts
29
31
from oslo_config import cfg
30
32
from oslo_utils import uuidutils
31
33
32
34
from neutron .common .ovn import constants as ovn_const
33
35
from neutron .common .ovn import utils
34
36
from neutron .conf .plugins .ml2 .drivers .ovn import ovn_conf as config
37
+ from neutron .db import extraroute_db
35
38
from neutron .services .revisions import revision_plugin
36
39
from neutron .tests .unit .api import test_extensions
37
40
from neutron .tests .unit .extensions import test_extraroute
@@ -1216,7 +1219,8 @@ def test_update_floatingip(self, uf):
1216
1219
uf .return_value = self .fake_floating_ip_new
1217
1220
nb_ovn .get_floatingip .return_value = (
1218
1221
self .fake_ovn_nat_rule )
1219
- self .l3_inst .update_floatingip (self .context , 'id' , 'floatingip' )
1222
+ fip = {l3_def .FLOATINGIP : {'port_id' : 'port1' }}
1223
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1220
1224
nb_ovn .delete_nat_rule_in_lrouter .assert_called_once_with (
1221
1225
'neutron-router-id' ,
1222
1226
type = 'dnat_and_snat' ,
@@ -1240,13 +1244,30 @@ def test_update_floatingip(self, uf):
1240
1244
logical_port = 'new-port_id' ,
1241
1245
external_ids = expected_ext_ids )
1242
1246
1247
+ @mock .patch .object (extraroute_db .ExtraRoute_dbonly_mixin ,
1248
+ 'update_floatingip' )
1249
+ def test_update_floatingip_qos (self , uf ):
1250
+ nb_ovn = self .l3_inst ._nb_ovn
1251
+ nb_ovn .is_col_present .return_value = True
1252
+ uf .return_value = self .fake_floating_ip_new
1253
+ nb_ovn .get_floatingip .return_value = (
1254
+ self .fake_ovn_nat_rule )
1255
+ fip = {l3_def .FLOATINGIP : {qos_consts .QOS_POLICY_ID : 'qos_id_1' }}
1256
+ with mock .patch .object (self .l3_inst ._ovn_client ._qos_driver ,
1257
+ 'update_floatingip' ) as ufip :
1258
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1259
+ nb_ovn .delete_nat_rule_in_lrouter .assert_not_called ()
1260
+ nb_ovn .add_nat_rule_in_lrouter .assert_not_called ()
1261
+ ufip .assert_called_once_with (mock .ANY , self .fake_floating_ip_new )
1262
+
1243
1263
@mock .patch ('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
1244
1264
'update_floatingip' )
1245
1265
def test_update_floatingip_associate (self , uf ):
1246
1266
self .l3_inst ._nb_ovn .is_col_present .return_value = True
1247
1267
self .fake_floating_ip .update ({'fixed_port_id' : None })
1248
1268
uf .return_value = self .fake_floating_ip_new
1249
- self .l3_inst .update_floatingip (self .context , 'id' , 'floatingip' )
1269
+ fip = {l3_def .FLOATINGIP : {'port_id' : 'port1' }}
1270
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1250
1271
self .l3_inst ._nb_ovn .delete_nat_rule_in_lrouter .assert_not_called ()
1251
1272
expected_ext_ids = {
1252
1273
ovn_const .OVN_FIP_EXT_ID_KEY : self .fake_floating_ip_new ['id' ],
@@ -1282,7 +1303,8 @@ def test_update_floatingip_associate_distributed(self, uf, gn):
1282
1303
1283
1304
config .cfg .CONF .set_override (
1284
1305
'enable_distributed_floating_ip' , True , group = 'ovn' )
1285
- self .l3_inst .update_floatingip (self .context , 'id' , 'floatingip' )
1306
+ fip = {l3_def .FLOATINGIP : {'port_id' : 'port1' }}
1307
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1286
1308
self .l3_inst ._nb_ovn .delete_nat_rule_in_lrouter .assert_not_called ()
1287
1309
expected_ext_ids = {
1288
1310
ovn_const .OVN_FIP_EXT_ID_KEY : self .fake_floating_ip_new ['id' ],
@@ -1310,7 +1332,8 @@ def test_update_floatingip_association_empty_update(self, uf):
1310
1332
self .fake_floating_ip .update ({'fixed_port_id' : 'foo' })
1311
1333
self .fake_floating_ip_new .update ({'port_id' : 'foo' })
1312
1334
uf .return_value = self .fake_floating_ip_new
1313
- self .l3_inst .update_floatingip (self .context , 'id' , 'floatingip' )
1335
+ fip = {l3_def .FLOATINGIP : {'port_id' : 'port1' }}
1336
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1314
1337
nb_ovn .delete_nat_rule_in_lrouter .assert_called_once_with (
1315
1338
'neutron-router-id' ,
1316
1339
type = 'dnat_and_snat' ,
@@ -1345,7 +1368,8 @@ def test_update_floatingip_reassociate_to_same_port_diff_fixed_ip(
1345
1368
self .fake_floating_ip_new .update ({'port_id' : 'port_id' ,
1346
1369
'fixed_port_id' : 'port_id' })
1347
1370
uf .return_value = self .fake_floating_ip_new
1348
- self .l3_inst .update_floatingip (self .context , 'id' , 'floatingip' )
1371
+ fip = {l3_def .FLOATINGIP : {'port_id' : 'port1' }}
1372
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1349
1373
1350
1374
nb_ovn .delete_nat_rule_in_lrouter .assert_called_once_with (
1351
1375
'neutron-router-id' ,
0 commit comments