Browse Source

Merge "Fix unbound "mac" variable"

tags/6.0.0.0b1
Zuul 3 months ago
parent
commit
1bed5f830c

+ 1
- 1
networking_ovn/ml2/mech_driver.py View File

@@ -743,7 +743,7 @@ class OVNMechanismDriver(api.MechanismDriver):
743 743
                 'NAT', nat['_uuid'],
744 744
                 ('external_mac', mac)).execute(check_error=True)
745 745
         else:
746
-            LOG.debug("Clearing up external_mac of port %s", port_id, mac)
746
+            LOG.debug("Clearing up external_mac of port %s", port_id)
747 747
             self._nb_ovn.db_clear(
748 748
                 'NAT', nat['_uuid'], 'external_mac').execute(check_error=True)
749 749
 

+ 3
- 0
networking_ovn/tests/unit/fakes.py View File

@@ -135,6 +135,9 @@ class FakeOvsdbNbOvnIdl(object):
135 135
         self.nb_global = mock.Mock()
136 136
         self.db_list_rows = mock.Mock()
137 137
         self.lsp_list = mock.MagicMock()
138
+        self.db_find = mock.Mock()
139
+        self.db_set = mock.Mock()
140
+        self.db_clear = mock.Mock()
138 141
 
139 142
 
140 143
 class FakeOvsdbSbOvnIdl(object):

+ 32
- 0
networking_ovn/tests/unit/ml2/test_mech_driver.py View File

@@ -33,6 +33,7 @@ from oslo_config import cfg
33 33
 from oslo_db import exception as os_db_exc
34 34
 from oslo_serialization import jsonutils
35 35
 from oslo_utils import timeutils
36
+from oslo_utils import uuidutils
36 37
 
37 38
 from neutron.db import provisioning_blocks
38 39
 from neutron.plugins.ml2.drivers import type_geneve  # noqa
@@ -1444,6 +1445,37 @@ class TestOVNMechanismDriver(test_plugin.Ml2PluginV2TestCase):
1444 1445
         # shows it as "dead" instead of blowing up with an exception
1445 1446
         self.assertFalse(self.mech_driver.agent_alive(chassis, agent_type))
1446 1447
 
1448
+    def _test__update_dnat_entry_if_needed(self, up=True):
1449
+        ovn_config.cfg.CONF.set_override(
1450
+            'enable_distributed_floating_ip', True, group='ovn')
1451
+        port_id = 'fake-port-id'
1452
+        fake_ext_mac_key = 'fake-ext-mac-key'
1453
+        fake_nat_uuid = uuidutils.generate_uuid()
1454
+        nat_row = fakes.FakeOvsdbRow.create_one_ovsdb_row(
1455
+            attrs={'_uuid': fake_nat_uuid, 'external_ids': {
1456
+                ovn_const.OVN_FIP_EXT_MAC_KEY: fake_ext_mac_key}})
1457
+
1458
+        fake_db_find = mock.Mock()
1459
+        fake_db_find.execute.return_value = [nat_row]
1460
+        self.nb_ovn.db_find.return_value = fake_db_find
1461
+
1462
+        self.mech_driver._update_dnat_entry_if_needed(port_id, up=up)
1463
+
1464
+        if up:
1465
+            # Assert that we are setting the external_mac in the NAT table
1466
+            self.nb_ovn.db_set.assert_called_once_with(
1467
+                'NAT', fake_nat_uuid, ('external_mac', fake_ext_mac_key))
1468
+        else:
1469
+            # Assert that we are cleaning the external_mac from the NAT table
1470
+            self.nb_ovn.db_clear.assert_called_once_with(
1471
+                'NAT', fake_nat_uuid, 'external_mac')
1472
+
1473
+    def test__update_dnat_entry_if_needed_up(self):
1474
+        self._test__update_dnat_entry_if_needed()
1475
+
1476
+    def test__update_dnat_entry_if_needed_down(self):
1477
+        self._test__update_dnat_entry_if_needed(up=False)
1478
+
1447 1479
 
1448 1480
 class OVNMechanismDriverTestCase(test_plugin.Ml2PluginV2TestCase):
1449 1481
     _mechanism_drivers = ['logger', 'ovn']

Loading…
Cancel
Save