create: Auto-generate fs path if not provided

Use default place to store file systems of bootstraped containers.

If the current user has effective UID 0 use:
    /var/lib/libvirt/filesystems/<container-name>

otherwise use:
    ~/.local/share/libvirt/filesystems/<container-name>
This commit is contained in:
Radostin Stoyanov 2017-07-24 09:26:45 +01:00 committed by Cole Robinson
parent c5264a2390
commit 89e5783cad

View File

@ -1653,6 +1653,17 @@ class vmmCreate(vmmGObjectUI):
enable_src = self.widget("install-oscontainer-bootstrap").get_active()
self.widget("install-oscontainer-source").set_sensitive(enable_src)
# Auto-generate a path if not specified
if enable_src and not self.widget("install-oscontainer-fs").get_text():
if os.geteuid() == 0:
fs_dir = ['/var/lib/libvirt/filesystems/']
else:
fs_dir = [os.environ['HOME'],
'.local/share/libvirt/filesystems/']
fs = fs_dir + [self._generate_default_name(None, None)]
self.widget("install-oscontainer-fs").set_text(os.path.join(*fs))
########################
# Misc helper routines #