@@ -191,15 +191,15 @@ def test_net_api_put_update_pre_boot(uvm_plain):
191191 test_microvm = uvm_plain
192192 test_microvm .spawn ()
193193
194- first_if_name = "first_tap "
195- tap1 = net_tools .Tap (first_if_name , test_microvm .netns . id )
194+ tap1name = test_microvm . id [: 8 ] + "tap1 "
195+ tap1 = net_tools .Tap (tap1name , test_microvm .netns )
196196 test_microvm .api .network .put (
197197 iface_id = "1" , guest_mac = "06:00:00:00:00:01" , host_dev_name = tap1 .name
198198 )
199199
200200 # Adding new network interfaces is allowed.
201- second_if_name = "second_tap "
202- tap2 = net_tools .Tap (second_if_name , test_microvm .netns . id )
201+ tap2name = test_microvm . id [: 8 ] + "tap2 "
202+ tap2 = net_tools .Tap (tap2name , test_microvm .netns )
203203 test_microvm .api .network .put (
204204 iface_id = "2" , guest_mac = "07:00:00:00:00:01" , host_dev_name = tap2 .name
205205 )
@@ -209,28 +209,26 @@ def test_net_api_put_update_pre_boot(uvm_plain):
209209 expected_msg = f"The MAC address is already in use: { guest_mac } "
210210 with pytest .raises (RuntimeError , match = expected_msg ):
211211 test_microvm .api .network .put (
212- iface_id = "2" , host_dev_name = second_if_name , guest_mac = guest_mac
212+ iface_id = "2" , host_dev_name = tap2name , guest_mac = guest_mac
213213 )
214214
215215 # Updates to a network interface with an available MAC are allowed.
216216 test_microvm .api .network .put (
217- iface_id = "2" , host_dev_name = second_if_name , guest_mac = "08:00:00:00:00:01"
217+ iface_id = "2" , host_dev_name = tap2name , guest_mac = "08:00:00:00:00:01"
218218 )
219219
220220 # Updates to a network interface with an unavailable name are not allowed.
221221 expected_msg = "Could not create the network device"
222222 with pytest .raises (RuntimeError , match = expected_msg ):
223223 test_microvm .api .network .put (
224- iface_id = "1" , host_dev_name = second_if_name , guest_mac = "06:00:00:00:00:01"
224+ iface_id = "1" , host_dev_name = tap2name , guest_mac = "06:00:00:00:00:01"
225225 )
226226
227227 # Updates to a network interface with an available name are allowed.
228- iface_id = "1"
229- tapname = test_microvm .id [:8 ] + "tap" + iface_id
230-
231- tap3 = net_tools .Tap (tapname , test_microvm .netns .id )
228+ tap3name = test_microvm .id [:8 ] + "tap3"
229+ tap3 = net_tools .Tap (tap3name , test_microvm .netns )
232230 test_microvm .api .network .put (
233- iface_id = iface_id , host_dev_name = tap3 .name , guest_mac = "06:00:00:00:00:01"
231+ iface_id = "3" , host_dev_name = tap3 .name , guest_mac = "06:00:00:00:00:01"
234232 )
235233
236234
@@ -266,7 +264,7 @@ def test_api_mmds_config(uvm_plain):
266264 test_microvm .api .mmds_config .put (network_interfaces = ["foo" ])
267265
268266 # Attach network interface.
269- tap = net_tools .Tap ("tap1" , test_microvm .netns . id )
267+ tap = net_tools .Tap (f "tap1- { test_microvm . id [: 6 ] } " , test_microvm .netns )
270268 test_microvm .api .network .put (
271269 iface_id = "1" , guest_mac = "06:00:00:00:00:01" , host_dev_name = tap .name
272270 )
@@ -487,7 +485,7 @@ def test_api_put_update_post_boot(uvm_plain, io_engine):
487485
488486 iface_id = "1"
489487 tapname = test_microvm .id [:8 ] + "tap" + iface_id
490- tap1 = net_tools .Tap (tapname , test_microvm .netns . id )
488+ tap1 = net_tools .Tap (tapname , test_microvm .netns )
491489
492490 test_microvm .api .network .put (
493491 iface_id = iface_id , host_dev_name = tap1 .name , guest_mac = "06:00:00:00:00:01"
@@ -595,7 +593,7 @@ def test_rate_limiters_api_config(uvm_plain, io_engine):
595593 # Test network with tx bw rate-limiting.
596594 iface_id = "1"
597595 tapname = test_microvm .id [:8 ] + "tap" + iface_id
598- tap1 = net_tools .Tap (tapname , test_microvm .netns . id )
596+ tap1 = net_tools .Tap (tapname , test_microvm .netns )
599597
600598 test_microvm .api .network .put (
601599 iface_id = iface_id ,
@@ -607,7 +605,7 @@ def test_rate_limiters_api_config(uvm_plain, io_engine):
607605 # Test network with rx bw rate-limiting.
608606 iface_id = "2"
609607 tapname = test_microvm .id [:8 ] + "tap" + iface_id
610- tap2 = net_tools .Tap (tapname , test_microvm .netns . id )
608+ tap2 = net_tools .Tap (tapname , test_microvm .netns )
611609 test_microvm .api .network .put (
612610 iface_id = iface_id ,
613611 guest_mac = "06:00:00:00:00:02" ,
@@ -618,7 +616,7 @@ def test_rate_limiters_api_config(uvm_plain, io_engine):
618616 # Test network with tx and rx bw and ops rate-limiting.
619617 iface_id = "3"
620618 tapname = test_microvm .id [:8 ] + "tap" + iface_id
621- tap3 = net_tools .Tap (tapname , test_microvm .netns . id )
619+ tap3 = net_tools .Tap (tapname , test_microvm .netns )
622620 test_microvm .api .network .put (
623621 iface_id = iface_id ,
624622 guest_mac = "06:00:00:00:00:03" ,
@@ -665,7 +663,7 @@ def test_api_patch_pre_boot(uvm_plain, io_engine):
665663
666664 iface_id = "1"
667665 tapname = test_microvm .id [:8 ] + "tap" + iface_id
668- tap1 = net_tools .Tap (tapname , test_microvm .netns . id )
666+ tap1 = net_tools .Tap (tapname , test_microvm .netns )
669667 test_microvm .api .network .put (
670668 iface_id = iface_id , host_dev_name = tap1 .name , guest_mac = "06:00:00:00:00:01"
671669 )
@@ -714,7 +712,7 @@ def test_negative_api_patch_post_boot(uvm_plain, io_engine):
714712
715713 iface_id = "1"
716714 tapname = test_microvm .id [:8 ] + "tap" + iface_id
717- tap1 = net_tools .Tap (tapname , test_microvm .netns . id )
715+ tap1 = net_tools .Tap (tapname , test_microvm .netns )
718716 test_microvm .api .network .put (
719717 iface_id = iface_id , host_dev_name = tap1 .name , guest_mac = "06:00:00:00:00:01"
720718 )
@@ -1245,7 +1243,7 @@ def test_get_full_config(uvm_plain):
12451243 # Add a net device.
12461244 iface_id = "1"
12471245 tapname = test_microvm .id [:8 ] + "tap" + iface_id
1248- tap1 = net_tools .Tap (tapname , test_microvm .netns . id )
1246+ tap1 = net_tools .Tap (tapname , test_microvm .netns )
12491247 guest_mac = "06:00:00:00:00:01"
12501248 tx_rl = {
12511249 "bandwidth" : {"size" : 1000000 , "refill_time" : 100 , "one_time_burst" : None },
0 commit comments