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 .api .v2 import router as api_router
33
35
from neutron .common .ovn import constants as ovn_const
34
36
from neutron .common .ovn import utils
35
37
from neutron .conf .plugins .ml2 .drivers .ovn import ovn_conf as config
38
+ from neutron .db import extraroute_db
36
39
from neutron import manager as neutron_manager
37
40
from neutron .plugins .ml2 import managers
38
41
from neutron .services .ovn_l3 import exceptions as ovn_l3_exc
@@ -1220,7 +1223,8 @@ def test_update_floatingip(self, uf):
1220
1223
uf .return_value = self .fake_floating_ip_new
1221
1224
nb_ovn .get_floatingip .return_value = (
1222
1225
self .fake_ovn_nat_rule )
1223
- self .l3_inst .update_floatingip (self .context , 'id' , 'floatingip' )
1226
+ fip = {l3_def .FLOATINGIP : {'port_id' : 'port1' }}
1227
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1224
1228
nb_ovn .delete_nat_rule_in_lrouter .assert_called_once_with (
1225
1229
'neutron-router-id' ,
1226
1230
type = 'dnat_and_snat' ,
@@ -1244,13 +1248,30 @@ def test_update_floatingip(self, uf):
1244
1248
logical_port = 'new-port_id' ,
1245
1249
external_ids = expected_ext_ids )
1246
1250
1251
+ @mock .patch .object (extraroute_db .ExtraRoute_dbonly_mixin ,
1252
+ 'update_floatingip' )
1253
+ def test_update_floatingip_qos (self , uf ):
1254
+ nb_ovn = self .l3_inst ._nb_ovn
1255
+ nb_ovn .is_col_present .return_value = True
1256
+ uf .return_value = self .fake_floating_ip_new
1257
+ nb_ovn .get_floatingip .return_value = (
1258
+ self .fake_ovn_nat_rule )
1259
+ fip = {l3_def .FLOATINGIP : {qos_consts .QOS_POLICY_ID : 'qos_id_1' }}
1260
+ with mock .patch .object (self .l3_inst ._ovn_client ._qos_driver ,
1261
+ 'update_floatingip' ) as ufip :
1262
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1263
+ nb_ovn .delete_nat_rule_in_lrouter .assert_not_called ()
1264
+ nb_ovn .add_nat_rule_in_lrouter .assert_not_called ()
1265
+ ufip .assert_called_once_with (mock .ANY , self .fake_floating_ip_new )
1266
+
1247
1267
@mock .patch ('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
1248
1268
'update_floatingip' )
1249
1269
def test_update_floatingip_associate (self , uf ):
1250
1270
self .l3_inst ._nb_ovn .is_col_present .return_value = True
1251
1271
self .fake_floating_ip .update ({'fixed_port_id' : None })
1252
1272
uf .return_value = self .fake_floating_ip_new
1253
- self .l3_inst .update_floatingip (self .context , 'id' , 'floatingip' )
1273
+ fip = {l3_def .FLOATINGIP : {'port_id' : 'port1' }}
1274
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1254
1275
self .l3_inst ._nb_ovn .delete_nat_rule_in_lrouter .assert_not_called ()
1255
1276
expected_ext_ids = {
1256
1277
ovn_const .OVN_FIP_EXT_ID_KEY : self .fake_floating_ip_new ['id' ],
@@ -1286,7 +1307,8 @@ def test_update_floatingip_associate_distributed(self, uf, gn):
1286
1307
1287
1308
config .cfg .CONF .set_override (
1288
1309
'enable_distributed_floating_ip' , True , group = 'ovn' )
1289
- self .l3_inst .update_floatingip (self .context , 'id' , 'floatingip' )
1310
+ fip = {l3_def .FLOATINGIP : {'port_id' : 'port1' }}
1311
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1290
1312
self .l3_inst ._nb_ovn .delete_nat_rule_in_lrouter .assert_not_called ()
1291
1313
expected_ext_ids = {
1292
1314
ovn_const .OVN_FIP_EXT_ID_KEY : self .fake_floating_ip_new ['id' ],
@@ -1314,7 +1336,8 @@ def test_update_floatingip_association_empty_update(self, uf):
1314
1336
self .fake_floating_ip .update ({'fixed_port_id' : 'foo' })
1315
1337
self .fake_floating_ip_new .update ({'port_id' : 'foo' })
1316
1338
uf .return_value = self .fake_floating_ip_new
1317
- self .l3_inst .update_floatingip (self .context , 'id' , 'floatingip' )
1339
+ fip = {l3_def .FLOATINGIP : {'port_id' : 'port1' }}
1340
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1318
1341
nb_ovn .delete_nat_rule_in_lrouter .assert_called_once_with (
1319
1342
'neutron-router-id' ,
1320
1343
type = 'dnat_and_snat' ,
@@ -1349,7 +1372,8 @@ def test_update_floatingip_reassociate_to_same_port_diff_fixed_ip(
1349
1372
self .fake_floating_ip_new .update ({'port_id' : 'port_id' ,
1350
1373
'fixed_port_id' : 'port_id' })
1351
1374
uf .return_value = self .fake_floating_ip_new
1352
- self .l3_inst .update_floatingip (self .context , 'id' , 'floatingip' )
1375
+ fip = {l3_def .FLOATINGIP : {'port_id' : 'port1' }}
1376
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1353
1377
1354
1378
nb_ovn .delete_nat_rule_in_lrouter .assert_called_once_with (
1355
1379
'neutron-router-id' ,
0 commit comments