Ejemplo n.º 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
Ejemplo n.º 2
0
    def setUpClass(cls):
        cls.api = cls.vtm.get_client()
        if not isinstance(cls.api, MidonetApi):
            raise ArgMismatchException("Need midonet client for this test")

        setup_main_tunnel_zone(
            cls.api,
            {h.name: h.interfaces["eth0"].ip_list[0].ip for h in cls.ptm.hypervisors.itervalues()},
            cls.setup_logger,
        )
        cls.main_bridge = setup_main_bridge(cls.api)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
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()