Exemple #1
0
def register_options(conf):
    config.register_interface_driver_opts_helper(conf)
    config.register_agent_state_opts_helper(conf)
    config.register_availability_zone_opts_helper(conf)
    dhcp_config.register_agent_dhcp_opts(conf)
    meta_conf.register_meta_conf_opts(meta_conf.SHARED_OPTS, conf)
    conf.register_opts(interface.OPTS)
Exemple #2
0
def register_options(conf):
    config.register_interface_driver_opts_helper(conf)
    config.register_agent_state_opts_helper(conf)
    config.register_availability_zone_opts_helper(conf)
    dhcp_config.register_agent_dhcp_opts(conf)
    meta_conf.register_meta_conf_opts(meta_conf.SHARED_OPTS, conf)
    conf.register_opts(interface.OPTS)
Exemple #3
0
 def _configure(self):
     config.register_interface_driver_opts_helper(cfg.CONF)
     cfg.CONF.set_override(
         'interface_driver',
         'neutron.agent.linux.interface.OVSInterfaceDriver')
     config.register_interface_opts()
     self.driver = importutils.import_object(cfg.CONF.interface_driver,
                                             cfg.CONF)
Exemple #4
0
 def _configure(self):
     config.register_interface_driver_opts_helper(cfg.CONF)
     cfg.CONF.set_override(
         'interface_driver',
         'neutron.agent.linux.interface.OVSInterfaceDriver')
     config.register_interface_opts()
     self.driver = importutils.import_object(cfg.CONF.interface_driver,
                                             cfg.CONF)
Exemple #5
0
 def _get_config_opts(self):
     config = cfg.ConfigOpts()
     config.register_opts(common_config.core_opts)
     ovs_conf.register_ovs_agent_opts(config)
     agent_config.register_interface_opts(config)
     agent_config.register_interface_driver_opts_helper(config)
     agent_config.register_agent_state_opts_helper(config)
     ext_manager.register_opts(config)
     return config
Exemple #6
0
 def _get_config_opts(self):
     config = cfg.ConfigOpts()
     config.register_opts(common_config.core_opts)
     ovs_conf.register_ovs_agent_opts(config)
     agent_config.register_interface_opts(config)
     agent_config.register_interface_driver_opts_helper(config)
     agent_config.register_agent_state_opts_helper(config)
     ext_manager.register_opts(config)
     return config
Exemple #7
0
def register_opts(conf):
    l3_config.register_l3_agent_config_opts(l3_config.OPTS, conf)
    ha_conf.register_l3_agent_ha_opts(conf)
    meta_conf.register_meta_conf_opts(meta_conf.SHARED_OPTS, conf)
    config.register_interface_driver_opts_helper(conf)
    config.register_agent_state_opts_helper(conf)
    config.register_interface_opts(conf)
    config.register_external_process_opts(conf)
    config.register_pddriver_opts(conf)
    config.register_ra_opts(conf)
    config.register_availability_zone_opts_helper(conf)
Exemple #8
0
 def setUp(self):
     super(TestDhcp, self).setUp()
     conf = cfg.ConfigOpts()
     config.register_interface_driver_opts_helper(conf)
     config.register_interface_opts(conf)
     conf.register_opts(common_conf.core_opts)
     conf.register_opts(dhcp_conf.DHCP_AGENT_OPTS)
     conf.set_override('interface_driver', 'openvswitch')
     conf.set_override('host', 'foo-host')
     self.conf = conf
     br_int = self.useFixture(net_helpers.OVSBridgeFixture()).bridge
     self.conf.set_override('ovs_integration_bridge', br_int.br_name)
Exemple #9
0
 def setUp(self):
     super(TestDhcp, self).setUp()
     conf = cfg.ConfigOpts()
     config.register_interface_driver_opts_helper(conf)
     config.register_interface_opts(conf)
     conf.register_opts(common_conf.core_opts)
     conf.register_opts(dhcp_conf.DHCP_AGENT_OPTS)
     conf.set_override('interface_driver', 'openvswitch')
     conf.set_override('host', 'foo-host')
     self.conf = conf
     br_int = self.useFixture(net_helpers.OVSBridgeFixture()).bridge
     self.conf.set_override('ovs_integration_bridge', br_int.br_name)
Exemple #10
0
def setup_conf():
    """Setup the cfg for the clean up utility.

    Use separate setup_conf for the utility because there are many options
    from the main config that do not apply during clean-up.
    """

    conf = cfg.CONF
    cmd.register_cmd_opts(cmd.netns_opts, conf)
    agent_config.register_interface_driver_opts_helper(conf)
    dhcp_config.register_agent_dhcp_opts(conf)
    conf.register_opts(interface.OPTS)
    return conf
