コード例 #1
0
    def start(self):
        # stores all configured ports on agent
        self.network_ports = collections.defaultdict(list)
        # flag to do a sync after revival
        self.fullsync = False
        self.context = context.get_admin_context_without_session()
        self.setup_rpc()
        self.init_extension_manager(self.connection)

        configurations = {'extensions': self.ext_manager.names()}
        configurations.update(self.mgr.get_agent_configurations())

        #TODO(mangelajo): optimize resource_versions (see ovs agent)
        self.agent_state = {
            'binary': self.agent_binary,
            'host': cfg.CONF.host,
            'topic': constants.L2_AGENT_TOPIC,
            'configurations': configurations,
            'agent_type': self.agent_type,
            'resource_versions': resources.LOCAL_RESOURCE_VERSIONS,
            'start_flag': True
        }

        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)

        capabilities.notify_init_event(self.agent_type, self)
        # The initialization is complete; we can start receiving messages
        self.connection.consume_in_threads()

        self.daemon_loop()
コード例 #2
0
    def start(self):
        self.prevent_arp_spoofing = cfg.CONF.AGENT.prevent_arp_spoofing

        # stores all configured ports on agent
        self.network_ports = collections.defaultdict(list)
        # flag to do a sync after revival
        self.fullsync = False
        self.context = context.get_admin_context_without_session()
        self.setup_rpc()
        self.init_extension_manager(self.connection)

        configurations = {'extensions': self.ext_manager.names()}
        configurations.update(self.mgr.get_agent_configurations())

        #TODO(mangelajo): optimize resource_versions (see ovs agent)
        self.agent_state = {
            'binary': self.agent_binary,
            'host': cfg.CONF.host,
            'topic': constants.L2_AGENT_TOPIC,
            'configurations': configurations,
            'agent_type': self.agent_type,
            'resource_versions': resources.LOCAL_RESOURCE_VERSIONS,
            'start_flag': True}

        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)

        capabilities.notify_init_event(self.agent_type, self)
        # The initialization is complete; we can start receiving messages
        self.connection.consume_in_threads()

        self.daemon_loop()
コード例 #3
0
 def test_notify_init_event(self, mocked_manager):
     mock_agent_type = mock.Mock()
     mock_agent = mock.Mock()
     capabilities.notify_init_event(mock_agent_type, mock_agent)
     mocked_manager.assert_called_with(mock_agent_type,
                                       events.AFTER_INIT,
                                       mock_agent,
                                       agent=mock_agent)
コード例 #4
0
 def test_notify_init_event(self):
     mock_agent_type = mock.Mock()
     mock_agent = mock.Mock()
     capabilities.notify_init_event(mock_agent_type, mock_agent)
     self._mgr.notify.assert_called_with(mock_agent_type,
                                         events.AFTER_INIT,
                                         mock_agent,
                                         agent=mock_agent)
コード例 #5
0
 def test_notify_init_event(self):
     mock_agent_type = mock.Mock()
     mock_agent = mock.Mock()
     capabilities.notify_init_event(mock_agent_type, mock_agent)
     self._mgr.publish.assert_called_with(mock_agent_type,
                                         events.AFTER_INIT,
                                         mock_agent,
                                         payload=None)