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
@@ -1210,7 +1213,8 @@ def test_update_floatingip(self, uf):
1210
1213
uf .return_value = self .fake_floating_ip_new
1211
1214
nb_ovn .get_floatingip .return_value = (
1212
1215
self .fake_ovn_nat_rule )
1213
- self .l3_inst .update_floatingip (self .context , 'id' , 'floatingip' )
1216
+ fip = {l3_def .FLOATINGIP : {'port_id' : 'port1' }}
1217
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1214
1218
nb_ovn .delete_nat_rule_in_lrouter .assert_called_once_with (
1215
1219
'neutron-router-id' ,
1216
1220
type = 'dnat_and_snat' ,
@@ -1234,13 +1238,30 @@ def test_update_floatingip(self, uf):
1234
1238
logical_port = 'new-port_id' ,
1235
1239
external_ids = expected_ext_ids )
1236
1240
1241
+ @mock .patch .object (extraroute_db .ExtraRoute_dbonly_mixin ,
1242
+ 'update_floatingip' )
1243
+ def test_update_floatingip_qos (self , uf ):
1244
+ nb_ovn = self .l3_inst ._nb_ovn
1245
+ nb_ovn .is_col_present .return_value = True
1246
+ uf .return_value = self .fake_floating_ip_new
1247
+ nb_ovn .get_floatingip .return_value = (
1248
+ self .fake_ovn_nat_rule )
1249
+ fip = {l3_def .FLOATINGIP : {qos_consts .QOS_POLICY_ID : 'qos_id_1' }}
1250
+ with mock .patch .object (self .l3_inst ._ovn_client ._qos_driver ,
1251
+ 'update_floatingip' ) as ufip :
1252
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1253
+ nb_ovn .delete_nat_rule_in_lrouter .assert_not_called ()
1254
+ nb_ovn .add_nat_rule_in_lrouter .assert_not_called ()
1255
+ ufip .assert_called_once_with (mock .ANY , self .fake_floating_ip_new )
1256
+
1237
1257
@mock .patch ('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
1238
1258
'update_floatingip' )
1239
1259
def test_update_floatingip_associate (self , uf ):
1240
1260
self .l3_inst ._nb_ovn .is_col_present .return_value = True
1241
1261
self .fake_floating_ip .update ({'fixed_port_id' : None })
1242
1262
uf .return_value = self .fake_floating_ip_new
1243
- self .l3_inst .update_floatingip (self .context , 'id' , 'floatingip' )
1263
+ fip = {l3_def .FLOATINGIP : {'port_id' : 'port1' }}
1264
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1244
1265
self .l3_inst ._nb_ovn .delete_nat_rule_in_lrouter .assert_not_called ()
1245
1266
expected_ext_ids = {
1246
1267
ovn_const .OVN_FIP_EXT_ID_KEY : self .fake_floating_ip_new ['id' ],
@@ -1276,7 +1297,8 @@ def test_update_floatingip_associate_distributed(self, uf, gn):
1276
1297
1277
1298
config .cfg .CONF .set_override (
1278
1299
'enable_distributed_floating_ip' , True , group = 'ovn' )
1279
- self .l3_inst .update_floatingip (self .context , 'id' , 'floatingip' )
1300
+ fip = {l3_def .FLOATINGIP : {'port_id' : 'port1' }}
1301
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1280
1302
self .l3_inst ._nb_ovn .delete_nat_rule_in_lrouter .assert_not_called ()
1281
1303
expected_ext_ids = {
1282
1304
ovn_const .OVN_FIP_EXT_ID_KEY : self .fake_floating_ip_new ['id' ],
@@ -1304,7 +1326,8 @@ def test_update_floatingip_association_empty_update(self, uf):
1304
1326
self .fake_floating_ip .update ({'fixed_port_id' : 'foo' })
1305
1327
self .fake_floating_ip_new .update ({'port_id' : 'foo' })
1306
1328
uf .return_value = self .fake_floating_ip_new
1307
- self .l3_inst .update_floatingip (self .context , 'id' , 'floatingip' )
1329
+ fip = {l3_def .FLOATINGIP : {'port_id' : 'port1' }}
1330
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1308
1331
nb_ovn .delete_nat_rule_in_lrouter .assert_called_once_with (
1309
1332
'neutron-router-id' ,
1310
1333
type = 'dnat_and_snat' ,
@@ -1339,7 +1362,8 @@ def test_update_floatingip_reassociate_to_same_port_diff_fixed_ip(
1339
1362
self .fake_floating_ip_new .update ({'port_id' : 'port_id' ,
1340
1363
'fixed_port_id' : 'port_id' })
1341
1364
uf .return_value = self .fake_floating_ip_new
1342
- self .l3_inst .update_floatingip (self .context , 'id' , 'floatingip' )
1365
+ fip = {l3_def .FLOATINGIP : {'port_id' : 'port1' }}
1366
+ self .l3_inst .update_floatingip (self .context , 'id' , fip )
1343
1367
1344
1368
nb_ovn .delete_nat_rule_in_lrouter .assert_called_once_with (
1345
1369
'neutron-router-id' ,
0 commit comments