Ejemplo n.º 1
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)
Ejemplo n.º 2
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}})