Merge "evpn: Remove Chassis events" into stable/2024.1

This commit is contained in:
Zuul 2024-11-20 12:05:19 +00:00 committed by Gerrit Code Review
commit bafab4132b
8 changed files with 59 additions and 110 deletions

View File

@ -27,6 +27,7 @@ from ovn_bgp_agent.drivers.openstack.utils import driver_utils
from ovn_bgp_agent.drivers.openstack.utils import ovn from ovn_bgp_agent.drivers.openstack.utils import ovn
from ovn_bgp_agent.drivers.openstack.utils import ovs from ovn_bgp_agent.drivers.openstack.utils import ovs
from ovn_bgp_agent.drivers.openstack.utils import wire as wire_utils from ovn_bgp_agent.drivers.openstack.utils import wire as wire_utils
from ovn_bgp_agent.drivers.openstack.watchers import base_watcher
from ovn_bgp_agent.drivers.openstack.watchers import bgp_watcher as watcher from ovn_bgp_agent.drivers.openstack.watchers import bgp_watcher as watcher
from ovn_bgp_agent import exceptions as agent_exc from ovn_bgp_agent import exceptions as agent_exc
from ovn_bgp_agent.utils import helpers from ovn_bgp_agent.utils import helpers
@ -112,8 +113,8 @@ class OVNBGPDriver(driver_api.AgentDriverBase):
watcher.FIPUnsetEvent(self), watcher.FIPUnsetEvent(self),
watcher.OVNLBMemberCreateEvent(self), watcher.OVNLBMemberCreateEvent(self),
watcher.OVNLBMemberDeleteEvent(self), watcher.OVNLBMemberDeleteEvent(self),
watcher.ChassisCreateEvent(self), base_watcher.ChassisCreateEvent(self),
watcher.ChassisPrivateCreateEvent(self), base_watcher.ChassisPrivateCreateEvent(self),
watcher.LocalnetCreateDeleteEvent(self)} watcher.LocalnetCreateDeleteEvent(self)}
if self._expose_tenant_networks: if self._expose_tenant_networks:
events.update({watcher.SubnetRouterAttachedEvent(self), events.update({watcher.SubnetRouterAttachedEvent(self),

View File

@ -25,6 +25,7 @@ from ovn_bgp_agent.drivers import driver_api
from ovn_bgp_agent.drivers.openstack.utils import frr from ovn_bgp_agent.drivers.openstack.utils import frr
from ovn_bgp_agent.drivers.openstack.utils import ovn from ovn_bgp_agent.drivers.openstack.utils import ovn
from ovn_bgp_agent.drivers.openstack.utils import ovs from ovn_bgp_agent.drivers.openstack.utils import ovs
from ovn_bgp_agent.drivers.openstack.watchers import base_watcher
from ovn_bgp_agent.drivers.openstack.watchers import evpn_watcher as \ from ovn_bgp_agent.drivers.openstack.watchers import evpn_watcher as \
watcher watcher
from ovn_bgp_agent.utils import helpers from ovn_bgp_agent.utils import helpers
@ -91,8 +92,8 @@ class OVNEVPNDriver(driver_api.AgentDriverBase):
watcher.SubnetRouterDetachedEvent(self), watcher.SubnetRouterDetachedEvent(self),
watcher.TenantPortCreatedEvent(self), watcher.TenantPortCreatedEvent(self),
watcher.TenantPortDeletedEvent(self), watcher.TenantPortDeletedEvent(self),
watcher.ChassisCreateEvent(self), base_watcher.ChassisCreateEvent(self),
watcher.ChassisPrivateCreateEvent(self), base_watcher.ChassisPrivateCreateEvent(self),
watcher.LocalnetCreateDeleteEvent(self)} watcher.LocalnetCreateDeleteEvent(self)}
@lockutils.synchronized('evpn') @lockutils.synchronized('evpn')

View File

@ -149,3 +149,30 @@ class LRPChassisEvent(Event):
'logical_switch': self._get_network(row), 'logical_switch': self._get_network(row),
'router': row.external_ids.get(constants.OVN_LR_NAME_EXT_ID_KEY), 'router': row.external_ids.get(constants.OVN_LR_NAME_EXT_ID_KEY),
} }
class ChassisCreateEventBase(Event):
table = None
def __init__(self, bgp_agent):
self.first_time = True
events = (self.ROW_CREATE,)
super().__init__(
bgp_agent, events, self.table,
(('name', '=', bgp_agent.chassis),))
self.event_name = self.__class__.__name__
def _run(self, event, row, old):
if self.first_time:
self.first_time = False
else:
LOG.info("Connection to OVSDB established, doing a full sync")
self.agent.sync()
class ChassisCreateEvent(ChassisCreateEventBase):
table = 'Chassis'
class ChassisPrivateCreateEvent(ChassisCreateEventBase):
table = 'Chassis_Private'

View File

@ -481,30 +481,3 @@ class LocalnetCreateDeleteEvent(base_watcher.PortBindingChassisEvent):
def _run(self, event, row, old): def _run(self, event, row, old):
with _SYNC_STATE_LOCK.read_lock(): with _SYNC_STATE_LOCK.read_lock():
self.agent.sync() self.agent.sync()
class ChassisCreateEventBase(base_watcher.Event):
table = None
def __init__(self, bgp_agent):
self.first_time = True
events = (self.ROW_CREATE,)
super().__init__(
bgp_agent, events, self.table,
(('name', '=', bgp_agent.chassis),))
self.event_name = self.__class__.__name__
def _run(self, event, row, old):
if self.first_time:
self.first_time = False
else:
LOG.info("Connection to OVSDB established, doing a full sync")
self.agent.sync()
class ChassisCreateEvent(ChassisCreateEventBase):
table = 'Chassis'
class ChassisPrivateCreateEvent(ChassisCreateEventBase):
table = 'Chassis_Private'

