Exemplo n.º 1
0
    def test_host_plugin_vm(self):
        vtm = VirtualTopologyManager(client_api_impl=MockClient,
                                     physical_topology_manager=self.ptm)

        hv = self.ptm.hypervisors['cmp1']
        """ :type hv: HypervisorHost """

        vm = hv.create_vm('vm1')
        try:
            vm.create_interface('eth0', ip_list=[IP("10.3.3.3", "8")])

            # Normally we get this from network, but just go with a mocked up port for this test
            port = "fe6707e3-9c99-4529-b059-aa669d1463bb"

            virtual_host = Guest(vm)
            virtual_host.plugin_vm('eth0', port)

            self.assertTrue(port in virtual_host.open_ports_by_id)

            virtual_host.unplug_vm(port)

            self.assertFalse(port in virtual_host.open_ports_by_id)
        finally:
            vm.net_down()
            vm.shutdown()
            vm.remove()
Exemplo n.º 2
0
    def test_host_plugin_vm(self):
        vtc = VirtualTopologyConfig(client_api_impl=MockClient)
        test_system = RootServer()
        hv = test_system.config_compute(
            HostDef(
                'cmp1',
                [InterfaceDef(name='eth0', ip_list=[IPDef('2.2.2.2', '32')])]))
        vm = test_system.config_vm(
            VMDef(
                'cmp1',
                HostDef('vm1', [
                    InterfaceDef(name='eth0', ip_list=[IPDef('3.3.3.3', '32')])
                ])))

        # Normally we get this from network, but just go with a mocked up port for this test
        port = Port("fe6707e3-9c99-4529-b059-aa669d1463bb")

        virtual_host = Guest(vtc, vm)
        virtual_host.plugin_vm('eth0', port)
        self.assertEquals(virtual_host.open_ports_by_interface['eth0'], port)
Exemplo n.º 3
0
    def test_host_cross_vm_communication(self):
        vtm = VirtualTopologyManager(client_api_impl=MockClient,
                                     physical_topology_manager=self.ptm)

        hv1 = self.ptm.hosts_by_name['cmp1']
        """ :type hv1: HypervisorHost """
        hv2 = self.ptm.hosts_by_name['cmp2']
        """ :type hv2: HypervisorHost """

        vm1 = hv1.create_vm('vm1')
        vm2 = hv2.create_vm('vm2')

        try:
            vm1.create_interface('eth0', ip_list=[IP("10.3.3.3", "8")])
            vm2.create_interface('eth0', ip_list=[IP("10.55.55.55", "8")])

            # Normally we get this from network, but just go with a mocked up port for this test
            port1 = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
            port2 = "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"

            virtual_host1 = Guest(vm1)
            virtual_host1.plugin_vm('eth0', port1)

            virtual_host2 = Guest(vm2)
            virtual_host2.plugin_vm('eth0', port2)

            # No virtual bridge between VMs means they should NOT talk to each other yet.
            self.assertFalse(virtual_host1.ping('eth0', '10.55.55.55'))

            virtual_host1.unplug_vm(port1)
            virtual_host2.unplug_vm(port2)

        finally:
            vm1.net_down()
            vm2.net_down()
            vm1.shutdown()
            vm2.shutdown()
            vm1.remove()
            vm2.remove()
Exemplo n.º 4
0
    def test_ping_between_two_hosts(self):
        vtc = VirtualTopologyConfig(client_api_impl=MockClient)

        test_system = RootServer()
        hv = test_system.config_compute(HostDef('cmp1', [InterfaceDef(name='eth0', ip_list=[IPDef('2.2.2.2', '32')])]))
        vm = test_system.config_vm(VMDef('cmp1', HostDef('vm1', [InterfaceDef(name='eth0',
                                                                         ip_list=[IPDef('3.3.3.3', '32')])])))

        virtual_host = Guest(vtc,vtc)

        port = Port.from_json(vtc.get_client().create_port())
        """ :type: Port """

        virtual_host.plugin_vm(hv.get_interfaces_for_host('vm1')['eth0'], port_id)

        tenant_id = 'mdts2_test_ping_between_two_vms' + \
                  datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        name = 'test_ping_between_two_vms'

        #
        # Topology setup
        #

        # create network and subnet
        net_data = {'name': name, 'tenant_id': tenant_id}
        net = Network.from_json(vtc.get_client().create_network({'network':net_data}))
        """ :type: Network """

        network_id = net['network']['id']

        subnet = Subnet.from_json(vtc.client_api_impl.create_subnet(net))

        # create two ports
        port1 = vtc.client_api_impl.create_port({'port':net_data}))

        port2 = vtc.client_api_impl.create_port(
            {'port': {'tenant_id': tenant_id,
                      'network_id': network_id}})