|
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,24 @@ 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]] |
| 344 | + ) -> Generator[dict[Host, list[DiskDevName]]]: |
| 345 | + ret = {host: [disk for disk in disks if host.disk_is_available(disk)] |
| 346 | + for host, disks in disks.items() |
| 347 | + } |
| 348 | + logging.debug("available disks collected: %s", {host.hostname_or_ip: value for host, value in ret.items()}) |
| 349 | + yield ret |
| 350 | + |
332 | 351 | @pytest.fixture(scope='session')
|
333 | 352 | def sr_disk(pytestconfig, host):
|
334 | 353 | """
|
@@ -412,6 +431,13 @@ def sr_disk_for_all_hosts(pytestconfig, request, host):
|
412 | 431 | logging.info(f">> Disk or block device {disk} is present and free on all pool members")
|
413 | 432 | yield candidates[0]
|
414 | 433 |
|
| 434 | +@pytest.fixture(scope='session') |
| 435 | +def pool_with_unused_disk(host: Host, unused_disks: dict[Host, list[DiskDevName]]) -> Pool: |
| 436 | + for h in host.pool.hosts: |
| 437 | + assert h in unused_disks |
| 438 | + assert unused_disks[h], f"host {h} does not have any unused disk" |
| 439 | + return host.pool |
| 440 | + |
415 | 441 | @pytest.fixture(scope='session')
|
416 | 442 | def sr_disks_for_all_hosts(pytestconfig, request, host):
|
417 | 443 | """
|
|
0 commit comments