View File

@ -213,30 +213,3 @@ class LocalnetCreateDeleteEvent(base_watcher.PortBindingChassisEvent):
def _run(self, event, row, old): def _run(self, event, row, old):
with _SYNC_STATE_LOCK.read_lock(): with _SYNC_STATE_LOCK.read_lock():
self.agent.sync() self.agent.sync()
class ChassisCreateEventBase(base_watcher.Event):
table = None
def __init__(self, bgp_agent):
self.first_time = True
events = (self.ROW_CREATE,)
super().__init__(
bgp_agent, events, self.table,
(('name', '=', bgp_agent.chassis),))
self.event_name = self.__class__.__name__
def _run(self, event, row, old):
if self.first_time:
self.first_time = False
else:
LOG.info("Connection to OVSDB established, doing a full sync")
self.agent.sync()
class ChassisCreateEvent(ChassisCreateEventBase):
table = 'Chassis'
class ChassisPrivateCreateEvent(ChassisCreateEventBase):
table = 'Chassis_Private'

View File

@ -132,3 +132,29 @@ class TestLRPChassisEvent(test_base.TestCase):
self.assertEqual('test-net', self.lrp_event._get_network(row)) self.assertEqual('test-net', self.lrp_event._get_network(row))
row = utils.create_row(external_ids={}) row = utils.create_row(external_ids={})
self.assertEqual(None, self.lrp_event._get_network(row)) self.assertEqual(None, self.lrp_event._get_network(row))
class TestChassisCreateEvent(test_base.TestCase):
_event = base_watcher.ChassisCreateEvent
def setUp(self):
super(TestChassisCreateEvent, self).setUp()
self.chassis = '935f91fa-b8f8-47b9-8b1b-3a7a90ef7c26'
self.agent = mock.Mock(chassis=self.chassis)
self.event = self._event(self.agent)
def test_run(self):
self.assertTrue(self.event.first_time)
self.event.run(mock.Mock(), mock.Mock(), mock.Mock())
self.assertFalse(self.event.first_time)
self.agent.sync.assert_not_called()
def test_run_not_first_time(self):
self.event.first_time = False
self.event.run(mock.Mock(), mock.Mock(), mock.Mock())
self.agent.sync.assert_called_once_with()
class TestChassisPrivateCreateEvent(TestChassisCreateEvent):
_event = base_watcher.ChassisPrivateCreateEvent

View File

@ -1060,29 +1060,3 @@ class TestLocalnetCreateDeleteEvent(test_base.TestCase):
def test_run(self): def test_run(self):
self.event.run(mock.Mock(), mock.Mock(), mock.Mock()) self.event.run(mock.Mock(), mock.Mock(), mock.Mock())
self.agent.sync.assert_called_once() self.agent.sync.assert_called_once()
class TestChassisCreateEvent(test_base.TestCase):
_event = bgp_watcher.ChassisCreateEvent
def setUp(self):
super(TestChassisCreateEvent, self).setUp()
self.chassis = '935f91fa-b8f8-47b9-8b1b-3a7a90ef7c26'
self.agent = mock.Mock(chassis=self.chassis)
self.event = self._event(self.agent)
def test_run(self):
self.assertTrue(self.event.first_time)
self.event.run(mock.Mock(), mock.Mock(), mock.Mock())
self.assertFalse(self.event.first_time)
self.agent.sync.assert_not_called()
def test_run_not_first_time(self):
self.event.first_time = False
self.event.run(mock.Mock(), mock.Mock(), mock.Mock())
self.agent.sync.assert_called_once_with()
class TestChassisPrivateCreateEvent(TestChassisCreateEvent):
_event = bgp_watcher.ChassisPrivateCreateEvent

View File

@ -501,29 +501,3 @@ class TestLocalnetCreateDeleteEvent(test_base.TestCase):
def test_run(self): def test_run(self):
self.event.run(mock.Mock(), mock.Mock(), mock.Mock()) self.event.run(mock.Mock(), mock.Mock(), mock.Mock())
self.agent.sync.assert_called_once() self.agent.sync.assert_called_once()
class TestChassisCreateEvent(test_base.TestCase):
_event = evpn_watcher.ChassisCreateEvent
def setUp(self):
super(TestChassisCreateEvent, self).setUp()
self.chassis = '935f91fa-b8f8-47b9-8b1b-3a7a90ef7c26'
self.agent = mock.Mock(chassis=self.chassis)
self.event = self._event(self.agent)
def test_run(self):
self.assertTrue(self.event.first_time)
self.event.run(mock.Mock(), mock.Mock(), mock.Mock())
self.assertFalse(self.event.first_time)
self.agent.sync.assert_not_called()
def test_run_not_first_time(self):
self.event.first_time = False
self.event.run(mock.Mock(), mock.Mock(), mock.Mock())
self.agent.sync.assert_called_once_with()
class TestChassisPrivateCreateEvent(TestChassisCreateEvent):
_event = evpn_watcher.ChassisPrivateCreateEvent