Skip to content

Commit 35db2f4

Browse files
Updated lvm_disks (lvm_disk) fixture to provision multiple disks collectively, refining vgcreate and pvcreate logic.
Signed-off-by: Rushikesh Jadhav <[email protected]>
1 parent 8b902b7 commit 35db2f4

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

tests/storage/linstor/conftest.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,34 @@
1212
LINSTOR_PACKAGE = 'xcp-ng-linstor'
1313

1414
@pytest.fixture(scope='package')
15-
def lvm_disk(host, sr_disk_for_all_hosts):
16-
device = '/dev/' + sr_disk_for_all_hosts
15+
def lvm_disks(host, sr_disks_for_all_hosts, provisioning_type):
16+
devices = [f"/dev/{disk}" for disk in sr_disks_for_all_hosts]
1717
hosts = host.pool.hosts
1818

1919
for host in hosts:
20-
try:
21-
host.ssh(['pvcreate', '-ff', '-y', device])
22-
except commands.SSHCommandFailed as e:
23-
if e.stdout.endswith('Mounted filesystem?'):
24-
host.ssh(['vgremove', '-f', GROUP_NAME, '-y'])
20+
for device in devices:
21+
try:
2522
host.ssh(['pvcreate', '-ff', '-y', device])
26-
elif e.stdout.endswith('excluded by a filter.'):
27-
host.ssh(['wipefs', '-a', device])
28-
host.ssh(['pvcreate', '-ff', '-y', device])
29-
else:
30-
raise e
23+
except commands.SSHCommandFailed as e:
24+
if e.stdout.endswith('Mounted filesystem?'):
25+
host.ssh(['vgremove', '-f', GROUP_NAME, '-y'])
26+
host.ssh(['pvcreate', '-ff', '-y', device])
27+
elif e.stdout.endswith('excluded by a filter.'):
28+
host.ssh(['wipefs', '-a', device])
29+
host.ssh(['pvcreate', '-ff', '-y', device])
30+
else:
31+
raise e
3132

32-
host.ssh(['vgcreate', GROUP_NAME, device])
33-
host.ssh(['lvcreate', '-l', '100%FREE', '-T', STORAGE_POOL_NAME])
33+
host.ssh(['vgcreate', GROUP_NAME] + devices)
34+
if provisioning_type == 'thin':
35+
host.ssh(['lvcreate', '-l', '100%FREE', '-T', STORAGE_POOL_NAME])
3436

35-
yield device
37+
yield devices
3638

3739
for host in hosts:
3840
host.ssh(['vgremove', '-f', GROUP_NAME])
39-
host.ssh(['pvremove', device])
41+
for device in devices:
42+
host.ssh(['pvremove', device])
4043

4144
@pytest.fixture(scope='package')
4245
def pool_with_linstor(hostA2, lvm_disk, pool_with_saved_yum_state):

0 commit comments

Comments
 (0)