Exemple #11
0
def setup_conf():
    """Setup the cfg for the clean up utility.

    Use separate setup_conf for the utility because there are many options
    from the main config that do not apply during clean-up.
    """

    conf = cfg.CONF
    cmd.register_cmd_opts(cmd.netns_opts, conf)
    agent_config.register_interface_driver_opts_helper(conf)
    dhcp_config.register_agent_dhcp_opts(conf)
    agent_config.register_interface_opts()
    return conf
Exemple #12
0
def setup_conf():
    """Setup the cfg for the clean up utility.

    Use separate setup_conf for the utility because there are many options
    from the main config that do not apply during clean-up.
    """

    conf = cfg.CONF
    cmd.register_cmd_opts(cmd.ovs_opts, conf)
    l3_config.register_l3_agent_config_opts(l3_config.OPTS, conf)
    conf.register_opts(interface.OPTS)
    agent_config.register_interface_driver_opts_helper(conf)
    return conf
Exemple #13
0
    def setUp(self):
        super(TestMetadataDriverProcess, self).setUp()
        mock.patch('eventlet.spawn').start()
        agent_config.register_interface_driver_opts_helper(cfg.CONF)
        cfg.CONF.set_override('interface_driver',
                              'neutron.agent.linux.interface.NullDriver')

        mock.patch('neutron.agent.l3.agent.L3PluginApi').start()
        mock.patch('neutron.agent.l3.ha.AgentMixin'
                   '._init_ha_conf_path').start()

        l3_config.register_l3_agent_config_opts(l3_config.OPTS, cfg.CONF)
        ha_conf.register_l3_agent_ha_opts()
        meta_conf.register_meta_conf_opts(meta_conf.SHARED_OPTS, cfg.CONF)
Exemple #14
0
def setup_conf():
    """Setup the cfg for the clean up utility.

    Use separate setup_conf for the utility because there are many options
    from the main config that do not apply during clean-up.
    """

    conf = cfg.CONF
    cmd.register_cmd_opts(cmd.ovs_opts, conf)
    l3_config.register_l3_agent_config_opts(l3_config.OPTS, conf)
    agent_config.register_interface_driver_opts_helper(conf)
    agent_config.register_interface_opts()
    conf.set_default("ovsdb_timeout", CLEANUP_OVSDB_TIMEOUT, "OVS")
    return conf
Exemple #15
0
    def setUp(self):
        super(TestMetadataDriverProcess, self).setUp()
        mock.patch('eventlet.spawn').start()
        agent_config.register_interface_driver_opts_helper(cfg.CONF)
        cfg.CONF.set_override('interface_driver',
                              'neutron.agent.linux.interface.NullDriver')

        mock.patch('neutron.agent.l3.agent.L3PluginApi').start()
        mock.patch('neutron.agent.l3.ha.AgentMixin'
                   '._init_ha_conf_path').start()

        l3_config.register_l3_agent_config_opts(l3_config.OPTS, cfg.CONF)
        ha_conf.register_l3_agent_ha_opts()
        meta_conf.register_meta_conf_opts(meta_conf.SHARED_OPTS, cfg.CONF)
Exemple #16
0
def setup_conf():
    """Setup the cfg for the clean up utility.

    Use separate setup_conf for the utility because there are many options
    from the main config that do not apply during clean-up.
    """

    conf = cfg.CONF
    cmd.register_cmd_opts(cmd.ovs_opts, conf)
    l3_config.register_l3_agent_config_opts(l3_config.OPTS, conf)
    agent_config.register_interface_driver_opts_helper(conf)
    agent_config.register_interface_opts()
    conf.set_default("ovsdb_timeout", CLEANUP_OVSDB_TIMEOUT, "OVS")
    return conf
Exemple #17
0
 def initialize_app(self, argv):
     super(NeutronDebugShell, self).initialize_app(argv)
     if not self.options.config_file:
         raise exc.CommandError(
             _("You must provide a config file for bridge -"
               " either --config-file or env[NEUTRON_TEST_CONFIG_FILE]"))
     client = self.client_manager.neutron
     config.register_interface_opts()
     config.register_interface_driver_opts_helper(cfg.CONF)
     cfg.CONF(['--config-file', self.options.config_file])
     config.setup_logging()
     driver = utils.load_interface_driver(cfg.CONF)
     self.debug_agent = debug_agent.NeutronDebugAgent(
         cfg.CONF, client, driver)
     self.log.warning('This tool is deprecated and will be removed '
                      'in the future to be replaced with a more '
                      'powerful troubleshooting toolkit.')
