mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-25 23:21:45 +03:00
config: Move constants into vmmConfig class
This commit is contained in:
parent
18a82b8ea3
commit
36040e3f00
@ -29,20 +29,6 @@ import virtinst
|
||||
from virtManager.keyring import vmmKeyring
|
||||
from virtManager.secret import vmmSecret
|
||||
|
||||
CONSOLE_KEYGRAB_NEVER = 0
|
||||
CONSOLE_KEYGRAB_FULLSCREEN = 1
|
||||
CONSOLE_KEYGRAB_MOUSEOVER = 2
|
||||
|
||||
STATS_CPU = 0
|
||||
STATS_DISK = 1
|
||||
STATS_NETWORK = 2
|
||||
|
||||
DEFAULT_XEN_IMAGE_DIR = "/var/lib/xen/images"
|
||||
DEFAULT_XEN_SAVE_DIR = "/var/lib/xen/dump"
|
||||
|
||||
DEFAULT_VIRT_IMAGE_DIR = "/var/lib/libvirt/images"
|
||||
DEFAULT_VIRT_SAVE_DIR = "/var/lib/libvirt"
|
||||
|
||||
running_config = None
|
||||
|
||||
class vmmConfig(object):
|
||||
@ -74,10 +60,24 @@ class vmmConfig(object):
|
||||
CONSOLE_SCALE_FULLSCREEN = 1
|
||||
CONSOLE_SCALE_ALWAYS = 2
|
||||
|
||||
CONSOLE_KEYGRAB_NEVER = 0
|
||||
CONSOLE_KEYGRAB_FULLSCREEN = 1
|
||||
CONSOLE_KEYGRAB_MOUSEOVER = 2
|
||||
|
||||
STATS_CPU = 0
|
||||
STATS_DISK = 1
|
||||
STATS_NETWORK = 2
|
||||
|
||||
_PEROBJ_FUNC_SET = 0
|
||||
_PEROBJ_FUNC_GET = 1
|
||||
_PEROBJ_FUNC_LISTEN = 2
|
||||
|
||||
DEFAULT_XEN_IMAGE_DIR = "/var/lib/xen/images"
|
||||
DEFAULT_XEN_SAVE_DIR = "/var/lib/xen/dump"
|
||||
|
||||
DEFAULT_VIRT_IMAGE_DIR = "/var/lib/libvirt/images"
|
||||
DEFAULT_VIRT_SAVE_DIR = "/var/lib/libvirt"
|
||||
|
||||
def __init__(self, appname, appversion, gconf_dir, glade_dir, icon_dir,
|
||||
data_dir):
|
||||
self.appname = appname
|
||||
@ -681,21 +681,21 @@ class vmmConfig(object):
|
||||
|
||||
def get_default_image_dir(self, connection):
|
||||
if connection.is_xen():
|
||||
return DEFAULT_XEN_IMAGE_DIR
|
||||
return self.DEFAULT_XEN_IMAGE_DIR
|
||||
|
||||
if (connection.is_qemu_session() or
|
||||
not os.access(DEFAULT_VIRT_IMAGE_DIR, os.W_OK)):
|
||||
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 DEFAULT_VIRT_IMAGE_DIR
|
||||
return self.DEFAULT_VIRT_IMAGE_DIR
|
||||
|
||||
def get_default_save_dir(self, connection):
|
||||
if connection.is_xen():
|
||||
return DEFAULT_XEN_SAVE_DIR
|
||||
elif os.access(DEFAULT_VIRT_SAVE_DIR, os.W_OK):
|
||||
return DEFAULT_VIRT_SAVE_DIR
|
||||
return self.DEFAULT_XEN_SAVE_DIR
|
||||
elif os.access(self.DEFAULT_VIRT_SAVE_DIR, os.W_OK):
|
||||
return self.DEFAULT_VIRT_SAVE_DIR
|
||||
else:
|
||||
return os.getcwd()
|
||||
|
||||
|
@ -23,7 +23,6 @@ import gtk
|
||||
|
||||
import logging
|
||||
|
||||
import virtManager.config as cfg
|
||||
import virtManager.uihelpers as uihelpers
|
||||
from virtManager.connection import vmmConnection
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
@ -148,11 +147,11 @@ class vmmManager(vmmGObjectUI):
|
||||
|
||||
self.window.signal_autoconnect({
|
||||
"on_menu_view_cpu_usage_activate": (self.toggle_stats_visible,
|
||||
cfg.STATS_CPU),
|
||||
self.config.STATS_CPU),
|
||||
"on_menu_view_disk_io_activate" : (self.toggle_stats_visible,
|
||||
cfg.STATS_DISK),
|
||||
self.config.STATS_DISK),
|
||||
"on_menu_view_network_traffic_activate": (self.toggle_stats_visible,
|
||||
cfg.STATS_NETWORK),
|
||||
self.config.STATS_NETWORK),
|
||||
|
||||
"on_vm_manager_delete_event": self.close,
|
||||
"on_vmm_manager_configure_event": self.window_resized,
|
||||
@ -192,9 +191,9 @@ class vmmManager(vmmGObjectUI):
|
||||
|
||||
# Initialize stat polling columns based on global polling
|
||||
# preferences (we want signal handlers for this)
|
||||
for typ, init_val in \
|
||||
[(cfg.STATS_DISK, self.config.get_stats_enable_disk_poll()),
|
||||
(cfg.STATS_NETWORK, self.config.get_stats_enable_net_poll())]:
|
||||
for typ, init_val in [
|
||||
(self.config.STATS_DISK, self.config.get_stats_enable_disk_poll()),
|
||||
(self.config.STATS_NETWORK, self.config.get_stats_enable_net_poll())]:
|
||||
self.enable_polling(None, None, init_val, typ)
|
||||
|
||||
self.engine.connect("connection-added", self._add_connection)
|
||||
@ -293,10 +292,10 @@ class vmmManager(vmmGObjectUI):
|
||||
# that disable the associated vmlist widgets if reporting is disabled
|
||||
self.add_gconf_handle(
|
||||
self.config.on_stats_enable_disk_poll_changed(self.enable_polling,
|
||||
cfg.STATS_DISK))
|
||||
self.config.STATS_DISK))
|
||||
self.add_gconf_handle(
|
||||
self.config.on_stats_enable_net_poll_changed(self.enable_polling,
|
||||
cfg.STATS_NETWORK))
|
||||
self.config.STATS_NETWORK))
|
||||
|
||||
|
||||
self.window.get_widget("menu_view_stats_cpu").set_active(
|
||||
@ -1092,9 +1091,9 @@ class vmmManager(vmmGObjectUI):
|
||||
return cmp(model.get_value(iter1, ROW_HANDLE).network_traffic_rate(), model.get_value(iter2, ROW_HANDLE).network_traffic_rate())
|
||||
|
||||
def enable_polling(self, ignore1, ignore2, conf_entry, userdata):
|
||||
if userdata == cfg.STATS_DISK:
|
||||
if userdata == self.config.STATS_DISK:
|
||||
widgn = "menu_view_stats_disk"
|
||||
elif userdata == cfg.STATS_NETWORK:
|
||||
elif userdata == self.config.STATS_NETWORK:
|
||||
widgn = "menu_view_stats_network"
|
||||
widget = self.window.get_widget(widgn)
|
||||
|
||||
@ -1132,9 +1131,9 @@ class vmmManager(vmmGObjectUI):
|
||||
def toggle_stats_visible(self, src, stats_id):
|
||||
visible = src.get_active()
|
||||
set_stats = {
|
||||
cfg.STATS_CPU: self.config.set_vmlist_cpu_usage_visible,
|
||||
cfg.STATS_DISK: self.config.set_vmlist_disk_io_visible,
|
||||
cfg.STATS_NETWORK: self.config.set_vmlist_network_traffic_visible,
|
||||
self.config.STATS_CPU: self.config.set_vmlist_cpu_usage_visible,
|
||||
self.config.STATS_DISK: self.config.set_vmlist_disk_io_visible,
|
||||
self.config.STATS_NETWORK: self.config.set_vmlist_network_traffic_visible,
|
||||
}
|
||||
set_stats[stats_id](visible)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user