def _init_vif(self, plugin): if plugin == 1: try: import neutron.agent.linux.interface as interface from neutron.agent.linux.interface import OVSInterfaceDriver conf = config.setup_conf() conf.register_opts(interface.OPTS) config.register_root_helper(conf) return OVSInterfaceDriver(conf) except: pass else: ROOT_HELPER_OPTS = [ cfg.StrOpt('root_helper', default='sudo', help=_('Root helper application.')), cfg.BoolOpt('ovs_use_veth', default=True, help = _("ovs_use_veth")), cfg.StrOpt('ovs_integration_bridge', default='br-int', help=_('Name of Open vSwitch bridge to use')) ] try: from neutron_plugin_contrail.plugins.opencontrail.agent.contrail_vif_driver import ContrailInterfaceDriver contrail_conf = cfg.ConfigOpts() contrail_conf.register_opts(ROOT_HELPER_OPTS) contrail_conf.register_opts(ROOT_HELPER_OPTS, 'AGENT') return ContrailInterfaceDriver(contrail_conf) except: pass return None
def setUp(self): super(TestDhcpNoOpDriver, self).setUp() self.conf = config.setup_conf() config.register_interface_driver_opts_helper(self.conf) self.conf.register_opts(base_config.core_opts) self.conf.register_opts(dhcp.OPTS) self.conf.enable_isolated_metadata = True self.conf.use_namespaces = True instance = mock.patch("neutron.agent.linux.dhcp.DeviceManager") self.mock_mgr = instance.start()
def setUp(self): super(TestBase, self).setUp() self.conf = config.setup_conf() self.conf.register_opts(interface.OPTS) self.ip_dev_p = mock.patch.object(ip_lib, 'IPDevice') self.ip_dev = self.ip_dev_p.start() self.ip_p = mock.patch.object(ip_lib, 'IPWrapper') self.ip = self.ip_p.start() self.device_exists_p = mock.patch.object(ip_lib, 'device_exists') self.device_exists = self.device_exists_p.start()
def setUp(self): super(TestBase, self).setUp() self.conf = config.setup_conf() self.conf.register_opts(interface.OPTS) config.register_root_helper(self.conf) self.ip_dev_p = mock.patch.object(ip_lib, 'IPDevice') self.ip_dev = self.ip_dev_p.start() self.ip_p = mock.patch.object(ip_lib, 'IPWrapper') self.ip = self.ip_p.start() self.device_exists_p = mock.patch.object(ip_lib, 'device_exists') self.device_exists = self.device_exists_p.start()
def setUp(self): self.conf = config.setup_conf() self.conf.register_opts(interface.OPTS) self.driver = interface.MidonetInterfaceDriver(self.conf) self.network_id = uuidutils.generate_uuid() self.port_id = uuidutils.generate_uuid() self.device_name = "tap0" self.mac_address = "aa:bb:cc:dd:ee:ff" self.bridge = "br-test" self.namespace = "ns-test" super(TestMidonetInterfaceDriver, self).setUp()
def setUp(self): super(TestRouterInfo, self).setUp() conf = agent_config.setup_conf() conf.use_namespaces = True self.ip_cls_p = mock.patch("neutron.agent.linux.ip_lib.IPWrapper") ip_cls = self.ip_cls_p.start() self.mock_ip = mock.MagicMock() ip_cls.return_value = self.mock_ip self.ri_kwargs = {"agent_conf": conf, "interface_driver": mock.sentinel.interface_driver}
def setUp(self): super(TestRouterInfo, self).setUp() conf = agent_config.setup_conf() self.ip_cls_p = mock.patch('neutron.agent.linux.ip_lib.IPWrapper') ip_cls = self.ip_cls_p.start() self.mock_ip = mock.MagicMock() ip_cls.return_value = self.mock_ip self.ri_kwargs = {'agent_conf': conf, 'interface_driver': mock.sentinel.interface_driver}
def setUp(self): super(TestDhcpNoOpDriver, self).setUp() self.conf = config.setup_conf() config.register_interface_driver_opts_helper(self.conf) self.conf.register_opts(base_config.core_opts) self.conf.register_opts(dhcp.OPTS) self.conf.enable_isolated_metadata = True self.conf.use_namespaces = True instance = mock.patch("neutron.agent.linux.dhcp.DeviceManager") self.mock_mgr = instance.start() self.addCleanup(instance.stop)
def setUp(self): super(TestBasicRouterOperations, self).setUp() self.conf = agent_config.setup_conf() self.conf.register_opts(base_config.core_opts) self.conf.register_opts(l3_config.OPTS) self.conf.register_opts(ha.OPTS) agent_config.register_process_monitor_opts(self.conf) agent_config.register_interface_driver_opts_helper(self.conf) agent_config.register_use_namespaces_opts_helper(self.conf) self.conf.register_opts(interface.OPTS) self.conf.set_override('interface_driver', 'neutron.agent.linux.interface.NullDriver') self.conf.state_path = '' self.device_exists_p = mock.patch( 'neutron.agent.linux.ip_lib.device_exists') self.device_exists = self.device_exists_p.start() self.utils_exec_p = mock.patch('neutron.agent.linux.utils.execute') self.utils_exec = self.utils_exec_p.start() self.external_process_p = mock.patch( 'neutron.agent.linux.external_process.ProcessManager') self.external_process = self.external_process_p.start() self.makedirs_p = mock.patch('os.makedirs') self.makedirs = self.makedirs_p.start() self.dvr_cls_p = mock.patch('neutron.agent.linux.interface.NullDriver') driver_cls = self.dvr_cls_p.start() self.mock_driver = mock.MagicMock() self.mock_driver.DEV_NAME_LEN = ( interface.LinuxInterfaceDriver.DEV_NAME_LEN) driver_cls.return_value = self.mock_driver self.ip_cls_p = mock.patch('neutron.agent.linux.ip_lib.IPWrapper') ip_cls = self.ip_cls_p.start() self.mock_ip = mock.MagicMock() ip_cls.return_value = self.mock_ip mock.patch('neutron.agent.l3.agent.L3PluginApi').start() self.looping_call_p = mock.patch( 'oslo_service.loopingcall.FixedIntervalLoopingCall') self.looping_call_p.start() self.fake_agent_mode = None self.ri_kwargs = { 'agent_conf': self.conf, 'interface_driver': self.mock_driver }
def setUp(self): self.conf = config.setup_conf() self.conf.register_opts(interface.OPTS) config.register_root_helper(self.conf) self.device_exists_p = mock.patch.object(ip_lib, 'device_exists') self.device_exists = self.device_exists_p.start() self.driver = interface.MidonetInterfaceDriver(self.conf) self.network_id = uuidutils.generate_uuid() self.port_id = uuidutils.generate_uuid() self.device_name = "tap0" self.mac_address = "aa:bb:cc:dd:ee:ff" self.bridge = "br-test" self.namespace = "ns-test" super(TestMidonetInterfaceDriver, self).setUp()
def setUp(self): super(TestBase, self).setUp() self.conf = config.setup_conf() self.conf.register_opts(interface.OPTS) config.register_root_helper(self.conf) self.ip_dev_p = mock.patch.object(ip_lib, "IPDevice") self.ip_dev = self.ip_dev_p.start() self.addCleanup(self.ip_dev_p.stop) self.ip_p = mock.patch.object(ip_lib, "IPWrapper") self.ip = self.ip_p.start() self.addCleanup(self.ip_p.stop) self.device_exists_p = mock.patch.object(ip_lib, "device_exists") self.device_exists = self.device_exists_p.start() self.addCleanup(self.device_exists_p.stop)
def setUp(self): super(TestBasicRouterOperations, self).setUp() self.conf = agent_config.setup_conf() self.conf.register_opts(base_config.core_opts) self.conf.register_opts(l3_config.OPTS) self.conf.register_opts(ha.OPTS) agent_config.register_process_monitor_opts(self.conf) agent_config.register_interface_driver_opts_helper(self.conf) agent_config.register_use_namespaces_opts_helper(self.conf) self.conf.register_opts(interface.OPTS) self.conf.set_override('interface_driver', 'neutron.agent.linux.interface.NullDriver') self.conf.state_path = '' self.device_exists_p = mock.patch( 'neutron.agent.linux.ip_lib.device_exists') self.device_exists = self.device_exists_p.start() self.utils_exec_p = mock.patch( 'neutron.agent.linux.utils.execute') self.utils_exec = self.utils_exec_p.start() self.external_process_p = mock.patch( 'neutron.agent.linux.external_process.ProcessManager') self.external_process = self.external_process_p.start() self.makedirs_p = mock.patch('os.makedirs') self.makedirs = self.makedirs_p.start() self.dvr_cls_p = mock.patch('neutron.agent.linux.interface.NullDriver') driver_cls = self.dvr_cls_p.start() self.mock_driver = mock.MagicMock() self.mock_driver.DEV_NAME_LEN = ( interface.LinuxInterfaceDriver.DEV_NAME_LEN) driver_cls.return_value = self.mock_driver self.ip_cls_p = mock.patch('neutron.agent.linux.ip_lib.IPWrapper') ip_cls = self.ip_cls_p.start() self.mock_ip = mock.MagicMock() ip_cls.return_value = self.mock_ip mock.patch('neutron.agent.l3.agent.L3PluginApi').start() self.looping_call_p = mock.patch( 'oslo_service.loopingcall.FixedIntervalLoopingCall') self.looping_call_p.start() self.fake_agent_mode = None self.ri_kwargs = {'agent_conf': self.conf, 'interface_driver': self.mock_driver}
def setUp(self): super(TestBasicRouterOperations, self).setUp() self.conf = agent_config.setup_conf() self.conf.register_opts(base_config.core_opts) self.conf.register_opts(varmour_router.vArmourL3NATAgent.OPTS) self.conf.register_opts(l3_ha_agent.OPTS) agent_config.register_interface_driver_opts_helper(self.conf) agent_config.register_use_namespaces_opts_helper(self.conf) agent_config.register_root_helper(self.conf) self.conf.register_opts(external_process.OPTS) self.conf.register_opts(interface.OPTS) self.conf.set_override('interface_driver', 'neutron.agent.linux.interface.NullDriver') self.conf.root_helper = 'sudo' self.conf.state_path = '' self.device_exists_p = mock.patch( 'neutron.agent.linux.ip_lib.device_exists') self.device_exists = self.device_exists_p.start() self.utils_exec_p = mock.patch( 'neutron.agent.linux.utils.execute') self.utils_exec = self.utils_exec_p.start() self.external_process_p = mock.patch( 'neutron.agent.linux.external_process.ProcessManager') self.external_process = self.external_process_p.start() self.makedirs_p = mock.patch('os.makedirs') self.makedirs = self.makedirs_p.start() self.dvr_cls_p = mock.patch('neutron.agent.linux.interface.NullDriver') driver_cls = self.dvr_cls_p.start() self.mock_driver = mock.MagicMock() self.mock_driver.DEV_NAME_LEN = ( interface.LinuxInterfaceDriver.DEV_NAME_LEN) driver_cls.return_value = self.mock_driver self.ip_cls_p = mock.patch('neutron.agent.linux.ip_lib.IPWrapper') ip_cls = self.ip_cls_p.start() self.mock_ip = mock.MagicMock() ip_cls.return_value = self.mock_ip mock.patch('neutron.agent.l3_agent.L3PluginApi').start() self.looping_call_p = mock.patch( 'neutron.openstack.common.loopingcall.FixedIntervalLoopingCall') self.looping_call_p.start()
def setUp(self): super(TestBasicRouterOperations, self).setUp() self.conf = agent_config.setup_conf() self.conf.register_opts(base_config.core_opts) self.conf.register_opts(varmour_router.vArmourL3NATAgent.OPTS) self.conf.register_opts(l3_ha_agent.OPTS) agent_config.register_interface_driver_opts_helper(self.conf) agent_config.register_use_namespaces_opts_helper(self.conf) agent_config.register_root_helper(self.conf) self.conf.register_opts(interface.OPTS) self.conf.set_override('interface_driver', 'neutron.agent.linux.interface.NullDriver') self.conf.root_helper = 'sudo' self.conf.state_path = '' self.device_exists_p = mock.patch( 'neutron.agent.linux.ip_lib.device_exists') self.device_exists = self.device_exists_p.start() self.utils_exec_p = mock.patch( 'neutron.agent.linux.utils.execute') self.utils_exec = self.utils_exec_p.start() self.external_process_p = mock.patch( 'neutron.agent.linux.external_process.ProcessManager') self.external_process = self.external_process_p.start() self.makedirs_p = mock.patch('os.makedirs') self.makedirs = self.makedirs_p.start() self.dvr_cls_p = mock.patch('neutron.agent.linux.interface.NullDriver') driver_cls = self.dvr_cls_p.start() self.mock_driver = mock.MagicMock() self.mock_driver.DEV_NAME_LEN = ( interface.LinuxInterfaceDriver.DEV_NAME_LEN) driver_cls.return_value = self.mock_driver self.ip_cls_p = mock.patch('neutron.agent.linux.ip_lib.IPWrapper') ip_cls = self.ip_cls_p.start() self.mock_ip = mock.MagicMock() ip_cls.return_value = self.mock_ip mock.patch('neutron.agent.l3_agent.L3PluginApi').start() self.looping_call_p = mock.patch( 'neutron.openstack.common.loopingcall.FixedIntervalLoopingCall') self.looping_call_p.start()
def setUp(self): super(TestBase, self).setUp() self.conf = config.setup_conf() self.conf.register_opts(base_config.core_opts) self.conf.register_opts(dhcp.OPTS) config.register_interface_driver_opts_helper(self.conf) instance = mock.patch("neutron.agent.linux.dhcp.DeviceManager") self.mock_mgr = instance.start() self.conf.register_opt( cfg.BoolOpt('enable_isolated_metadata', default=True)) self.config_parse(self.conf) self.conf.set_override('state_path', '') self.conf.use_namespaces = True self.replace_p = mock.patch('neutron.agent.linux.utils.replace_file') self.execute_p = mock.patch('neutron.agent.linux.utils.execute') self.safe = self.replace_p.start() self.execute = self.execute_p.start()
def setUp(self): super(TestBase, self).setUp() self.conf = config.setup_conf() self.conf.register_opts(base_config.core_opts) self.conf.register_opts(dhcp.OPTS) config.register_interface_driver_opts_helper(self.conf) instance = mock.patch("neutron.agent.linux.dhcp.DeviceManager") self.mock_mgr = instance.start() self.conf.register_opt(cfg.BoolOpt('enable_isolated_metadata', default=True)) self.config_parse(self.conf) self.conf.set_override('state_path', '') self.conf.use_namespaces = True self.replace_p = mock.patch('neutron.agent.linux.utils.replace_file') self.execute_p = mock.patch('neutron.agent.linux.utils.execute') self.safe = self.replace_p.start() self.execute = self.execute_p.start()
def setUp(self): super(TestBase, self).setUp() root = os.path.dirname(os.path.dirname(__file__)) args = ["--config-file", os.path.join(root, "etc", "neutron.conf.test")] self.conf = config.setup_conf() self.conf.register_opts(base_config.core_opts) self.conf.register_opts(dhcp.OPTS) config.register_interface_driver_opts_helper(self.conf) instance = mock.patch("neutron.agent.linux.dhcp.DeviceManager") self.mock_mgr = instance.start() self.conf.register_opt(cfg.BoolOpt("enable_isolated_metadata", default=True)) self.conf(args=args) self.conf.set_override("state_path", "") self.conf.use_namespaces = True self.replace_p = mock.patch("neutron.agent.linux.utils.replace_file") self.execute_p = mock.patch("neutron.agent.linux.utils.execute") self.safe = self.replace_p.start() self.execute = self.execute_p.start()
def setUp(self): super(TestBase, self).setUp() root = os.path.dirname(os.path.dirname(__file__)) args = ['--config-file', os.path.join(root, 'etc', 'neutron.conf.test')] self.conf = config.setup_conf() self.conf.register_opts(base_config.core_opts) self.conf.register_opts(dhcp.OPTS) self.conf.register_opt(cfg.BoolOpt('enable_isolated_metadata', default=True)) self.conf(args=args) self.conf.set_override('state_path', '') self.conf.use_namespaces = True self.replace_p = mock.patch('neutron.agent.linux.utils.replace_file') self.execute_p = mock.patch('neutron.agent.linux.utils.execute') self.addCleanup(self.replace_p.stop) self.addCleanup(self.execute_p.stop) self.safe = self.replace_p.start() self.execute = self.execute_p.start()
def setUp(self): self.conf = config.setup_conf() self.conf.register_opts(interface.OPTS) config.register_root_helper(self.conf) self.ip_dev_p = mock.patch.object(ip_lib, 'IPDevice') self.ip_dev = self.ip_dev_p.start() self.ip_p = mock.patch.object(ip_lib, 'IPWrapper') self.ip = self.ip_p.start() self.device_exists_p = mock.patch.object(ip_lib, 'device_exists') self.device_exists = self.device_exists_p.start() self.device_exists.return_value = False self.addCleanup(mock.patch.stopall) midonet_opts = [ cfg.StrOpt('midonet_uri', default='http://localhost:8080/midonet-api', help=_('MidoNet API server URI.')), cfg.StrOpt('username', default='admin', help=_('MidoNet admin username.')), cfg.StrOpt('password', default='passw0rd', secret=True, help=_('MidoNet admin password.')), cfg.StrOpt('project_id', default='77777777-7777-7777-7777-777777777777', help=_('ID of the project that MidoNet admin user' 'belongs to.')) ] self.conf.register_opts(midonet_opts, "MIDONET") self.driver = driver.MidonetInterfaceDriver(self.conf) self.root_dev = mock.Mock() self.ns_dev = mock.Mock() self.ip().add_veth = mock.Mock(return_value=( self.root_dev, self.ns_dev)) self.driver._get_host_uuid = mock.Mock( return_value=uuidutils.generate_uuid()) self.network_id = uuidutils.generate_uuid() self.port_id = uuidutils.generate_uuid() self.device_name = "tap0" self.mac_address = "aa:bb:cc:dd:ee:ff" self.bridge = "br-test" self.namespace = "ns-test" super(MidoInterfaceDriverTestCase, self).setUp()
def setUp(self): super(TestBase, self).setUp() root = os.path.dirname(os.path.dirname(__file__)) args = [ '--config-file', os.path.join(root, 'etc', 'neutron.conf.test') ] self.conf = config.setup_conf() self.conf.register_opts(base_config.core_opts) self.conf.register_opts(dhcp.OPTS) self.conf.register_opt( cfg.BoolOpt('enable_isolated_metadata', default=True)) self.conf(args=args) self.conf.set_override('state_path', '') self.conf.use_namespaces = True self.replace_p = mock.patch('neutron.agent.linux.utils.replace_file') self.execute_p = mock.patch('neutron.agent.linux.utils.execute') self.addCleanup(self.replace_p.stop) self.addCleanup(self.execute_p.stop) self.safe = self.replace_p.start() self.execute = self.execute_p.start()
def test_agent_root_helper(self): conf = config.setup_conf() config.register_root_helper(conf) conf.set_override("root_helper", "my_root_helper", "AGENT") self.assertEqual(config.get_root_helper(conf), "my_root_helper")
def setUp(self): super(TestLoadInterfaceDriver, self).setUp() self.conf = config.setup_conf() self.conf.register_opts(interface.OPTS) config.register_interface_driver_opts_helper(self.conf)
def test_root_helper(self): conf = config.setup_conf() config.register_root_helper(conf) conf.set_override('root_helper', 'my_root_helper') self.assertEqual(config.get_root_helper(conf), 'my_root_helper')
def test_root_default(self): conf = config.setup_conf() config.register_root_helper(conf) self.assertEqual(config.get_root_helper(conf), 'sudo')
def test_agent_root_helper_daemon(self): conf = config.setup_conf() config.register_root_helper(conf) rhd = 'my_root_helper_daemon' conf.set_override('root_helper_daemon', rhd, 'AGENT') self.assertEqual(rhd, conf.AGENT.root_helper_daemon)
def test_setup_conf(): conf = config.setup_conf() assert conf.state_path.endswith('/var/lib/neutron')
def setUp(self): super(TestDvrRouterOperations, self).setUp() mock.patch('eventlet.spawn').start() self.conf = agent_config.setup_conf() self.conf.register_opts(base_config.core_opts) log.register_options(self.conf) self.conf.register_opts(agent_config.AGENT_STATE_OPTS, 'AGENT') self.conf.register_opts(l3_config.OPTS) self.conf.register_opts(ha.OPTS) agent_config.register_interface_driver_opts_helper(self.conf) agent_config.register_use_namespaces_opts_helper(self.conf) agent_config.register_process_monitor_opts(self.conf) self.conf.register_opts(interface.OPTS) self.conf.register_opts(external_process.OPTS) self.conf.set_override('router_id', 'fake_id') self.conf.set_override('interface_driver', 'neutron.agent.linux.interface.NullDriver') self.conf.set_override('send_arp_for_ha', 1) self.conf.set_override('state_path', '') self.device_exists_p = mock.patch( 'neutron.agent.linux.ip_lib.device_exists') self.device_exists = self.device_exists_p.start() self.ensure_dir = mock.patch('neutron.agent.linux.utils' '.ensure_dir').start() mock.patch('neutron.agent.linux.keepalived.KeepalivedManager' '.get_full_config_file_path').start() self.utils_exec_p = mock.patch('neutron.agent.linux.utils.execute') self.utils_exec = self.utils_exec_p.start() self.utils_replace_file_p = mock.patch( 'neutron.agent.linux.utils.replace_file') self.utils_replace_file = self.utils_replace_file_p.start() self.external_process_p = mock.patch( 'neutron.agent.linux.external_process.ProcessManager') self.external_process = self.external_process_p.start() self.process_monitor = mock.patch( 'neutron.agent.linux.external_process.ProcessMonitor').start() self.send_adv_notif_p = mock.patch( 'neutron.agent.linux.ip_lib.send_ip_addr_adv_notif') self.send_adv_notif = self.send_adv_notif_p.start() self.dvr_cls_p = mock.patch('neutron.agent.linux.interface.NullDriver') driver_cls = self.dvr_cls_p.start() self.mock_driver = mock.MagicMock() self.mock_driver.DEV_NAME_LEN = ( interface.LinuxInterfaceDriver.DEV_NAME_LEN) driver_cls.return_value = self.mock_driver self.ip_cls_p = mock.patch('neutron.agent.linux.ip_lib.IPWrapper') ip_cls = self.ip_cls_p.start() self.mock_ip = mock.MagicMock() ip_cls.return_value = self.mock_ip ip_rule = mock.patch('neutron.agent.linux.ip_lib.IPRule').start() self.mock_rule = mock.MagicMock() ip_rule.return_value = self.mock_rule ip_dev = mock.patch('neutron.agent.linux.ip_lib.IPDevice').start() self.mock_ip_dev = mock.MagicMock() ip_dev.return_value = self.mock_ip_dev self.l3pluginApi_cls_p = mock.patch( 'neutron.agent.l3.agent.L3PluginApi') l3pluginApi_cls = self.l3pluginApi_cls_p.start() self.plugin_api = mock.MagicMock() l3pluginApi_cls.return_value = self.plugin_api self.looping_call_p = mock.patch( 'oslo_service.loopingcall.FixedIntervalLoopingCall') self.looping_call_p.start() subnet_id_1 = _uuid() subnet_id_2 = _uuid() self.snat_ports = [{ 'subnets': [{ 'cidr': '152.2.0.0/16', 'gateway_ip': '152.2.0.1', 'id': subnet_id_1 }], 'network_id': _uuid(), 'device_owner': 'network:router_centralized_snat', 'mac_address': 'fa:16:3e:80:8d:80', 'fixed_ips': [{ 'subnet_id': subnet_id_1, 'ip_address': '152.2.0.13', 'prefixlen': 16 }], 'id': _uuid(), 'device_id': _uuid() }, { 'subnets': [{ 'cidr': '152.10.0.0/16', 'gateway_ip': '152.10.0.1', 'id': subnet_id_2 }], 'network_id': _uuid(), 'device_owner': 'network:router_centralized_snat', 'mac_address': 'fa:16:3e:80:8d:80', 'fixed_ips': [{ 'subnet_id': subnet_id_2, 'ip_address': '152.10.0.13', 'prefixlen': 16 }], 'id': _uuid(), 'device_id': _uuid() }] self.ri_kwargs = { 'agent_conf': self.conf, 'interface_driver': self.mock_driver }
def test_agent_root_helper(self): conf = config.setup_conf() config.register_root_helper(conf) conf.set_override('root_helper', 'my_root_helper', 'AGENT') self.assertEqual(config.get_root_helper(conf), 'my_root_helper')
def test_agent_root_helper_daemon(self): conf = config.setup_conf() config.register_root_helper(conf) rhd = "my_root_helper_daemon" conf.set_override("root_helper_daemon", rhd, "AGENT") self.assertEqual(rhd, conf.AGENT.root_helper_daemon)
def setUp(self): super(TestDvrRouterOperations, self).setUp() mock.patch('eventlet.spawn').start() self.conf = agent_config.setup_conf() self.conf.register_opts(base_config.core_opts) log.register_options(self.conf) self.conf.register_opts(agent_config.AGENT_STATE_OPTS, 'AGENT') l3_config.register_l3_agent_config_opts(l3_config.OPTS, self.conf) ha_conf.register_l3_agent_ha_opts(self.conf) agent_config.register_interface_driver_opts_helper(self.conf) agent_config.register_process_monitor_opts(self.conf) self.conf.register_opts(interface.OPTS) self.conf.register_opts(external_process.OPTS) self.conf.set_override('interface_driver', 'neutron.agent.linux.interface.NullDriver') self.conf.set_override('send_arp_for_ha', 1) self.conf.set_override('state_path', cfg.CONF.state_path) self.device_exists_p = mock.patch( 'neutron.agent.linux.ip_lib.device_exists') self.device_exists = self.device_exists_p.start() self.ensure_dir = mock.patch( 'oslo_utils.fileutils.ensure_tree').start() mock.patch('neutron.agent.linux.keepalived.KeepalivedManager' '.get_full_config_file_path').start() self.utils_exec_p = mock.patch( 'neutron.agent.linux.utils.execute') self.utils_exec = self.utils_exec_p.start() self.utils_replace_file_p = mock.patch( 'neutron_lib.utils.file.replace_file') self.utils_replace_file = self.utils_replace_file_p.start() self.external_process_p = mock.patch( 'neutron.agent.linux.external_process.ProcessManager') self.external_process = self.external_process_p.start() self.process_monitor = mock.patch( 'neutron.agent.linux.external_process.ProcessMonitor').start() self.send_adv_notif_p = mock.patch( 'neutron.agent.linux.ip_lib.send_ip_addr_adv_notif') self.send_adv_notif = self.send_adv_notif_p.start() self.dvr_cls_p = mock.patch('neutron.agent.linux.interface.NullDriver') driver_cls = self.dvr_cls_p.start() self.mock_driver = mock.MagicMock() self.mock_driver.DEV_NAME_LEN = ( interface.LinuxInterfaceDriver.DEV_NAME_LEN) driver_cls.return_value = self.mock_driver self.ip_cls_p = mock.patch('neutron.agent.linux.ip_lib.IPWrapper') ip_cls = self.ip_cls_p.start() self.mock_ip = mock.MagicMock() ip_cls.return_value = self.mock_ip ip_rule = mock.patch('neutron.agent.linux.ip_lib.IPRule').start() self.mock_rule = mock.MagicMock() ip_rule.return_value = self.mock_rule ip_dev = mock.patch('neutron.agent.linux.ip_lib.IPDevice').start() self.mock_ip_dev = mock.MagicMock() ip_dev.return_value = self.mock_ip_dev self.l3pluginApi_cls_p = mock.patch( 'neutron.agent.l3.agent.L3PluginApi') l3pluginApi_cls = self.l3pluginApi_cls_p.start() self.plugin_api = mock.MagicMock() l3pluginApi_cls.return_value = self.plugin_api self.looping_call_p = mock.patch( 'oslo_service.loopingcall.FixedIntervalLoopingCall') self.looping_call_p.start() subnet_id_1 = _uuid() subnet_id_2 = _uuid() self.snat_ports = [{'subnets': [{'cidr': '152.2.0.0/16', 'gateway_ip': '152.2.0.1', 'id': subnet_id_1}], 'network_id': _uuid(), 'device_owner': lib_constants.DEVICE_OWNER_ROUTER_SNAT, 'mac_address': 'fa:16:3e:80:8d:80', 'fixed_ips': [{'subnet_id': subnet_id_1, 'ip_address': '152.2.0.13', 'prefixlen': 16}], 'id': _uuid(), 'device_id': _uuid()}, {'subnets': [{'cidr': '152.10.0.0/16', 'gateway_ip': '152.10.0.1', 'id': subnet_id_2}], 'network_id': _uuid(), 'device_owner': lib_constants.DEVICE_OWNER_ROUTER_SNAT, 'mac_address': 'fa:16:3e:80:8d:80', 'fixed_ips': [{'subnet_id': subnet_id_2, 'ip_address': '152.10.0.13', 'prefixlen': 16}], 'id': _uuid(), 'device_id': _uuid()}] self.ri_kwargs = {'agent_conf': self.conf, 'interface_driver': self.mock_driver}