Exemple #18
0
 def initialize_app(self, argv):
     super(NeutronDebugShell, self).initialize_app(argv)
     if not self.options.config_file:
         raise exc.CommandError(
             _("You must provide a config file for bridge -"
               " either --config-file or env[NEUTRON_TEST_CONFIG_FILE]"))
     client = self.client_manager.neutron
     config.register_interface_opts()
     config.register_interface_driver_opts_helper(cfg.CONF)
     cfg.CONF(['--config-file', self.options.config_file])
     config.setup_logging()
     driver = utils.load_interface_driver(cfg.CONF)
     self.debug_agent = debug_agent.NeutronDebugAgent(cfg.CONF,
                                                      client,
                                                      driver)
     self.log.warning('This tool is deprecated and will be removed '
                      'in the future to be replaced with a more '
                      'powerful troubleshooting toolkit.')
Exemple #19
0
def main():
    cfg.CONF.register_opts(OPTS)
    cfg.CONF.register_opts(manager.OPTS)
    # import interface options just in case the driver uses namespaces
    cfg.CONF.register_opts(interface.OPTS)
    cfg.CONF.register_opts(external_process.OPTS)
    config.register_interface_driver_opts_helper(cfg.CONF)
    config.register_agent_state_opts_helper(cfg.CONF)
    config.register_root_helper(cfg.CONF)

    common_config.init(sys.argv[1:])
    config.setup_logging()

    mgr = manager.LbaasAgentManager(cfg.CONF)
    svc = LbaasAgentService(host=cfg.CONF.host,
                            topic=constants.LOADBALANCER_AGENTV2,
                            manager=mgr)
    service.launch(cfg.CONF, svc).wait()
Exemple #20
0
    def setUp(self):
        super(TestMetadataDriverProcess, self).setUp()
        mock.patch('eventlet.spawn').start()
        agent_config.register_interface_driver_opts_helper(cfg.CONF)
        cfg.CONF.set_override('interface_driver',
                              'neutron.agent.linux.interface.NullDriver')

        mock.patch('neutron.agent.l3.agent.L3PluginApi').start()
        mock.patch('neutron.agent.l3.ha.AgentMixin'
                   '._init_ha_conf_path').start()
        self.delete_if_exists = mock.patch.object(linux_utils,
                                                  'delete_if_exists')
        self.mock_get_process = mock.patch.object(
            metadata_driver.MetadataDriver,
            '_get_metadata_proxy_process_manager')

        l3_config.register_l3_agent_config_opts(l3_config.OPTS, cfg.CONF)
        ha_conf.register_l3_agent_ha_opts()
        meta_conf.register_meta_conf_opts(meta_conf.SHARED_OPTS, cfg.CONF)
Exemple #21
0
def main():
    cfg.CONF.register_opts(OPTS)
    cfg.CONF.register_opts(manager.OPTS)
    # import interface options just in case the driver uses namespaces
    config.register_interface_opts(cfg.CONF)
    config.register_external_process_opts(cfg.CONF)
    config.register_interface_driver_opts_helper(cfg.CONF)
    config.register_agent_state_opts_helper(cfg.CONF)
    config.register_root_helper(cfg.CONF)

    common_config.init(sys.argv[1:])
    config.setup_logging()
    config.setup_privsep()

    LOG.warning('neutron-lbaas is now deprecated. See: '
                'https://wiki.openstack.org/wiki/Neutron/LBaaS/Deprecation')

    mgr = manager.LbaasAgentManager(cfg.CONF)
    svc = LbaasAgentService(host=cfg.CONF.host,
                            topic=constants.LOADBALANCER_AGENTV2,
                            manager=mgr)
    service.launch(cfg.CONF, svc).wait()
Exemple #22
0
def main():
    cfg.CONF.register_opts(OPTS)
    cfg.CONF.register_opts(manager.OPTS)
    # import interface options just in case the driver uses namespaces
    config.register_interface_opts(cfg.CONF)
    config.register_external_process_opts(cfg.CONF)
    config.register_interface_driver_opts_helper(cfg.CONF)
    config.register_agent_state_opts_helper(cfg.CONF)
    config.register_root_helper(cfg.CONF)

    common_config.init(sys.argv[1:])
    config.setup_logging()
    config.setup_privsep()

    LOG.warning('neutron-lbaas is now deprecated. See: '
                'https://wiki.openstack.org/wiki/Neutron/LBaaS/Deprecation')

    mgr = manager.LbaasAgentManager(cfg.CONF)
    svc = LbaasAgentService(
        host=cfg.CONF.host,
        topic=constants.LOADBALANCER_AGENTV2,
        manager=mgr
    )
    service.launch(cfg.CONF, svc).wait()
