예제 #1
0
    def _start_metadata_agent(self):
        conf = self.useFixture(fixture_config.Config()).conf
        conf.register_opts(meta.SHARED_OPTS)
        conf.register_opts(meta.UNIX_DOMAIN_METADATA_PROXY_OPTS)
        conf.register_opts(meta.METADATA_PROXY_HANDLER_OPTS)
        conf.register_opts(meta.OVS_OPTS, group='ovs')
        meta.setup_privsep()

        ovn_sb_db = self.ovsdb_server_mgr.get_ovsdb_connection_path('sb')
        conf.set_override('ovn_sb_connection', ovn_sb_db, group='ovn')

        # We don't need the HA proxy server running for now
        p = mock.patch.object(metadata_server, 'UnixDomainMetadataProxy')
        p.start()
        self.addCleanup(p.stop)

        # We only have OVN NB and OVN SB running for functional tests
        p = mock.patch.object(ovsdb, 'MetadataAgentOvsIdl')
        p.start()
        self.addCleanup(p.stop)

        self.chassis_name = self.add_fake_chassis('ovs-host-fake')
        with mock.patch.object(agent.MetadataAgent,
                               '_get_own_chassis_name') as mock_get_ch_name:
            mock_get_ch_name.return_value = self.chassis_name
            agt = agent.MetadataAgent(conf)
            agt.start()
            # Metadata agent will open connections to OVS and SB databases.
            # Close connections to them when the test ends,
            self.addCleanup(agt.ovs_idl.ovsdb_connection.stop)
            self.addCleanup(agt.sb_idl.ovsdb_connection.stop)
예제 #2
0
def main():
    meta.register_meta_conf_opts(meta.SHARED_OPTS)
    meta.register_meta_conf_opts(meta.UNIX_DOMAIN_METADATA_PROXY_OPTS)
    meta.register_meta_conf_opts(meta.METADATA_PROXY_HANDLER_OPTS)
    meta.register_meta_conf_opts(meta.OVS_OPTS, group='ovs')
    config.init(sys.argv[1:])
    config.setup_logging()
    meta.setup_privsep()
    utils.log_opt_values(LOG)

    agt = agent.MetadataAgent(cfg.CONF)
    agt.start()