tests/vm: avoid image presence check and removal
Python's os.rename() will silently replace an existing file, so there's no need for the extra check and removal. Reference: https://docs.python.org/3/library/os.html#os.rename Signed-off-by: Cleber Rosa <crosa@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20190613130718.3763-3-crosa@redhat.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
This commit is contained in:
parent
676d1f3e2f
commit
fcd2060e8e
@ -77,8 +77,6 @@ class CentosVM(basevm.BaseVM):
|
||||
self.ssh_root_check("systemctl enable docker")
|
||||
self.ssh_root("poweroff")
|
||||
self.wait()
|
||||
if os.path.exists(img):
|
||||
os.remove(img)
|
||||
os.rename(img_tmp, img)
|
||||
return 0
|
||||
|
||||
|
@ -36,8 +36,6 @@ class FreeBSDVM(basevm.BaseVM):
|
||||
sys.stderr.write("Extracting the image...\n")
|
||||
subprocess.check_call(["ln", "-f", cimg, img_tmp_xz])
|
||||
subprocess.check_call(["xz", "--keep", "-dvf", img_tmp_xz])
|
||||
if os.path.exists(img):
|
||||
os.remove(img)
|
||||
os.rename(img_tmp, img)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -36,8 +36,6 @@ class NetBSDVM(basevm.BaseVM):
|
||||
sys.stderr.write("Extracting the image...\n")
|
||||
subprocess.check_call(["ln", "-f", cimg, img_tmp_xz])
|
||||
subprocess.check_call(["xz", "--keep", "-dvf", img_tmp_xz])
|
||||
if os.path.exists(img):
|
||||
os.remove(img)
|
||||
os.rename(img_tmp, img)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -38,8 +38,6 @@ class OpenBSDVM(basevm.BaseVM):
|
||||
sys.stderr.write("Extracting the image...\n")
|
||||
subprocess.check_call(["ln", "-f", cimg, img_tmp_xz])
|
||||
subprocess.check_call(["xz", "--keep", "-dvf", img_tmp_xz])
|
||||
if os.path.exists(img):
|
||||
os.remove(img)
|
||||
os.rename(img_tmp, img)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -80,8 +80,6 @@ class UbuntuX86VM(basevm.BaseVM):
|
||||
self.ssh_root_check("apt-get install -y libfdt-dev flex bison")
|
||||
self.ssh_root("poweroff")
|
||||
self.wait()
|
||||
if os.path.exists(img):
|
||||
os.remove(img)
|
||||
os.rename(img_tmp, img)
|
||||
return 0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user