Make use of virtinst's new 'support' module, instead of duplicating checks.
This commit is contained in:
parent
1bb8e87df6
commit
1d592160d5
|
@ -27,7 +27,6 @@ import gtk
|
|||
import gtk.gdk
|
||||
import gtk.glade
|
||||
|
||||
import libvirt
|
||||
import virtinst
|
||||
from virtinst import VirtualCharDevice, VirtualDevice, VirtualVideoDevice
|
||||
|
||||
|
@ -417,7 +416,9 @@ class vmmAddHardware(gobject.GObject):
|
|||
_("Connection does not support host device "
|
||||
"enumeration"))
|
||||
add_hw_option("Video", "video-display", PAGE_VIDEO,
|
||||
libvirt.getVersion() > 6005,
|
||||
virtinst.support.check_conn_support(
|
||||
self.vm.get_connection().vmm,
|
||||
virtinst.support.SUPPORT_CONN_DOMAIN_VIDEO),
|
||||
_("Libvirt version does not support video devices."))
|
||||
|
||||
self.window.get_widget("hardware-type").set_active(0)
|
||||
|
|
|
@ -136,7 +136,8 @@ class vmmConnection(gobject.GObject):
|
|||
return bool(self.get_uri_hostname() == "localhost")
|
||||
|
||||
def get_qualified_hostname(self):
|
||||
if util.libvirt_support_and_check(self.vmm, "getHostname"):
|
||||
if virtinst.support.check_conn_support(self.vmm,
|
||||
virtinst.support.SUPPORT_CONN_GETHOSTNAME):
|
||||
return self.vmm.getHostname()
|
||||
|
||||
uri_hostname = self.get_uri_hostname()
|
||||
|
|
|
@ -845,7 +845,7 @@ class vmmDomain(gobject.GObject):
|
|||
rx += io[0]
|
||||
tx += io[4]
|
||||
except libvirt.libvirtError, err:
|
||||
if err.get_error_code() == libvirt.VIR_ERR_NO_SUPPORT:
|
||||
if virtinst.support.is_error_nosupport(err):
|
||||
logging.debug("Net stats not supported: %s" % err)
|
||||
self._stats_net_supported = False
|
||||
else:
|
||||
|
@ -874,7 +874,7 @@ class vmmDomain(gobject.GObject):
|
|||
rd += io[1]
|
||||
wr += io[3]
|
||||
except libvirt.libvirtError, err:
|
||||
if err.get_error_code() == libvirt.VIR_ERR_NO_SUPPORT:
|
||||
if virtinst.support.is_error_nosupport():
|
||||
logging.debug("Disk stats not supported: %s" % err)
|
||||
self._stats_disk_supported = False
|
||||
else:
|
||||
|
|
|
@ -20,11 +20,14 @@
|
|||
|
||||
import gobject
|
||||
import gtk
|
||||
import libvirt
|
||||
|
||||
import logging
|
||||
import traceback
|
||||
import threading
|
||||
|
||||
import libvirt
|
||||
import virtinst
|
||||
|
||||
from virtManager.about import vmmAbout
|
||||
from virtManager.netdevhelper import vmmNetDevHelper
|
||||
from virtManager.clone import vmmCloneVM
|
||||
|
@ -74,7 +77,7 @@ class vmmEngine(gobject.GObject):
|
|||
|
||||
self._tick_thread = None
|
||||
self._tick_thread_slow = False
|
||||
self._libvirt_support_threading = (libvirt.getVersion() >= 6000)
|
||||
self._libvirt_support_threading = virtinst.support.support_threading()
|
||||
if not self._libvirt_support_threading:
|
||||
logging.debug("Libvirt doesn't support threading, skipping.")
|
||||
|
||||
|
@ -87,7 +90,7 @@ class vmmEngine(gobject.GObject):
|
|||
self.init_systray()
|
||||
|
||||
self.config.on_stats_update_interval_changed(self.reschedule_timer)
|
||||
self.config.on_view_system_tray_changed(self.system_tray_changed)
|
||||
self.config.on_view_system_tray_changed(self.system_tray_changed)
|
||||
|
||||
self.schedule_timer()
|
||||
self.load_stored_uris()
|
||||
|
|
|
@ -197,7 +197,7 @@ def _dup_all_conn(config, conn, libconn, return_conn_class):
|
|||
# between instances
|
||||
return return_conn_class and conn or vmm
|
||||
|
||||
if int(libvirt.getVersion()) >= 6000:
|
||||
if virtinst.support.support_threading():
|
||||
# Libvirt 0.6.0 implemented client side request threading: this
|
||||
# removes the need to actually duplicate the connection.
|
||||
return return_conn_class and conn or vmm
|
||||
|
@ -244,24 +244,3 @@ def idle_emit(self, signal, *args):
|
|||
"""
|
||||
self.emit(signal, *args)
|
||||
return False
|
||||
|
||||
def libvirt_support_and_check(libvirtobj, funcname, funcargs=()):
|
||||
"""
|
||||
Try to determine if function 'funcname' is support for 'libvirtobj' (could
|
||||
be virDomain), and test the function with passed args 'funcargs'
|
||||
"""
|
||||
try:
|
||||
if not hasattr(libvirtobj, funcname):
|
||||
return False
|
||||
|
||||
try:
|
||||
func = getattr(libvirtobj, funcname)
|
||||
func(*funcargs)
|
||||
except libvirt.libvirtError, e:
|
||||
if e.get_error_code() == libvirt.VIR_ERR_NO_SUPPORT:
|
||||
return False
|
||||
except Exception, e:
|
||||
logging.debug("Error testing libvirt command '%s': %s" %
|
||||
(funcname, str(e)))
|
||||
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue