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