Beispiel #1
0
    def setUpClass(cls):
        cls.ptm.configure_logging(debug=True)
        cls.ptm.configure(os.path.dirname(os.path.abspath(__file__)) + '/test-basic-config.json')
        logging.getLogger("neutronclient").addHandler(logging.StreamHandler())
        cls.ptm.startup()
        cls.vtm = VirtualTopologyManager(client_api_impl=create_neutron_client(),
                                         physical_topology_manager=cls.ptm)

        cls.api = cls.vtm.get_client()
        """ :type: neutron_client.Client"""

        cls.mn_api = create_midonet_client()

        log = logging.getLogger("neutronclient")
        log.setLevel(logging.DEBUG)

        setup_main_tunnel_zone(cls.mn_api,
                               {h.name: h.interfaces['eth0'].ip_list[0].ip
                                for h in cls.ptm.hypervisors.itervalues()},
                               cls.ptm.LOG)

        try:
            (cls.main_network, cls.main_subnet) = setup_neutron(cls.api, subnet_cidr='10.0.1.1/24', log=log)
        except Exception:
            clean_neutron(cls.api, log=log)
            cls.ptm.shutdown()
            LinuxCLI().cmd('ip netns del vm1')
            raise
    def setup_neutron_test(cls):
        """
        Sets up neutron network and subnet.  Can be overridden by subclasses to change behavior
        """
        cls.api = cls.vtm.get_client()
        cls.mn_api = create_midonet_client()

        setup_main_tunnel_zone(cls.mn_api,
                               {h.name: h.interfaces['eth0'].ip_list[0].ip
                                for h in cls.ptm.hypervisors.itervalues()},
                               cls.setup_logger)

        (cls.main_network, cls.main_subnet) = setup_neutron(cls.api,
                                                              subnet_cidr='10.0.1.1/24', log=cls.setup_logger)
Beispiel #3
0
    def test_midonet_api_ping_two_hosts_same_hv(self):
        vtm = VirtualTopologyManager(client_api_impl=create_midonet_client(),
                                     physical_topology_manager=self.ptm)


        # Set up virtual topology
        api = vtm.get_client()
        """ :type: MidonetApi"""

        logger = self.ptm.log_manager.add_tee_logger('MNAPITest', 'mnapi-test-logger',
                                                     file_log_level=logging.DEBUG,
                                                     stdout_log_level=logging.DEBUG)

        tz = setup_main_tunnel_zone(api,
                                    {h.name: h.interfaces['eth0'].ip_list[0].ip
                                     for h in self.ptm.hypervisors.itervalues()},
                                    logger)
        main_bridge = setup_main_bridge(api)
        """ :type: Bridge"""

        port1 = main_bridge.add_port().create()
        """ :type: Port"""
        port2 = main_bridge.add_port().create()
        """ :type: Port"""

        vm1 = vtm.create_vm(ip='10.1.1.2', preferred_hv_host='cmp2')
        vm2 = vtm.create_vm(ip='10.1.1.3', preferred_hv_host='cmp2')

        try:
            vm1.plugin_vm('eth0', port1.get_id())
            vm2.plugin_vm('eth0', port2.get_id())

            self.assertTrue(vm1.ping(on_iface='eth0', target_ip='10.1.1.3'))
            self.assertTrue(vm2.ping(on_iface='eth0', target_ip='10.1.1.2'))

        finally:
            vm1.terminate()
            vm2.terminate()
            port1.delete()
            port2.delete()
            main_bridge.delete()
Beispiel #4
0
                client_args[p[0]] = p[1]
            pass
        else:
            raise ArgMismatchException('Invalid argument' + arg)

    if len(tests) == 0:
        usage(ArgMismatchException('Must specify at least one test with the -t or --tests option'))

    root_dir = LinuxCLI().cmd('pwd').strip()
    print 'Setting root dir to: ' + root_dir

    client_impl = None
    if client_impl_type == 'neutron':
        client_impl = create_neutron_client(**client_args)
    elif client_impl_type == 'midonet':
        client_impl = create_midonet_client(**client_args)
    else:
        raise ArgMismatchException('Invalid client API implementation:' + client_impl_type)

    print 'Setting up log manager'
    log_manager = LogManager(root_dir=log_dir)
    console_log = log_manager.add_stdout_logger(name='tsm-run-console',
                                                log_level=logging.DEBUG if debug is True else logging.INFO)
    log_manager.rollover_logs_fresh(file_filter='*.log')

    console_log.debug('Setting up PTM')
    ptm = PhysicalTopologyManager(root_dir=root_dir, log_manager=log_manager)
    ptm.configure_logging(debug=debug)

    console_log.debug('Setting up VTM')
    vtm = VirtualTopologyManager(physical_topology_manager=ptm, client_api_impl=client_impl, log_manager=log_manager)