def _initialize_agent(self): cfg.CONF.set_override('epg_mapping_dir', self.ep_dir, 'OPFLEX') cfg.CONF.set_override( 'bridge_manager', 'opflexagent.utils.bridge_managers.vpp_manager.VppManager', 'OPFLEX') cfg.CONF.set_override("vhostuser_socket_dir", VHU_DIR, group="VPP") kwargs = gbp_agent.create_agent_config_map(cfg.CONF) class MockFixedIntervalLoopingCall(object): def __init__(self, f): self.f = f def start(self, interval=0): self.f() resources = [ mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall', new=MockFixedIntervalLoopingCall), mock.patch('opflexagent.gbp_agent.GBPOpflexAgent.' '_report_state') ] with utils.nested_context_manager(*resources): agent = gbp_agent.GBPOpflexAgent(**kwargs) # set back to true because initial report state will succeed due # to mocked out RPC calls agent.use_call = True agent.tun_br = mock.Mock() agent.host = 'host1' agent.sg_agent = mock.Mock() return agent
def _initialize_agent(self): cfg.CONF.set_override('epg_mapping_dir', self.ep_dir, 'OPFLEX') kwargs = gbp_agent.create_agent_config_map(cfg.CONF) class MockFixedIntervalLoopingCall(object): def __init__(self, f): self.f = f def start(self, interval=0): self.f() with mock.patch( 'opflexagent.utils.bridge_managers.ovs_manager.' 'OvsManager.setup_integration_bridge', return_value=mock.Mock()): with mock.patch('neutron.agent.common.ovs_lib.OVSBridge.' 'create'): with mock.patch('neutron.agent.common.ovs_lib.OVSBridge.' 'set_secure_mode'): with mock.patch( 'neutron.agent.common.ovs_lib.OVSBridge.' 'get_local_port_mac', return_value='00:00:00:00:00:01'): with mock.patch('neutron.agent.common.ovs_lib' '.BaseOVS.get_bridges'): with mock.patch( 'oslo_service.loopingcall' '.FixedIntervalLoopingCall', new=MockFixedIntervalLoopingCall): with mock.patch('opflexagent.gbp_agent' '.GBPOpflexAgent.' '_report_state'): agent = gbp_agent.GBPOpflexAgent(**kwargs) # set back to true because initial report # state will succeed due # to mocked out RPC calls agent.use_call = True agent.tun_br = mock.Mock() agent.host = 'host1' agent.sg_agent = mock.Mock() return agent