|
13 | 13 | import lib.config as global_config
|
14 | 14 |
|
15 | 15 | from lib import pxe
|
| 16 | +from lib.common import DiskDevName |
16 | 17 | from lib.common import callable_marker, shortened_nodeid, prefix_object_name
|
17 | 18 | from lib.common import wait_for, vm_image, is_uuid
|
18 | 19 | from lib.common import setup_formatted_and_mounted_disk, teardown_formatted_and_mounted_disk
|
@@ -329,6 +330,23 @@ def local_sr_on_hostB1(hostB1):
|
329 | 330 | logging.info(">> local SR on hostB1 present : %s" % sr.uuid)
|
330 | 331 | yield sr
|
331 | 332 |
|
| 333 | +@pytest.fixture(scope='session') |
| 334 | +def disks(hosts: list[Host]) -> Generator[dict[Host, list[DiskDevName]], None, None]: |
| 335 | + ret = {host: host.disks() |
| 336 | + for pool_master in hosts |
| 337 | + for host in pool_master.pool.hosts |
| 338 | + } |
| 339 | + logging.debug("disks collected: %s", {host.hostname_or_ip: value for host, value in ret.items()}) |
| 340 | + yield ret |
| 341 | + |
| 342 | +@pytest.fixture(scope='session') |
| 343 | +def unused_disks(disks: dict[Host, list[DiskDevName]]) -> Generator[dict[Host, list[DiskDevName]], None, None]: |
| 344 | + ret = {host: [disk for disk in disks if host.disk_is_available(disk)] |
| 345 | + for host, disks in disks.items() |
| 346 | + } |
| 347 | + logging.debug("available disks collected: %s", {host.hostname_or_ip: value for host, value in ret.items()}) |
| 348 | + yield ret |
| 349 | + |
332 | 350 | @pytest.fixture(scope='session')
|
333 | 351 | def sr_disk(pytestconfig, host):
|
334 | 352 | disks = pytestconfig.getoption("sr_disk")
|
@@ -399,6 +417,13 @@ def sr_disk_for_all_hosts(pytestconfig, request, host):
|
399 | 417 | logging.info(f">> Disk or block device {disk} is present and free on all pool members")
|
400 | 418 | yield candidates[0]
|
401 | 419 |
|
| 420 | +@pytest.fixture(scope='session') |
| 421 | +def pool_with_unused_disk(host: Host, unused_disks: dict[Host, list[DiskDevName]]) -> Pool: |
| 422 | + for h in host.pool.hosts: |
| 423 | + assert h in unused_disks |
| 424 | + assert unused_disks[h], f"host {h} does not have any unused disk" |
| 425 | + return host.pool |
| 426 | + |
402 | 427 | @pytest.fixture(scope='session')
|
403 | 428 | def sr_disks_for_all_hosts(pytestconfig, request, host):
|
404 | 429 | """
|
|
0 commit comments