@@ -191,15 +191,15 @@ def test_net_api_put_update_pre_boot(uvm_plain):
191
191
test_microvm = uvm_plain
192
192
test_microvm .spawn ()
193
193
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 )
196
196
test_microvm .api .network .put (
197
197
iface_id = "1" , guest_mac = "06:00:00:00:00:01" , host_dev_name = tap1 .name
198
198
)
199
199
200
200
# 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 )
203
203
test_microvm .api .network .put (
204
204
iface_id = "2" , guest_mac = "07:00:00:00:00:01" , host_dev_name = tap2 .name
205
205
)
@@ -209,28 +209,26 @@ def test_net_api_put_update_pre_boot(uvm_plain):
209
209
expected_msg = f"The MAC address is already in use: { guest_mac } "
210
210
with pytest .raises (RuntimeError , match = expected_msg ):
211
211
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
213
213
)
214
214
215
215
# Updates to a network interface with an available MAC are allowed.
216
216
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"
218
218
)
219
219
220
220
# Updates to a network interface with an unavailable name are not allowed.
221
221
expected_msg = "Could not create the network device"
222
222
with pytest .raises (RuntimeError , match = expected_msg ):
223
223
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"
225
225
)
226
226
227
227
# 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 )
232
230
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"
234
232
)
235
233
236
234
@@ -266,7 +264,7 @@ def test_api_mmds_config(uvm_plain):
266
264
test_microvm .api .mmds_config .put (network_interfaces = ["foo" ])
267
265
268
266
# 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 )
270
268
test_microvm .api .network .put (
271
269
iface_id = "1" , guest_mac = "06:00:00:00:00:01" , host_dev_name = tap .name
272
270
)
@@ -487,7 +485,7 @@ def test_api_put_update_post_boot(uvm_plain, io_engine):
487
485
488
486
iface_id = "1"
489
487
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 )
491
489
492
490
test_microvm .api .network .put (
493
491
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):
595
593
# Test network with tx bw rate-limiting.
596
594
iface_id = "1"
597
595
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 )
599
597
600
598
test_microvm .api .network .put (
601
599
iface_id = iface_id ,
@@ -607,7 +605,7 @@ def test_rate_limiters_api_config(uvm_plain, io_engine):
607
605
# Test network with rx bw rate-limiting.
608
606
iface_id = "2"
609
607
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 )
611
609
test_microvm .api .network .put (
612
610
iface_id = iface_id ,
613
611
guest_mac = "06:00:00:00:00:02" ,
@@ -618,7 +616,7 @@ def test_rate_limiters_api_config(uvm_plain, io_engine):
618
616
# Test network with tx and rx bw and ops rate-limiting.
619
617
iface_id = "3"
620
618
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 )
622
620
test_microvm .api .network .put (
623
621
iface_id = iface_id ,
624
622
guest_mac = "06:00:00:00:00:03" ,
@@ -665,7 +663,7 @@ def test_api_patch_pre_boot(uvm_plain, io_engine):
665
663
666
664
iface_id = "1"
667
665
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 )
669
667
test_microvm .api .network .put (
670
668
iface_id = iface_id , host_dev_name = tap1 .name , guest_mac = "06:00:00:00:00:01"
671
669
)
@@ -714,7 +712,7 @@ def test_negative_api_patch_post_boot(uvm_plain, io_engine):
714
712
715
713
iface_id = "1"
716
714
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 )
718
716
test_microvm .api .network .put (
719
717
iface_id = iface_id , host_dev_name = tap1 .name , guest_mac = "06:00:00:00:00:01"
720
718
)
@@ -1245,7 +1243,7 @@ def test_get_full_config(uvm_plain):
1245
1243
# Add a net device.
1246
1244
iface_id = "1"
1247
1245
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 )
1249
1247
guest_mac = "06:00:00:00:00:01"
1250
1248
tx_rl = {
1251
1249
"bandwidth" : {"size" : 1000000 , "refill_time" : 100 , "one_time_burst" : None },
0 commit comments