Exemple #23
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
        }
Exemple #24
0
from neutron.agent.l3 import namespaces
from neutron.agent.linux import ip_lib
from neutron.agent.linux import iptables_manager
from neutron.conf.agent import common as config
from neutron.services.metering.drivers import abstract_driver

LOG = logging.getLogger(__name__)
NS_PREFIX = 'qrouter-'
WRAP_NAME = 'neutron-meter'
EXTERNAL_DEV_PREFIX = 'qg-'
ROUTER_2_FIP_DEV_PREFIX = namespaces.ROUTER_2_FIP_DEV_PREFIX
TOP_CHAIN = WRAP_NAME + "-FORWARD"
RULE = '-r-'
LABEL = '-l-'

config.register_interface_driver_opts_helper(cfg.CONF)
config.register_interface_opts()


class IptablesManagerTransaction(object):
    __transactions = {}

    def __init__(self, im):
        self.im = im

        transaction = self.__transactions.get(im, 0)
        transaction += 1
        self.__transactions[im] = transaction

    def __enter__(self):
        return self.im
    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}
 def setUp(self):
     super(TestInterfaceDriver, self).setUp()
     config.register_interface_driver_opts_helper(cfg.CONF)
     cfg.CONF.register_opts(interface.OPTS)
Exemple #27
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)
 def setUp(self):
     super(TestInterfaceDriverMissingNetworkDeviceMtu, self).setUp()
     config.register_interface_driver_opts_helper(cfg.CONF)
Exemple #29
0
    def setUp(self):
        super(TestDebugCommands, self).setUp()
        config.register_interface_opts()
        cfg.CONF.register_opts(config.EXT_NET_BRIDGE_OPTS)
        common_config.init([])
        config.register_interface_driver_opts_helper(cfg.CONF)

        device_exists_p = mock.patch(
            'neutron.agent.linux.ip_lib.device_exists', return_value=False)
        device_exists_p.start()
        namespace_e_p = mock.patch(
            'neutron.agent.linux.ip_lib.network_namespace_exists')
        namespace_e_p.start()
        namespace_d_p = mock.patch(
            'neutron.agent.linux.ip_lib.delete_network_namespace')
        namespace_d_p.start()
        ensure_namespace_p = mock.patch(
            'neutron.agent.linux.ip_lib.IPWrapper.ensure_namespace')
        ensure_namespace_p.start()
        dvr_cls_p = mock.patch('neutron.agent.linux.interface.NullDriver')
        driver_cls = dvr_cls_p.start()
        mock_driver = mock.MagicMock()
        mock_driver.DEV_NAME_LEN = (
            interface.LinuxInterfaceDriver.DEV_NAME_LEN)
        mock_driver.get_device_name.return_value = 'tap12345678-12'
        driver_cls.return_value = mock_driver
        self.driver = mock_driver

        client_cls_p = mock.patch('neutronclient.v2_0.client.Client')
        client_cls = client_cls_p.start()
        client_inst = mock.Mock()
        client_cls.return_value = client_inst

        fake_network = {'network': {'id': 'fake_net',
                                    'tenant_id': 'fake_tenant',
                                    'subnets': ['fake_subnet']}}
        fake_port = {'port':
                    {'id': 'fake_port',
                     'device_owner': 'fake_device',
                     'mac_address': 'aa:bb:cc:dd:ee:ffa',
                     'network_id': 'fake_net',
                     'fixed_ips':
                     [{'subnet_id': 'fake_subnet', 'ip_address': '10.0.0.3'}]
                     }}
        fake_ports = {'ports': [fake_port['port']]}
        self.fake_ports = fake_ports
        allocation_pools = [{'start': '10.0.0.2',
                             'end': '10.0.0.254'}]
        fake_subnet_v4 = {'subnet': {'name': 'fake_subnet_v4',
                          'id': 'fake_subnet',
                          'network_id': 'fake_net',
                          'gateway_ip': '10.0.0.1',
                          'dns_nameservers': ['10.0.0.2'],
                          'host_routes': [],
                          'cidr': '10.0.0.0/24',
                          'allocation_pools': allocation_pools,
                          'enable_dhcp': True,
                          'ip_version': constants.IP_VERSION_4}}

        client_inst.list_ports.return_value = fake_ports
        client_inst.create_port.return_value = fake_port
        client_inst.show_port.return_value = fake_port
        client_inst.show_network.return_value = fake_network
        client_inst.show_subnet.return_value = fake_subnet_v4
        self.client = client_inst
        mock_std = mock.Mock()
        self.app = MyApp(mock_std)
        self.app.debug_agent = debug_agent.NeutronDebugAgent(cfg.CONF,
                                                             client_inst,
                                                             mock_driver)
