Skip to content

Commit 52ba840

Browse files
committed
vm: add destroy_vdi_by_name()
The vdi uuid changes during migration, so we use its name to identify it Signed-off-by: Gaëtan Lehmann <[email protected]>
1 parent dacabae commit 52ba840

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/vm.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import pytest
4+
35
import logging
46
import os
57
import tempfile
@@ -345,6 +347,14 @@ def destroy_vdi(self, vdi_uuid: str) -> None:
345347
super().destroy_vdi(vdi_uuid)
346348
break
347349

350+
def destroy_vdi_by_name(self, name: str) -> None:
351+
for vdi in self.vdis:
352+
if vdi.name() == name:
353+
self.vdis.remove(vdi)
354+
super().destroy_vdi(vdi.uuid)
355+
return
356+
raise pytest.fail(f"No VDI named '{name}' in vm {self.uuid}")
357+
348358
def create_vdis_list(self) -> None:
349359
""" Used to redo the VDIs list of the VM when reverting a snapshot. """
350360
try:

0 commit comments

Comments
 (0)