Skip to content

Commit 5de806e

Browse files
authored
Fix fixture vm_with_vbds (#278)
It didn't delete the VBD so `vm.destroy()` would destroy the VDI that should have been cleanup by the fixture `vdis` instead. Signed-off-by: Damien Thenot <[email protected]>
1 parent 5285223 commit 5de806e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

tests/snapshot/conftest.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@ def _make_vdi(name):
2121

2222
@pytest.fixture(scope='module')
2323
def vm_with_vbds(host, vdis, imported_vm):
24-
def _make_vbd(host, device, vdi):
25-
host.xe('vbd-create', {
26-
'vm-uuid': vm.uuid, 'mode': 'RW', 'type': 'Disk', 'device': device, 'vdi-uuid': vdi
27-
})
28-
24+
vbds = []
2925
vm = imported_vm
3026
vdi_A, vdi_B, vdi_C = vdis
3127

32-
for name, vdi in [("xvdn", vdi_A), ("xvdo", vdi_B), ("xvdp", vdi_C)]:
33-
_make_vbd(host, name, vdi)
28+
for device, vdi in [("xvdn", vdi_A), ("xvdo", vdi_B), ("xvdp", vdi_C)]:
29+
vbd_uuid = host.xe('vbd-create', {
30+
'vm-uuid': vm.uuid, 'mode': 'RW', 'type': 'Disk', 'device': device, 'vdi-uuid': vdi
31+
})
32+
vbds.append(vbd_uuid)
3433

3534
vm.start()
35+
3636
yield vm
37+
38+
vm.shutdown(verify=True)
39+
for vbd_uuid in vbds:
40+
host.xe("vbd-destroy", {"uuid": vbd_uuid})

0 commit comments

Comments
 (0)