Пример #1
0
 def setUp(self):
     super(TestBase, self).setUp()
     self.conf = config.setup_conf()
     config.register_interface_opts(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()
Пример #2
0
 def setUp(self):
     super(TestBase, self).setUp()
     self.conf = config.setup_conf()
     config.register_interface_opts(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()
Пример #3
0
 def setUp(self):
     self.conf = config.setup_conf()
     config.register_interface_opts(self.conf)
     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()
Пример #4
0
    def setUp(self):
        super(TestRouterInfo, self).setUp()

        conf = 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}
Пример #5
0
    def setUp(self):
        super(TestRouterInfo, self).setUp()

        conf = config.setup_conf()
        l3_config.register_l3_agent_config_opts(l3_config.OPTS, 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 _prepare_router_data(self, ports=None):
     self.router_id = uuidutils.generate_uuid()
     self.project_id = uuidutils.generate_uuid()
     self.conf = config.setup_conf()
     l3_config.register_l3_agent_config_opts(l3_config.OPTS, self.conf)
     ri_kwargs = {'router': {'id': self.router_id,
                             'project_id': self.project_id},
                  'agent_conf': self.conf,
                  'interface_driver': mock.ANY,
                  'use_ipv6': mock.ANY}
     ri = l3router.RouterInfo(mock.Mock(), self.router_id, **ri_kwargs)
     ri.internal_ports = ports
     return {ri.router_id: ri}, ri
 def _prepare_router_data(self, ports=None):
     self.router_id = uuidutils.generate_uuid()
     self.project_id = uuidutils.generate_uuid()
     self.conf = config.setup_conf()
     l3_config.register_l3_agent_config_opts(l3_config.OPTS, self.conf)
     ri_kwargs = {'router': {'id': self.router_id,
                             'project_id': self.project_id},
                  'agent_conf': self.conf,
                  'interface_driver': mock.ANY,
                  'use_ipv6': mock.ANY}
     ri = l3router.RouterInfo(mock.Mock(), self.router_id, **ri_kwargs)
     ri.internal_ports = ports
     return {ri.router_id: ri}, ri
Пример #8
0
 def setUp(self):
     super(TestBase, self).setUp()
     self.conf = config.setup_conf()
     ovs_conf.register_ovs_opts(self.conf)
     config.register_interface_opts(self.conf)
     self.eth_offload_p = mock.patch.object(ethtool, 'offload')
     self.eth_offload = self.eth_offload_p.start()
     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.get_devices_with_ip_p = mock.patch.object(ip_lib,
                                                    'get_devices_with_ip')
     self.get_devices_with_ip = self.get_devices_with_ip_p.start()
Пример #9
0
    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)
        agent_config.register_interface_opts(self.conf)
        agent_config.register_external_process_opts(self.conf)
        self.conf.set_override('interface_driver',
                               'neutron.agent.linux.interface.NullDriver')
        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
        }
Пример #10
0
 def setUp(self):
     super(TestLoadInterfaceDriver, self).setUp()
     self.conf = config.setup_conf()
     config.register_interface_opts(self.conf)
     config.register_interface_driver_opts_helper(self.conf)
Пример #11
0
 def setUp(self):
     super(TestLoadInterfaceDriver, self).setUp()
     self.conf = config.setup_conf()
     config.register_interface_opts(self.conf)
     config.register_interface_driver_opts_helper(self.conf)
Пример #12
0
 def test_root_default(self):
     conf = config.setup_conf()
     config.register_root_helper(conf)
     self.assertEqual(config.get_root_helper(conf), 'sudo')
Пример #13
0
 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)
Пример #14
0
 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')
Пример #15
0
def test_setup_conf():
    conf = config.setup_conf()
    assert conf.state_path.endswith('/var/lib/neutron')
Пример #16
0
 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)
Пример #17
0
 def test_root_default(self):
     conf = config.setup_conf()
     config.register_root_helper(conf)
     self.assertEqual(config.get_root_helper(conf), 'sudo')
Пример #18
0
 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')
Пример #19
0
    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)
        agent_config.register_interface_opts(self.conf)
        agent_config.register_external_process_opts(self.conf)
        self.conf.set_override('interface_driver',
                               'neutron.agent.linux.interface.NullDriver')
        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}
Пример #20
0
def test_setup_conf():
    conf = config.setup_conf()
    assert conf.state_path.endswith('/var/lib/neutron')