예제 #1
0
    def test_ping_all_with_ensure_port(self):
        fake_ports = self.fake_ports

        def fake_port_list(network_id=None, device_owner=None, device_id=None):
            if network_id:
                # In order to test ensure_port, return []
                return {'ports': []}
            return fake_ports
        self.client.list_ports.side_effect = fake_port_list
        cmd = commands.PingAll(self.app, None)
        cmd_parser = cmd.get_parser('ping_all')
        args = []
        parsed_args = cmd_parser.parse_args(args)
        namespace = 'qprobe-fake_port'
        with mock.patch('neutron.agent.linux.ip_lib.IpNetnsCommand') as ns:
            cmd.run(parsed_args)
            ns.assert_has_calls([mock.call.execute(mock.ANY)])
        fake_port = {'port':
                    {'device_owner': debug_agent.DEVICE_OWNER_NETWORK_PROBE,
                     'admin_state_up': True,
                     'network_id': 'fake_net',
                     'tenant_id': 'fake_tenant',
                     portbindings.HOST_ID: cfg.CONF.host,
                     'fixed_ips': [{'subnet_id': 'fake_subnet'}],
                     'device_id': socket.gethostname()}}
        expected = [mock.call.show_network('fake_net'),
                    mock.call.show_subnet('fake_subnet'),
                    mock.call.create_port(fake_port),
                    mock.call.show_subnet('fake_subnet')]
        self.client.assert_has_calls(expected)
        self.driver.assert_has_calls([mock.call.init_l3('tap12345678-12',
                                                        ['10.0.0.3/24'],
                                                        namespace=namespace
                                                        )])
예제 #2
0
 def test_ping_all_v6(self):
     fake_subnet_v6 = {'subnet': {'name': 'fake_v6', 'ip_version': 6}}
     self.client.show_subnet.return_value = fake_subnet_v6
     cmd = commands.PingAll(self.app, None)
     cmd_parser = cmd.get_parser('ping_all')
     args = []
     parsed_args = cmd_parser.parse_args(args)
     with mock.patch('neutron.agent.linux.ip_lib.IpNetnsCommand') as ns:
         cmd.run(parsed_args)
         ns.assert_has_calls([mock.call.execute(mock.ANY)])
     self.client.assert_has_calls([mock.call.list_ports()])
예제 #3
0
 def test_ping_all(self):
     cmd = commands.PingAll(self.app, None)
     cmd_parser = cmd.get_parser('ping_all')
     args = []
     parsed_args = cmd_parser.parse_args(args)
     with mock.patch('neutron.agent.linux.ip_lib.IpNetnsCommand') as ns:
         cmd.run(parsed_args)
         ns.assert_has_calls([mock.call.execute(mock.ANY)])
     expected = [mock.call.list_ports(),
                 mock.call.list_ports(
                     network_id='fake_net',
                     device_owner=debug_agent.DEVICE_OWNER_NETWORK_PROBE,
                     device_id=socket.gethostname()),
                 mock.call.show_subnet('fake_subnet'),
                 mock.call.show_port('fake_port')]
     self.client.assert_has_calls(expected)