mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-24 21:34:47 +03:00
console: Don't require spicegtk-python, show error if not available
This commit is contained in:
parent
108f6e4b6d
commit
e9f87a0e32
@ -17,13 +17,20 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
# MA 02110-1301 USA.
|
||||
#
|
||||
import gconf
|
||||
import os
|
||||
import logging
|
||||
|
||||
import gtk
|
||||
import gconf
|
||||
|
||||
import libvirt
|
||||
import virtinst
|
||||
import logging
|
||||
|
||||
_spice_error = None
|
||||
try:
|
||||
import SpiceClientGtk as spice_ignore
|
||||
except Exception, _spice_error:
|
||||
logging.debug("Error importing spice: %s" % _spice_error)
|
||||
|
||||
from virtManager.keyring import vmmKeyring
|
||||
from virtManager.secret import vmmSecret
|
||||
@ -157,6 +164,15 @@ class vmmConfig(object):
|
||||
def get_data_dir(self):
|
||||
return self.data_dir
|
||||
|
||||
def get_spice_error(self):
|
||||
return _spice_error and str(_spice_error) or None
|
||||
|
||||
def embeddable_graphics(self):
|
||||
ret = ["vnc"]
|
||||
if not bool(self.get_spice_error()):
|
||||
ret.append("spice")
|
||||
return ret
|
||||
|
||||
# Per-VM/Connection/Connection Host Option dealings
|
||||
def _perconn_helper(self, uri, pref_func, func_type, value=None):
|
||||
suffix = "connection_prefs/%s" % gconf.escape_key(uri, len(uri))
|
||||
|
@ -24,8 +24,13 @@ import gtk
|
||||
import gobject
|
||||
|
||||
import libvirt
|
||||
|
||||
import gtkvnc
|
||||
import SpiceClientGtk as spice
|
||||
|
||||
try:
|
||||
import SpiceClientGtk as spice
|
||||
except Exception, e:
|
||||
spice = None
|
||||
|
||||
import os
|
||||
import sys
|
||||
@ -828,15 +833,21 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
return
|
||||
|
||||
if protocol is None:
|
||||
logging.debug("No graphics configured in guest")
|
||||
logging.debug("No graphics configured for guest")
|
||||
self.activate_unavailable_page(
|
||||
_("Graphical console not configured for guest"))
|
||||
return
|
||||
|
||||
if protocol not in ["vnc", "spice"]:
|
||||
logging.debug("Not a VNC or SPICE console, disabling")
|
||||
self.activate_unavailable_page(
|
||||
_("Graphical console not supported for guest"))
|
||||
if protocol not in self.config.embeddable_graphics():
|
||||
logging.debug("Don't know how to show graphics type '%s'"
|
||||
"disabling console page" % protocol)
|
||||
|
||||
msg = (_("Cannot display graphical console type '%s'")
|
||||
% protocol)
|
||||
if protocol == "spice":
|
||||
msg += ":\n %s" % self.config.get_spice_error()
|
||||
|
||||
self.activate_unavailable_page(msg)
|
||||
return
|
||||
|
||||
if gport == -1:
|
||||
@ -849,7 +860,7 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
self.viewer = VNCViewer(self, self.config)
|
||||
self.window.get_widget("console-vnc-viewport").add(self.viewer.get_widget())
|
||||
self.viewer.init_widget()
|
||||
else:
|
||||
elif protocol == "spice":
|
||||
self.viewer = SpiceViewer(self, self.config)
|
||||
|
||||
self.set_enable_accel()
|
||||
|
@ -1601,7 +1601,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
if self.config.get_console_popup() == 1:
|
||||
# user has requested console on new created vms only
|
||||
gtype = vm.get_graphics_console()[0]
|
||||
if gtype in ["vnc", "spice"]:
|
||||
if gtype in self.config.embeddable_graphics():
|
||||
self.emit("action-show-console", self.conn.get_uri(),
|
||||
guest.uuid)
|
||||
else:
|
||||
|
@ -718,16 +718,17 @@ class vmmManager(vmmGObjectUI):
|
||||
def vm_started(self, connection, uri, vmuuid):
|
||||
vm = connection.get_vm(vmuuid)
|
||||
logging.debug("VM %s started" % vm.get_name())
|
||||
if self.config.get_console_popup() == 2 and not vm.is_management_domain():
|
||||
# user has requested consoles on all vms
|
||||
gtype = vm.get_graphics_console()[0]
|
||||
if gtype in ["vnc", "spice"]:
|
||||
self.emit("action-show-console", uri, vmuuid)
|
||||
elif not connection.is_remote():
|
||||
self.emit("action-show-terminal", uri, vmuuid)
|
||||
else:
|
||||
if (self.config.get_console_popup() != 2 or
|
||||
vm.is_management_domain()):
|
||||
self.emit("action-refresh-console", uri, vmuuid)
|
||||
|
||||
# user has requested consoles on all vms
|
||||
gtype = vm.get_graphics_console()[0]
|
||||
if gtype in self.config.embeddable_graphics():
|
||||
self.emit("action-show-console", uri, vmuuid)
|
||||
elif not connection.is_remote():
|
||||
self.emit("action-show-terminal", uri, vmuuid)
|
||||
|
||||
def _build_conn_hint(self, conn):
|
||||
hint = conn.get_uri()
|
||||
if conn.state == conn.STATE_DISCONNECTED:
|
||||
|
Loading…
Reference in New Issue
Block a user