def fully_mocked_target(init): """Get target instance without executing the init This object method is meant to grab the fully blessed instance of the target code without running any of the target.Target.__init__() method. This can be handy in that the returned target instance is completely free of the __init__'s tasks or overhead. SHOULD ONLY BE USED FOR COMPLETELY-ISOLATING WHITE-BOX TESTS! """ init.return_value = None cfg = Mock() return agent_manager.LbaasAgentManager(cfg)
def mocked_target(*args): """Build a Mock target that totally skips the __init__ method This is typically a building block that builds just an instantiated instance of target that has limited to no attibute quality that is otherwise generated by fully_mocked_target(). Thus, the return is a partially-completed dead-end Target object instance. """ with mock.patch( 'f5_openstack_agent.lbaasv2.drivers.bigip.agent_manager.' 'LbaasAgentManager.__init__') as my_init: my_init.return_value = None conf = mock.Mock() new_target = agent_manager.LbaasAgentManager(conf) new_target.conf = conf return new_target
def main(): """F5 LBaaS agent for OpenStack.""" cfg.CONF.register_opts(OPTS) cfg.CONF.register_opts(manager.OPTS) cfg.CONF.register_opts(interface.OPTS) config.register_agent_state_opts_helper(cfg.CONF) config.register_root_helper(cfg.CONF) common_config.init(sys.argv[1:]) # alias for common_config.setup_logging()... config.setup_logging() mgr = manager.LbaasAgentManager(cfg.CONF) svc = F5AgentService(host=mgr.agent_host, topic=f5constants.TOPIC_LOADBALANCER_AGENT_V2, manager=mgr) service.launch(cfg.CONF, svc).wait()
def main(): """F5 LBaaS agent for OpenStack.""" cfg.CONF.register_opts(OPTS) # 注册上面的OPT periodic_interval cfg.CONF.register_opts(manager.OPTS) # 注册agentmanager的OPTS cfg.CONF.register_opts(interface.OPTS) # 注册interface的OPTS config.register_agent_state_opts_helper(cfg.CONF) # 注册配置 config.register_root_helper(cfg.CONF) common_config.init(sys.argv[1:]) # alias for common_config.setup_logging()... config.setup_logging() mgr = manager.LbaasAgentManager(cfg.CONF) # RPC初始化在这里 svc = F5AgentService( # Message server。agent功能endpoints host=mgr.agent_host, topic=f5constants.TOPIC_LOADBALANCER_AGENT_V2, manager=mgr) service.launch(cfg.CONF, svc).wait()
def agent_mgr_setup(mock_importutils, mock_setup_rpc): return agent_manager.LbaasAgentManager(mock.MagicMock(name='conf'))