ubuntu-bugcontrol team mailing list archive
-
ubuntu-bugcontrol team
-
Mailing list archive
-
Message #04669
[Merge] ~jslarraz/ubuntu-qa-tools:use-vol-delete into ubuntu-qa-tools:master
Jorge Sancho Larraz has proposed merging ~jslarraz/ubuntu-qa-tools:use-vol-delete into ubuntu-qa-tools:master.
Commit message:
uvt: use vol-delete in remove_preseeded_iso
Requested reviews:
Ubuntu Bug Control (ubuntu-bugcontrol)
For more details, see:
https://code.launchpad.net/~jslarraz/ubuntu-qa-tools/+git/ubuntu-qa-tools/+merge/460672
currently remove_preseeded_iso uses os.unlink() to remove the preseeded iso existent from a previous vm creation. Calling virt-install will change preseeded_iso file owner and group to libvbirt-qemu and kvm respectively. Thus, it will be more correct to use virsh vol-delete to remove it.
In case an error occurs between the generation of the preseeded_iso and the call to virt-install (or early in the execution of virt-install), the preseeded iso would remain being owned by the user. Thus, we still want to use os.unlink in case virsh vol-delete does not complete succesfully
--
Your team Ubuntu Bug Control is requested to review the proposed merge of ~jslarraz/ubuntu-qa-tools:use-vol-delete into ubuntu-qa-tools:master.
diff --git a/vm-tools/uvt b/vm-tools/uvt
index c7b0143..99b9122 100755
--- a/vm-tools/uvt
+++ b/vm-tools/uvt
@@ -1806,7 +1806,7 @@ def create_preseeded_iso(release_iso, iso_type, vm_name, release,
release_iso_preseed_path = os.path.join(uvt_conf['vm_dir_iso_cache'], release_iso_preseed)
if os.path.exists(release_iso_preseed_path):
- os.unlink(release_iso_preseed_path)
+ remove_preseeded_iso(release_iso, vm_name)
print("Creating preseeded iso...")
# Create a temp dir to store the iso contents
@@ -1892,7 +1892,17 @@ def remove_preseeded_iso(release_iso, vm_name):
release_iso_preseed_path = os.path.join(uvt_conf['vm_dir_iso_cache'], release_iso_preseed)
if os.path.exists(release_iso_preseed_path):
+ rc, out = runcmd(["virsh", "--connect", uvt_conf["vm_connect"],
+ "vol-delete", release_iso_preseed_path])
+ if rc == 0:
+ return True
+ try:
os.unlink(release_iso_preseed_path)
+ return True
+ except:
+ print("Error removing preseeded iso: " + release_iso_preseed_path)
+ print("Please, remove it manually to continue")
+ exit(-1)
def create_preseed_file(temp_dir, iso_type, release, release_num, vm_name):
'''Creates an appropriate preseed file'''
Follow ups