def _start_ovsdb_server_and_idls(self): self.temp_dir = self.useFixture(fixtures.TempDir()).path # Start 2 ovsdb-servers one each for OVN NB DB and OVN SB DB # ovsdb-server with OVN SB DB can be used to test the chassis up/down # events. self.ovsdb_server_mgr = self.useFixture( process.OvsdbServer(self.temp_dir, self.OVS_INSTALL_SHARE_PATH, ovn_nb_db=True, ovn_sb_db=True)) cfg.CONF.set_override( 'ovn_nb_connection', self.ovsdb_server_mgr.get_ovsdb_connection_path(), 'ovn') cfg.CONF.set_override( 'ovn_sb_connection', self.ovsdb_server_mgr.get_ovsdb_connection_path(db_type='sb'), 'ovn') num_attempts = 0 # 5 seconds should be more than enough for the transaction to complete # for the test cases. # This also fixes the bug #1607639. cfg.CONF.set_override( 'ovsdb_connection_timeout', 5, 'ovn') # Created monitor IDL connection to the OVN NB DB. # This monitor IDL connection can be used to # - Verify that the ML2 OVN driver has written to the OVN NB DB # as expected. # - Create and delete resources in OVN NB DB outside of the # ML2 OVN driver scope to test scenarios like ovn_nb_sync. while num_attempts < 3: try: self.monitor_idl_con = connection.Connection( self.ovsdb_server_mgr.get_ovsdb_connection_path(), 60, 'OVN_Northbound') self.monitor_idl_con.start() self.monitor_nb_db_idl = self.monitor_idl_con.idl break except Exception: LOG.exception(_LE("Error connecting to the OVN_Northbound DB")) num_attempts += 1 time.sleep(1) trigger = mock.MagicMock() if self.ovn_worker: trigger.im_class = ovsdb_monitor.OvnWorker cfg.CONF.set_override('neutron_sync_mode', 'off', 'ovn') # mech_driver.post_fork_initialize creates the IDL connections self.mech_driver.post_fork_initialize(mock.ANY, mock.ANY, trigger)
def _start_ovsdb_server_and_idls(self): # Start 2 ovsdb-servers one each for OVN NB DB and OVN SB DB # ovsdb-server with OVN SB DB can be used to test the chassis up/down # events. install_share_path = self._get_install_share_path() self.ovsdb_server_mgr = self.useFixture( process.OvsdbServer(self.temp_dir, install_share_path, ovn_nb_db=True, ovn_sb_db=True, protocol=self._ovsdb_protocol)) set_cfg = cfg.CONF.set_override set_cfg('ovn_nb_connection', self.ovsdb_server_mgr.get_ovsdb_connection_path(), 'ovn') set_cfg('ovn_sb_connection', self.ovsdb_server_mgr.get_ovsdb_connection_path(db_type='sb'), 'ovn') set_cfg('ovn_nb_private_key', self.ovsdb_server_mgr.private_key, 'ovn') set_cfg('ovn_nb_certificate', self.ovsdb_server_mgr.certificate, 'ovn') set_cfg('ovn_nb_ca_cert', self.ovsdb_server_mgr.ca_cert, 'ovn') set_cfg('ovn_sb_private_key', self.ovsdb_server_mgr.private_key, 'ovn') set_cfg('ovn_sb_certificate', self.ovsdb_server_mgr.certificate, 'ovn') set_cfg('ovn_sb_ca_cert', self.ovsdb_server_mgr.ca_cert, 'ovn') # 5 seconds should be more than enough for the transaction to complete # for the test cases. # This also fixes the bug #1607639. cfg.CONF.set_override('ovsdb_connection_timeout', 5, 'ovn') class TriggerCls(mock.MagicMock): def trigger(self): pass trigger_cls = TriggerCls() if self.maintenance_worker: trigger_cls.trigger.__self__.__class__ = worker.MaintenanceWorker cfg.CONF.set_override('neutron_sync_mode', 'off', 'ovn') self.addCleanup(self._collect_processes_logs) self.addCleanup(self.stop) # mech_driver.post_fork_initialize creates the IDL connections self.mech_driver.post_fork_initialize(mock.ANY, mock.ANY, trigger_cls.trigger) self.nb_api = self.mech_driver._nb_ovn self.sb_api = self.mech_driver._sb_ovn
def _start_ovsdb_server_and_idls(self): self.temp_dir = self.useFixture(fixtures.TempDir()).path # Start 2 ovsdb-servers one each for OVN NB DB and OVN SB DB # ovsdb-server with OVN SB DB can be used to test the chassis up/down # events. mgr = self.ovsdb_server_mgr = self.useFixture( process.OvsdbServer(self.temp_dir, self.OVS_INSTALL_SHARE_PATH, ovn_nb_db=True, ovn_sb_db=True, protocol=self._ovsdb_protocol)) set_cfg = cfg.CONF.set_override set_cfg('ovn_nb_connection', self.ovsdb_server_mgr.get_ovsdb_connection_path(), 'ovn') set_cfg('ovn_sb_connection', self.ovsdb_server_mgr.get_ovsdb_connection_path(db_type='sb'), 'ovn') set_cfg('ovn_nb_private_key', self.ovsdb_server_mgr.private_key, 'ovn') set_cfg('ovn_nb_certificate', self.ovsdb_server_mgr.certificate, 'ovn') set_cfg('ovn_nb_ca_cert', self.ovsdb_server_mgr.ca_cert, 'ovn') set_cfg('ovn_sb_private_key', self.ovsdb_server_mgr.private_key, 'ovn') set_cfg('ovn_sb_certificate', self.ovsdb_server_mgr.certificate, 'ovn') set_cfg('ovn_sb_ca_cert', self.ovsdb_server_mgr.ca_cert, 'ovn') num_attempts = 0 # 5 seconds should be more than enough for the transaction to complete # for the test cases. # This also fixes the bug #1607639. cfg.CONF.set_override('ovsdb_connection_timeout', 5, 'ovn') # Created monitor IDL connection to the OVN NB DB. # This monitor IDL connection can be used to # - Verify that the ML2 OVN driver has written to the OVN NB DB # as expected. # - Create and delete resources in OVN NB DB outside of the # ML2 OVN driver scope to test scenarios like ovn_nb_sync. while num_attempts < 3: try: con = self.useFixture( ConnectionFixture(constr=mgr.get_ovsdb_connection_path(), schema='OVN_Northbound')).connection self.nb_api = impl_idl_ovn.OvsdbNbOvnIdl(con) break except Exception: LOG.exception("Error connecting to the OVN_Northbound DB") num_attempts += 1 time.sleep(1) num_attempts = 0 # Create monitor IDL connection to the OVN SB DB. # This monitor IDL connection can be used to # - Create chassis rows # - Update chassis columns etc. while num_attempts < 3: try: con = self.useFixture( ConnectionFixture( constr=mgr.get_ovsdb_connection_path('sb'), schema='OVN_Southbound')).connection self.sb_api = impl_idl_ovn.OvsdbSbOvnIdl(con) break except Exception: LOG.exception("Error connecting to the OVN_Southbound DB") num_attempts += 1 time.sleep(1) trigger = mock.MagicMock() if self.ovn_worker: trigger.im_class = ovsdb_monitor.OvnWorker cfg.CONF.set_override('neutron_sync_mode', 'off', 'ovn') trigger.im_class.__name__ = 'trigger' self.addCleanup(self.stop) # mech_driver.post_fork_initialize creates the IDL connections self.mech_driver.post_fork_initialize(mock.ANY, mock.ANY, trigger)