Browse Source

Merge "Fix cleaning vlan_bindings in neutron db when vlan is 0."

changes/01/751301/1
Zuul 1 year ago
committed by Gerrit Code Review
parent
commit
f408a9fd7a
  1. 3
      networking_l2gw/db/l2gateway/ovsdb/lib.py
  2. 16
      networking_l2gw/tests/unit/db/ovsdb/test_lib.py

3
networking_l2gw/db/l2gateway/ovsdb/lib.py

@ -38,7 +38,8 @@ def delete_vlan_binding(context, record_dict):
"""Delete vlan bindings of a given physical port."""
session = context.session
with session.begin(subtransactions=True):
if(record_dict['vlan'] and record_dict['logical_switch_uuid']):
if (record_dict['vlan'] is not None and
record_dict['logical_switch_uuid']):
session.query(models.VlanBindings).filter_by(
port_uuid=record_dict['port_uuid'], vlan=record_dict['vlan'],
logical_switch_uuid=record_dict['logical_switch_uuid'],

16
networking_l2gw/tests/unit/db/ovsdb/test_lib.py

@ -341,6 +341,15 @@ class OvsdbLibTestCase(testlib_api.SqlTestCase):
'ovsdb_identifier': 'host1'}
return record_dict
def _get_vlan0_binding_dict(self):
port_uuid = _uuid()
ls_uuid = _uuid()
record_dict = {'port_uuid': port_uuid,
'vlan': 0,
'logical_switch_uuid': ls_uuid,
'ovsdb_identifier': 'host1'}
return record_dict
def _create_vlan_binding(self, record_dict, port_uuid=None):
if port_uuid:
record_dict['port_uuid'] = port_uuid
@ -382,6 +391,13 @@ class OvsdbLibTestCase(testlib_api.SqlTestCase):
count = self.ctx.session.query(models.VlanBindings).count()
self.assertEqual(count, 0)
def test_delete_vlan0_binding(self):
record_dict = self._get_vlan0_binding_dict()
self._create_vlan_binding(record_dict)
lib.delete_vlan_binding(self.ctx, record_dict)
count = self.ctx.session.query(models.VlanBindings).count()
self.assertEqual(count, 0)
def test_get_logical_switch_by_name(self):
record_dict = self._get_logical_switch_dict()
with self.ctx.session.begin(subtransactions=True):

Loading…
Cancel
Save