Exemple #30
0
    def setUp(self):
        super(TestDebugCommands, self).setUp()
        config.register_interface_opts()
        cfg.CONF.register_opts(config.EXT_NET_BRIDGE_OPTS)
        common_config.init([])
        config.register_interface_driver_opts_helper(cfg.CONF)

        device_exists_p = mock.patch(
            'neutron.agent.linux.ip_lib.device_exists', return_value=False)
        device_exists_p.start()
        namespace_p = mock.patch(
            'neutron.agent.linux.ip_lib.IpNetnsCommand')
        namespace_p.start()
        ensure_namespace_p = mock.patch(
            'neutron.agent.linux.ip_lib.IPWrapper.ensure_namespace')
        ensure_namespace_p.start()
        dvr_cls_p = mock.patch('neutron.agent.linux.interface.NullDriver')
        driver_cls = dvr_cls_p.start()
        mock_driver = mock.MagicMock()
        mock_driver.DEV_NAME_LEN = (
            interface.LinuxInterfaceDriver.DEV_NAME_LEN)
        mock_driver.get_device_name.return_value = 'tap12345678-12'
        driver_cls.return_value = mock_driver
        self.driver = mock_driver

        client_cls_p = mock.patch('neutronclient.v2_0.client.Client')
        client_cls = client_cls_p.start()
        client_inst = mock.Mock()
        client_cls.return_value = client_inst

        fake_network = {'network': {'id': 'fake_net',
                                    'tenant_id': 'fake_tenant',
                                    'subnets': ['fake_subnet']}}
        fake_port = {'port':
                    {'id': 'fake_port',
                     'device_owner': 'fake_device',
                     'mac_address': 'aa:bb:cc:dd:ee:ffa',
                     'network_id': 'fake_net',
                     'fixed_ips':
                     [{'subnet_id': 'fake_subnet', 'ip_address': '10.0.0.3'}]
                     }}
        fake_ports = {'ports': [fake_port['port']]}
        self.fake_ports = fake_ports
        allocation_pools = [{'start': '10.0.0.2',
                             'end': '10.0.0.254'}]
        fake_subnet_v4 = {'subnet': {'name': 'fake_subnet_v4',
                          'id': 'fake_subnet',
                          'network_id': 'fake_net',
                          'gateway_ip': '10.0.0.1',
                          'dns_nameservers': ['10.0.0.2'],
                          'host_routes': [],
                          'cidr': '10.0.0.0/24',
                          'allocation_pools': allocation_pools,
                          'enable_dhcp': True,
                          'ip_version': 4}}

        client_inst.list_ports.return_value = fake_ports
        client_inst.create_port.return_value = fake_port
        client_inst.show_port.return_value = fake_port
        client_inst.show_network.return_value = fake_network
        client_inst.show_subnet.return_value = fake_subnet_v4
        self.client = client_inst
        mock_std = mock.Mock()
        self.app = MyApp(mock_std)
        self.app.debug_agent = debug_agent.NeutronDebugAgent(cfg.CONF,
                                                             client_inst,
                                                             mock_driver)
Exemple #31
0
from neutron.agent.linux import iptables_manager
from neutron.common import ipv6_utils
from neutron.conf.agent import common as config
from neutron.services.metering.drivers import abstract_driver


LOG = logging.getLogger(__name__)
NS_PREFIX = 'qrouter-'
WRAP_NAME = 'neutron-meter'
EXTERNAL_DEV_PREFIX = 'qg-'
ROUTER_2_FIP_DEV_PREFIX = namespaces.ROUTER_2_FIP_DEV_PREFIX
TOP_CHAIN = WRAP_NAME + "-FORWARD"
RULE = '-r-'
LABEL = '-l-'

config.register_interface_driver_opts_helper(cfg.CONF)
config.register_interface_opts()


class IptablesManagerTransaction(object):
    __transactions = {}

    def __init__(self, im):
        self.im = im

        transaction = self.__transactions.get(im, 0)
        transaction += 1
        self.__transactions[im] = transaction

    def __enter__(self):
        return self.im
Exemple #32
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)