def __init__(self, root_helper=None, **kwargs): self.opflex_networks = kwargs['opflex_networks'] if self.opflex_networks and self.opflex_networks[0] == '*': self.opflex_networks = None self.root_helper = root_helper self.notify_worker = opflex_notify.worker() self.host = cfg.CONF.host agent_conf = cfg.CONF.AGENT ovs_conf = cfg.CONF.OVS try: bridge_mappings = q_utils.parse_mappings(ovs_conf.bridge_mappings) except ValueError as e: raise ValueError(_("Parsing bridge_mappings failed: %s.") % e) self.agent_state = { 'binary': 'neutron-opflex-agent', 'host': self.host, 'topic': n_constants.L2_AGENT_TOPIC, 'configurations': { 'bridge_mappings': bridge_mappings, 'opflex_networks': self.opflex_networks }, 'agent_type': ofcst.AGENT_TYPE_OPFLEX_OVS, 'start_flag': True } # Initialize OVS Manager self.bridge_manager = ovs_manager.OvsManager().initialize( self.host, ovs_conf) # Stores port update notifications for processing in main rpc loop self.updated_ports = set() # Stores port delete notifications self.deleted_ports = set() # Stores VRF update notifications self.updated_vrf = set() self.setup_rpc() self.local_ip = ovs_conf.local_ip self.polling_interval = agent_conf.polling_interval self.config_apply_interval = kwargs['config_apply_interval'] self.minimize_polling = agent_conf.minimize_polling self.ovsdb_monitor_respawn_interval = ( agent_conf.ovsdb_monitor_respawn_interval or constants.DEFAULT_OVSDBMON_RESPAWN) self.setup_report() self.supported_pt_network_types = [ofcst.TYPE_OPFLEX] # Initialize iteration counter self.iter_num = 0 self.run_daemon_loop = True # The initialization is complete; we can start receiving messages self.connection.consume_in_threads() self.quitting_rpc_timeout = agent_conf.quitting_rpc_timeout # Initialize the Endpoint Manager. # TODO(ivar): make these components pluggable. self.ep_manager = ep_manager.EndpointFileManager().initialize( self.host, self.bridge_manager, kwargs) self.port_manager = port_manager.AsyncPortManager().initialize( self.host, self, kwargs)
def _initialize_agent(self): kwargs = gbp_agent.create_agent_config_map(cfg.CONF) agent = async_port_manager.AsyncPortManager().initialize( 'h1', mock.Mock(), kwargs) agent.of_rpc = mock.Mock() return agent