def test_creation(self):
        api = VirtualTopologyManager(physical_topology_manager=None,
                                     client_api_impl=MockClient(endpoint_url='test',
                                                                auth_strategy='test2',
                                                                option1='test3'))

        self.assertEqual(api.get_client().get_option('endpoint_url'), 'test')
        self.assertEqual(api.get_client().get_option('auth_strategy'), 'test2')
        self.assertEqual(api.get_client().get_option('option1'), 'test3')
Beispiel #2
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()
    def test_subnet(self):
        api = VirtualTopologyManager(physical_topology_manager=None,
                                     client_api_impl=MockClient())
        subnet = {
            'subnet': {
                'name': 'test-l2',
                'enable_dhcp': True,
                'network_id': 'b6c86193-024c-4aeb-bd9c-ffc747bb8a74',
                'tenant_id': 'mdts2-ft2015-03-10 06:03:17',
                'dns_nameservers': [],
                'ipv6_ra_mode': None,
                'allocation_pools': [
                    {
                        'start': '1.1.1.2',
                        'end': '1.1.1.254'}],
                'gateway_ip': '1.1.1.1',
                'ipv6_address_mode': None,
                'ip_version': 4,
                'host_routes': [],
                'cidr': '1.1.1.0/24',
                'id': '6c838ffc-6a40-49ba-b363-6380b0a7dae6'}}

        api.get_client().set_subnet(subnet)
        self.assertEqual(api.get_client().show_subnet(), subnet)