@@ -329,6 +329,40 @@ def sr_disk_for_all_hosts(pytestconfig, request, host):
329
329
logging .info (f">> Disk or block device { disk } is present and free on all pool members" )
330
330
yield candidates [0 ]
331
331
332
+ @pytest .fixture (scope = 'session' )
333
+ def sr_disks_for_all_hosts (pytestconfig , request , host ):
334
+ disks = pytestconfig .getoption ("sr_disk" )
335
+ assert len (disks ) > 0 , "This test requires at least one --sr-disk parameter"
336
+ # Fetch available disks on the master host
337
+ master_disks = host .available_disks ()
338
+ assert len (master_disks ) > 0 , "a free disk device is required on the master host"
339
+
340
+ if "auto" in disks :
341
+ candidates = list (master_disks )
342
+ else :
343
+ # Validate that all specified disks exist on the master host
344
+ for disk in disks :
345
+ assert disk in master_disks , \
346
+ f"Disk or block device { disk } is either not present or already used on the master host"
347
+ candidates = list (disks )
348
+
349
+ # Check if all disks are available on all hosts in the pool
350
+ for h in host .pool .hosts [1 :]:
351
+ other_disks = h .available_disks ()
352
+ candidates = [d for d in candidates if d in other_disks ]
353
+
354
+ if "auto" in disks :
355
+ # Automatically select disks if "auto" is passed
356
+ assert len (candidates ) > 0 , \
357
+ f"Free disk devices are required on all pool members. Pool master has: { ' ' .join (master_disks )} ."
358
+ logging .info (">> Using free disk device(s) on all pool hosts: %s." , candidates )
359
+ else :
360
+ # Ensure specified disks are free on all hosts
361
+ assert len (candidates ) == len (disks ), \
362
+ f"Some specified disks ({ ', ' .join (disks )} ) are not free or available on all hosts."
363
+ logging .info (">> Disk(s) %s are present and free on all pool members" , candidates )
364
+ yield candidates
365
+
332
366
@pytest .fixture (scope = 'module' )
333
367
def vm_ref (request ):
334
368
ref = request .param
0 commit comments