[virt-manager PATCH 01/12] util: Add {make, get}_unattended_cache_dir()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The "make" method will help to create a "unattended" dir based on the
virt-install process id, so we can store unattended installations
related files without the possibility of another process overwritting
the files.

The "get" method will help to clean up the dirs created by the "make"
method.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 virtinst/util.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/virtinst/util.py b/virtinst/util.py
index 7219d49f..d8b19b7e 100644
--- a/virtinst/util.py
+++ b/virtinst/util.py
@@ -271,6 +271,19 @@ def get_cache_dir():
     return os.path.join(ret, "virt-manager")
 
 
+def get_unattended_cache_dir():
+    pid = str(os.getpid())
+    return os.path.join(get_cache_dir(), pid, "unattended")
+
+
+def make_unattended_cache_dir():
+    scratch = get_unattended_cache_dir()
+    if not os.path.exists(scratch):
+        os.makedirs(scratch, 0o751)
+
+    return scratch
+
+
 def register_libvirt_error_handler():
     """
     Ignore libvirt error reporting, we just use exceptions
-- 
2.21.0

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list




[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux