Skip to content

Commit

Permalink
Clean the env before vm clone
Browse files Browse the repository at this point in the history
There could be scenario that existing VMs with the same name which block
the following operations. Remove these VMs to clean the env.

Signed-off-by: Yalan Zhang <yalzhang@redhat.com>
  • Loading branch information
yalzhang committed Dec 26, 2024
1 parent 05c945d commit 0365ea1
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,14 @@ def transfer_to_transient(per_guest_name):
utils_path.find_command("virt-clone")
except utils_path.CmdNotFoundError:
test.cancel("No virt-clone command found.")

# Clone additional vms: avocado-vt-vm2, avocado-vt-vm3.....
# Before clone, make sure there is no existing VMs
all_vm_list = virsh.dom_list('--name --all').stdout.strip().splitlines()
logging.debug("All vm on the host: %s", all_vm_list)
for vm_i in all_vm_list:
if vm_i.startswith("main_vm_name") and vm_i != "main_vm_name":
logging.debug("Clean the env by remove the guest : %s", vm_i)
virsh.remove_domain(vm_i, "--remove-all-storage --nvram")
for i in range(additional_vms):
guest_name = ("%s" % main_vm_name[:-1])+("%s" % str(i+2))
logging.debug("guest_name : %s", guest_name)
Expand Down

0 comments on commit 0365ea1

Please sign in to comment.