Ejemplo n.º 1
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
     cfg.CONF.register_opts(interface.OPTS)
     cfg.CONF.register_opts(config.EXT_NET_BRIDGE_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)
Ejemplo n.º 2
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.')
Ejemplo n.º 3
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)