[OVN] Add a start method to the OVN agent extensions
Each OVN agent extension can implement a start method. It is called after the extension manager initialization, at the end of the ``OVNNeutronAgent.start`` call. Related-Bug: #2017871 Change-Id: I334027f061fa963c1cf24540b27c1ff76145b977
This commit is contained in:
parent
9e74ea11e8
commit
cd1eb7852d
|
@ -141,7 +141,8 @@ class OVNNeutronAgent(service.Service):
|
|||
# "load_config" to populate self.chassis.
|
||||
self.ext_manager_api.sb_idl = self._load_sb_idl()
|
||||
self.ext_manager_api.nb_idl = self._load_nb_idl()
|
||||
LOG.info('Starting OVN Neutron Agent')
|
||||
self.ext_manager.start()
|
||||
LOG.info('OVN Neutron Agent started')
|
||||
|
||||
def stop(self, graceful=True):
|
||||
LOG.info('Stopping OVN Neutron Agent')
|
||||
|
|
|
@ -41,6 +41,11 @@ class OVNAgentExtensionManager(agent_ext_mgr.AgentExtensionsManager):
|
|||
'"OVNAgentExtension"')
|
||||
raise ConfigException(description=desc)
|
||||
|
||||
def start(self):
|
||||
"""Start the extensions, once the OVN agent has been initialized."""
|
||||
for ext in self:
|
||||
ext.obj.start()
|
||||
|
||||
|
||||
class OVNAgentExtension(extension.AgentExtension, metaclass=abc.ABCMeta):
|
||||
|
||||
|
@ -65,6 +70,14 @@ class OVNAgentExtension(extension.AgentExtension, metaclass=abc.ABCMeta):
|
|||
"""
|
||||
self.agent_api = agent_api
|
||||
|
||||
def start(self):
|
||||
"""Start the extension, once the OVN agent has been initialized.
|
||||
|
||||
This method executes any action needed after the initialization of the
|
||||
OVN agent and the extension manager API. It is executed at the end of
|
||||
the OVN agent ``start`` method.
|
||||
"""
|
||||
|
||||
@property
|
||||
@abc.abstractmethod
|
||||
def ovs_idl_events(self):
|
||||
|
|
|
@ -77,3 +77,6 @@ class FakeOVNAgentExtension(ext_mgr.OVNAgentExtension):
|
|||
@property
|
||||
def sb_idl_events(self):
|
||||
return [OVNSBChassisEvent]
|
||||
|
||||
def start(self):
|
||||
self._is_ext_started = True
|
||||
|
|
|
@ -39,9 +39,10 @@ class TestOVNNeutronAgent(base.TestOVNFunctionalBase):
|
|||
agent_ovsdb, 'get_own_chassis_name').start()
|
||||
self.ovn_agent = self._start_ovn_neutron_agent()
|
||||
|
||||
def _check_loaded_extensions(self, ovn_agent):
|
||||
def _check_loaded_and_started_extensions(self, ovn_agent):
|
||||
loaded_ext = ovn_agent[TEST_EXTENSION]
|
||||
self.assertEqual('Fake OVN agent extension', loaded_ext.name)
|
||||
self.assertTrue(loaded_ext._is_ext_started)
|
||||
|
||||
def _start_ovn_neutron_agent(self):
|
||||
conf = self.useFixture(fixture_config.Config()).conf
|
||||
|
@ -59,7 +60,7 @@ class TestOVNNeutronAgent(base.TestOVNFunctionalBase):
|
|||
agt.test_ovn_sb_idl = []
|
||||
agt.test_ovn_nb_idl = []
|
||||
agt.start()
|
||||
self._check_loaded_extensions(agt)
|
||||
self._check_loaded_and_started_extensions(agt)
|
||||
|
||||
self.add_fake_chassis(self.FAKE_CHASSIS_HOST, name=self.chassis_name)
|
||||
|
||||
|
|
Loading…
Reference in New Issue