def test_icmp_topology_in_test(): # Scenario: # When: a VM sends ICMP echo request with ping command # Then: the receiver VM should receive the ICMP echo packet. # And: the ping command succeeds # Building physical topology host1 = service.get_container_by_hostname('midolman1') host2 = service.get_container_by_hostname('midolman2') PTM.add_host_to_tunnel_zone('midolman1', 'tztest1') PTM.add_host_to_tunnel_zone('midolman2', 'tztest1') vm1data = { 'hw_addr': 'aa:bb:cc:00:00:11', 'ipv4_addr': ['172.16.1.2/24'], 'ipv4_gw': '172.16.1.1' } vm2data = { 'hw_addr': 'aa:bb:cc:00:00:22', 'ipv4_addr': ['172.16.1.3/24'], 'ipv4_gw': '172.16.1.1' } vm1 = host1.create_vmguest(**vm1data) vm2 = host2.create_vmguest(**vm2data) PTM.addCleanup(host1.destroy_vmguest, vm1) PTM.addCleanup(host2.destroy_vmguest, vm2) # Building virtual topology api = get_neutron_api() # Create network network = VTM.create_resource( api.create_network({ 'network': { 'name': 'demo', 'admin_state_up': 'True', 'tenant_id': 'admin' } })) VTM.create_resource( api.create_subnet({ 'subnet': { 'name': 'demo_subnet', 'network_id': network['network']['id'], 'ip_version': 4, 'cidr': '172.16.1.0/24', 'enable_dhcp': False } })) # Create ports port1json = { 'port': { 'name': 'port1', 'network_id': network['network']['id'], 'admin_state_up': True, 'mac_address': 'aa:bb:cc:00:00:11', 'fixed_ips': [{ 'ip_address': '172.16.1.2' }] } } port1 = VTM.create_resource(api.create_port(port1json)) LOG.debug(port1) port2json = { 'port': { 'name': 'port2', 'network_id': network['network']['id'], 'admin_state_up': True, 'mac_address': 'aa:bb:cc:00:00:22', 'fixed_ips': [{ 'ip_address': '172.16.1.3' }] } } port2 = VTM.create_resource(api.create_port(port2json)) LOG.debug(port2) # Bind virtual and physical topology host1.bind_port(vm1, port1['port']['id']) host2.bind_port(vm2, port2['port']['id']) # Test ping works f1 = async_assert_that( vm2, receives('dst host %s and icmp' % vm2.get_ip(), within_sec(10))) f2 = vm1.ping4(vm2) wait_on_futures([f1, f2])
def __init__(self): super(NeutronTopologyManager, self).__init__() self.resources = {} self.api = get_neutron_api() self.keystone = get_keystone_api()
def test_icmp_topology_in_test(): # Scenario: # When: a VM sends ICMP echo request with ping command # Then: the receiver VM should receive the ICMP echo packet. # And: the ping command succeeds # Building physical topology host1 = service.get_container_by_hostname('midolman1') host2 = service.get_container_by_hostname('midolman2') PTM.add_host_to_tunnel_zone('midolman1', 'tztest1') PTM.add_host_to_tunnel_zone('midolman2', 'tztest1') vm1data = {'hw_addr': 'aa:bb:cc:00:00:11', 'ipv4_addr': ['172.16.1.2/24'], 'ipv4_gw': '172.16.1.1'} vm2data = {'hw_addr': 'aa:bb:cc:00:00:22', 'ipv4_addr': ['172.16.1.3/24'], 'ipv4_gw': '172.16.1.1'} vm1 = host1.create_vmguest(**vm1data) vm2 = host2.create_vmguest(**vm2data) PTM.addCleanup(host1.destroy_vmguest, vm1) PTM.addCleanup(host2.destroy_vmguest, vm2) # Building virtual topology api = get_neutron_api() # Create network network = VTM.create_resource( api.create_network( {'network': {'name': 'demo', 'admin_state_up': 'True', 'tenant_id': 'admin'}} ) ) VTM.create_resource( api.create_subnet( {'subnet': {'name': 'demo_subnet', 'network_id': network['network']['id'], 'ip_version': 4, 'cidr': '172.16.1.0/24', 'enable_dhcp': False}} ) ) # Create ports port1json = {'port': {'name': 'port1', 'network_id': network['network']['id'], 'admin_state_up': True, 'mac_address': 'aa:bb:cc:00:00:11', 'fixed_ips': [{'ip_address': '172.16.1.2'}]}} port1 = VTM.create_resource(api.create_port(port1json)) LOG.debug(port1) port2json = {'port': {'name': 'port2', 'network_id': network['network']['id'], 'admin_state_up': True, 'mac_address': 'aa:bb:cc:00:00:22', 'fixed_ips': [{'ip_address': '172.16.1.3'}]}} port2 = VTM.create_resource(api.create_port(port2json)) LOG.debug(port2) # Bind virtual and physical topology host1.bind_port(vm1, port1['port']['id']) host2.bind_port(vm2, port2['port']['id']) # Test ping works f1 = async_assert_that(vm2, receives('dst host %s and icmp' % vm2.get_ip(), within_sec(10))) f2 = vm1.ping4(vm2) wait_on_futures([f1, f2])
def test_icmp_topology_in_test(): # Scenario: # When: a VM sends ICMP echo request with ping command # Then: the receiver VM should receive the ICMP echo packet. # And: the ping command succeeds # Building physical topology host1 = service.get_container_by_hostname("midolman1") host2 = service.get_container_by_hostname("midolman2") PTM.add_host_to_tunnel_zone("midolman1", "tztest1") PTM.add_host_to_tunnel_zone("midolman2", "tztest1") vm1data = {"hw_addr": "aa:bb:cc:00:00:11", "ipv4_addr": ["172.16.1.2/24"], "ipv4_gw": "172.16.1.1"} vm2data = {"hw_addr": "aa:bb:cc:00:00:22", "ipv4_addr": ["172.16.1.3/24"], "ipv4_gw": "172.16.1.1"} vm1 = host1.create_vmguest(**vm1data) vm2 = host2.create_vmguest(**vm2data) PTM.addCleanup(host1.destroy_vmguest, vm1) PTM.addCleanup(host2.destroy_vmguest, vm2) # Building virtual topology api = get_neutron_api() # Create network network = VTM.create_resource( api.create_network({"network": {"name": "demo", "admin_state_up": "True", "tenant_id": "admin"}}) ) subnet = VTM.create_resource( api.create_subnet( { "subnet": { "name": "demo_subnet", "network_id": network["network"]["id"], "ip_version": 4, "cidr": "172.16.1.0/24", "enable_dhcp": False, } } ) ) # Create ports port1json = { "port": { "name": "port1", "network_id": network["network"]["id"], "admin_state_up": True, "mac_address": "aa:bb:cc:00:00:11", "fixed_ips": [{"ip_address": "172.16.1.2"}], } } port1 = VTM.create_resource(api.create_port(port1json)) LOG.debug(port1) port2json = { "port": { "name": "port2", "network_id": network["network"]["id"], "admin_state_up": True, "mac_address": "aa:bb:cc:00:00:22", "fixed_ips": [{"ip_address": "172.16.1.3"}], } } port2 = VTM.create_resource(api.create_port(port2json)) LOG.debug(port2) # Bind virtual and physical topology host1.bind_port(vm1, port1["port"]["id"]) host2.bind_port(vm2, port2["port"]["id"]) # Test ping works f1 = async_assert_that(vm2, receives("dst host %s and icmp" % vm2.get_ip(), within_sec(10))) f2 = vm1.ping4(vm2) wait_on_futures([f1, f2])