mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-23 17:34:21 +03:00
Remove redundant 'default dir' functions
This commit is contained in:
parent
7e7c606ff7
commit
45e6cd4cac
@ -56,10 +56,7 @@ class vmmAddStorage(vmmGObjectUI):
|
||||
##########################
|
||||
|
||||
def _get_default_dir(self):
|
||||
pool = self.conn.get_default_pool()
|
||||
if pool:
|
||||
return pool.get_target_path()
|
||||
return self.config.get_default_image_dir(self.conn)
|
||||
return virtinst.StoragePool.get_default_dir(self.conn.get_backend())
|
||||
|
||||
def _get_ideal_path_info(self, name):
|
||||
path = self._get_default_dir()
|
||||
|
@ -148,10 +148,6 @@ class vmmConfig(object):
|
||||
CONSOLE_SCALE_FULLSCREEN = 1
|
||||
CONSOLE_SCALE_ALWAYS = 2
|
||||
|
||||
DEFAULT_XEN_IMAGE_DIR = "/var/lib/xen/images"
|
||||
|
||||
DEFAULT_VIRT_IMAGE_DIR = "/var/lib/libvirt/images"
|
||||
|
||||
def __init__(self, appname, CLIConfig, test_first_run=False):
|
||||
self.appname = appname
|
||||
self.appversion = CLIConfig.version
|
||||
@ -645,6 +641,7 @@ class vmmConfig(object):
|
||||
return None
|
||||
|
||||
def get_default_directory(self, conn, _type):
|
||||
ignore = conn
|
||||
key = self._get_default_dir_key(_type)
|
||||
path = None
|
||||
|
||||
@ -655,7 +652,7 @@ class vmmConfig(object):
|
||||
if (_type == self.CONFIG_DIR_IMAGE or
|
||||
_type == self.CONFIG_DIR_ISO_MEDIA or
|
||||
_type == self.CONFIG_DIR_FLOPPY_MEDIA):
|
||||
path = self.get_default_image_dir(conn)
|
||||
path = os.getcwd()
|
||||
|
||||
logging.debug("directory for type=%s returning=%s", _type, path)
|
||||
return path
|
||||
@ -668,19 +665,6 @@ class vmmConfig(object):
|
||||
logging.debug("saving directory for type=%s to %s", key, folder)
|
||||
self.conf.set("/paths/%s-default" % key, folder)
|
||||
|
||||
def get_default_image_dir(self, conn):
|
||||
if conn.is_xen():
|
||||
return self.DEFAULT_XEN_IMAGE_DIR
|
||||
|
||||
if (conn.is_qemu_session() or
|
||||
not os.access(self.DEFAULT_VIRT_IMAGE_DIR, os.W_OK)):
|
||||
return os.getcwd()
|
||||
|
||||
# Just return the default dir since the intention is that it
|
||||
# is a managed pool and the user will be able to install to it.
|
||||
return self.DEFAULT_VIRT_IMAGE_DIR
|
||||
|
||||
|
||||
# Keyring / VNC password dealings
|
||||
def get_secret_name(self, vm):
|
||||
return "vm-console-" + vm.get_uuid()
|
||||
|
@ -269,7 +269,7 @@ class VirtConverter(object):
|
||||
disk_format = None
|
||||
|
||||
if destdir is None:
|
||||
destdir = StoragePool.get_default_path(self.conn, build=not dry)
|
||||
destdir = StoragePool.get_default_dir(self.conn, build=not dry)
|
||||
|
||||
guest = self.get_guest()
|
||||
for disk in guest.get_devices("disk"):
|
||||
|
@ -232,20 +232,23 @@ class StoragePool(_StorageObject):
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get_default_path(conn, build=True):
|
||||
def get_default_dir(conn, build=False):
|
||||
"""
|
||||
Return the default storage path. If there's a 'default' pool,
|
||||
report that. If there's no default pool, return the path we would
|
||||
Return the default storage dir. If there's a 'default' pool,
|
||||
report that. If there's no default pool, return the dir we would
|
||||
use for the default.
|
||||
"""
|
||||
path = _get_default_pool_path(conn)
|
||||
if not conn.check_support(conn.SUPPORT_CONN_STORAGE):
|
||||
os.makedirs(path)
|
||||
if (not conn.is_remote() and
|
||||
not conn.check_support(conn.SUPPORT_CONN_STORAGE)):
|
||||
if build and not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
return path
|
||||
|
||||
try:
|
||||
poolobj = conn.storagePoolLookupByName("default")
|
||||
return StoragePool(conn, parsexml=poolobj.XMLDesc(0)).target_path
|
||||
for pool in conn.fetch_all_pools():
|
||||
if pool.name == "default":
|
||||
return pool.target_path
|
||||
except:
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user