66
77from libs .net .traffic_generator import TcpServer , is_tcp_connection
88from libs .net .traffic_generator import VMTcpClient as TcpClient
9- from libs .net .vmspec import lookup_iface_status , lookup_primary_network
9+ from libs .net .vmspec import lookup_iface_status_ip , lookup_primary_network
1010from libs .vm import affinity
1111from tests .network .libs .ip import random_ipv4_address
1212from tests .network .libs .vm_factory import udn_vm
@@ -85,7 +85,9 @@ def server(vmb_udn):
8585def client (vma_udn , vmb_udn ):
8686 with TcpClient (
8787 vm = vma_udn ,
88- server_ip = lookup_iface_status (vm = vmb_udn , iface_name = lookup_primary_network (vm = vmb_udn ).name )[IP_ADDRESS ],
88+ server_ip = str (
89+ lookup_iface_status_ip (vm = vmb_udn , iface_name = lookup_primary_network (vm = vmb_udn ).name , ip_family = 4 )
90+ ),
8991 server_port = SERVER_PORT ,
9092 ) as client :
9193 assert client .is_running ()
@@ -98,7 +100,7 @@ class TestPrimaryUdn:
98100 @pytest .mark .polarion ("CNV-11624" )
99101 @pytest .mark .single_nic
100102 def test_ip_address_in_running_vm_matches_udn_subnet (self , namespaced_layer2_user_defined_network , vma_udn ):
101- ip = lookup_iface_status ( vm = vma_udn , iface_name = lookup_primary_network (vm = vma_udn ).name )[ IP_ADDRESS ]
103+ ip = str ( lookup_iface_status_ip ( vm = vma_udn , iface_name = lookup_primary_network (vm = vma_udn ).name , ip_family = 4 ))
102104 (subnet ,) = namespaced_layer2_user_defined_network .subnets
103105 assert ipaddress .ip_address (ip ) in ipaddress .ip_network (subnet ), (
104106 f"The VM's primary network IP address ({ ip } ) is not in the UDN defined subnet ({ subnet } )"
@@ -107,14 +109,14 @@ def test_ip_address_in_running_vm_matches_udn_subnet(self, namespaced_layer2_use
107109 @pytest .mark .polarion ("CNV-11674" )
108110 @pytest .mark .single_nic
109111 def test_ip_address_is_preserved_after_live_migration (self , vma_udn ):
110- ip_before_migration = lookup_iface_status ( vm = vma_udn , iface_name = lookup_primary_network ( vm = vma_udn ). name )[
111- IP_ADDRESS
112- ]
112+ ip_before_migration = str (
113+ lookup_iface_status_ip ( vm = vma_udn , iface_name = lookup_primary_network ( vm = vma_udn ). name , ip_family = 4 )
114+ )
113115 assert ip_before_migration
114116 migrate_vm_and_verify (vm = vma_udn )
115- ip_after_migration = lookup_iface_status ( vm = vma_udn , iface_name = lookup_primary_network ( vm = vma_udn ). name )[
116- IP_ADDRESS
117- ]
117+ ip_after_migration = str (
118+ lookup_iface_status_ip ( vm = vma_udn , iface_name = lookup_primary_network ( vm = vma_udn ). name , ip_family = 4 )
119+ )
118120 assert ip_before_migration == ip_after_migration , (
119121 f"The IP address { ip_before_migration } was not preserved during live migration. "
120122 f"IP after migration: { ip_after_migration } ."
@@ -123,13 +125,15 @@ def test_ip_address_is_preserved_after_live_migration(self, vma_udn):
123125 @pytest .mark .polarion ("CNV-11434" )
124126 @pytest .mark .single_nic
125127 def test_vm_egress_connectivity (self , vmb_udn ):
126- assert lookup_iface_status ( vm = vmb_udn , iface_name = lookup_primary_network (vm = vmb_udn ).name )[ IP_ADDRESS ]
128+ assert str ( lookup_iface_status_ip ( vm = vmb_udn , iface_name = lookup_primary_network (vm = vmb_udn ).name , ip_family = 4 ))
127129 vmb_udn .console (commands = [f"ping -c 3 { PUBLIC_DNS_SERVER_IP } " ], timeout = TIMEOUT_1MINUTE )
128130
129131 @pytest .mark .polarion ("CNV-11418" )
130132 @pytest .mark .single_nic
131133 def test_basic_connectivity_between_udn_vms (self , vma_udn , vmb_udn ):
132- target_vm_ip = lookup_iface_status (vm = vmb_udn , iface_name = lookup_primary_network (vm = vmb_udn ).name )[IP_ADDRESS ]
134+ target_vm_ip = str (
135+ lookup_iface_status_ip (vm = vmb_udn , iface_name = lookup_primary_network (vm = vmb_udn ).name , ip_family = 4 )
136+ )
133137 vma_udn .console (commands = [f"ping -c 3 { target_vm_ip } " ], timeout = TIMEOUT_1MIN )
134138
135139 @pytest .mark .polarion ("CNV-11427" )
0 commit comments