bz 211385: add preference to automatically pop up console on new vm creation or all vm creation.

This commit is contained in:
Hugh O. Brock
2006-10-31 14:29:22 -05:00
parent cc41177fa5
commit a35e1867cf
6 changed files with 183 additions and 17 deletions

View File

@@ -17,7 +17,7 @@
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="gravity">GDK_GRAVITY_CENTER</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<signal name="delete_event" handler="on_vm_manager_delete_event" last_modification_time="Tue, 28 Mar 2006 17:08:39 GMT"/>
@@ -2759,7 +2759,7 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
<property name="visible">True</property>
<property name="title" translatable="yes">Virtual Machine Manager Preferences</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
@@ -2767,8 +2767,8 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="gravity">GDK_GRAVITY_CENTER</property>
<property name="focus_on_map">False</property>
<property name="urgency_hint">False</property>
<property name="has_separator">False</property>
<signal name="delete_event" handler="on_vmm_preferences_delete_event" last_modification_time="Wed, 29 Mar 2006 10:12:05 GMT"/>
@@ -2845,16 +2845,18 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
<child>
<widget class="GtkLabel" id="label36">
<property name="visible">True</property>
<property name="label" translatable="yes">Update status every</property>
<property name="use_underline">False</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Update status every</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">stats-update-interval</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
@@ -3029,6 +3031,118 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame9">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
<child>
<widget class="GtkAlignment" id="alignment127">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">6</property>
<property name="left_padding">12</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkTable" id="table31">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">0</property>
<property name="column_spacing">0</property>
<child>
<widget class="GtkComboBox" id="console-pref">
<property name="visible">True</property>
<property name="items" translatable="yes">Never
For new domains
For all domains</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
<signal name="changed" handler="on_console_pref_changed" last_modification_time="Mon, 30 Oct 2006 18:11:47 GMT"/>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_padding">5</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label342">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Automatically open consoles:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">console-pref</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label341">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Consoles&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">3</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>

View File

@@ -130,5 +130,18 @@
</locale>
</schema>
<schema>
<key>/schemas/apps/::PACKAGE::/console/popup-pref</key>
<applyto>/apps/::PACKAGE::/console/popup-pref</applyto>
<owner>::PACKAGE::</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short>When to pop up a console for a guest</short>
<long>Whether to pop up a console for a guest. 0 = never, 1 = only on creation of a new guest, 2 = On creation of any guest</long>
</locale>
</schema>
</schemalist>
</gconfschemafile>

View File

@@ -24,6 +24,10 @@ import libvirt
from virtManager.keyring import *
CONSOLE_NEVER = 0
CONSOLE_NEW_ONLY = 1
CONSOLE_ALWAYS = 2
class vmmConfig:
def __init__(self, appname, appversion, gconf_dir, glade_dir, icon_dir):
self.appname = appname
@@ -163,6 +167,17 @@ class vmmConfig:
def on_stats_history_length_changed(self, callback):
self.conf.notify_add(self.conf_dir + "/stats/history-length", callback)
def on_console_pref_changed(self, callback):
self.conf.notify_add(self.conf_dir + "/console/popup-pref", callback)
def get_console_pref(self):
console_pref = self.conf.get_int(self.conf_dir + "/console/popup-pref")
if console_pref == None:
console_pref = 0
return console_pref
def set_console_pref(self, pref):
self.conf.set_int(self.conf_dir + "/console/popup-pref", pref)
def get_secret_name(self, vm):
return "vm-console-" + vm.get_uuid()
@@ -254,5 +269,5 @@ class vmmConfig:
def get_kickstart_urls(self):
return self.conf.get_list(self.conf_dir + "/urls/kickstart", gconf.VALUE_STRING)

View File

@@ -398,12 +398,14 @@ class vmmCreate(gobject.GObject):
# Ensure new VM is loaded
self.connection.tick(noStatsUpdate=True)
vm = self.connection.get_vm(guest.uuid)
(gtype, host, port) = vm.get_graphics_console()
if gtype == "vnc":
self.emit("action-show-console", self.connection.get_uri(), guest.uuid)
else:
self.emit("action-show-terminal", self.connection.get_uri(), guest.uuid)
if self.config.get_console_pref() == 1:
# user has requested console on new created vms only
vm = self.connection.get_vm(guest.uuid)
(gtype, host, port) = vm.get_graphics_console()
if gtype == "vnc":
self.emit("action-show-console", self.connection.get_uri(), guest.uuid)
else:
self.emit("action-show-terminal", self.connection.get_uri(), guest.uuid)
self.close()
def do_install(self, guest):

View File

@@ -39,6 +39,8 @@ class vmmManager(gobject.GObject):
gobject.TYPE_NONE, []),
"action-show-console": (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, (str,str)),
"action-show-terminal": (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, (str,str)),
"action-show-details": (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, (str,str)),
"action-show-about": (gobject.SIGNAL_RUN_FIRST,
@@ -210,7 +212,14 @@ class vmmManager(gobject.GObject):
model.append([vmuuid, vm.get_name()])
vm.connect("status-changed", self.vm_status_changed)
vm.connect("resources-sampled", self.vm_resources_sampled)
if self.config.get_console_pref() == 2 and range(model.iter_n_children(None)) > 1:
# user has requested consoles on all vms
(gtype, host, port) = vm.get_graphics_console()
if gtype == "vnc":
self.emit("action-show-console", uri, vmuuid)
else:
self.emit("action-show-terminal", uri, vmuuid)
def vm_removed(self, connection, uri, vmuuid):
vmlist = self.window.get_widget("vm-list")

View File

@@ -24,16 +24,24 @@ class vmmPreferences:
self.config = config
self.window.get_widget("vmm-preferences").hide()
# box = self.window.get_widget("console-pref")
# model = gtk.ListStore(str)
# box.set_model(model)
# model.append(["Never"])
# model.append(["For new domains"])
# model.append(["For all domains"])
self.config.on_console_pref_changed(self.refresh_console_pref)
self.config.on_stats_update_interval_changed(self.refresh_update_interval)
self.config.on_stats_history_length_changed(self.refresh_history_length)
self.refresh_update_interval()
self.refresh_history_length()
self.refresh_console_pref()
self.window.signal_autoconnect({
"on_stats_update_interval_changed": self.change_update_interval,
"on_stats_history_length_changed": self.change_history_length,
"on_console_pref_changed": self.change_console_pref,
"on_close_clicked": self.close,
"on_vmm_preferences_delete_event": self.close,
})
@@ -45,7 +53,7 @@ class vmmPreferences:
def show(self):
win = self.window.get_widget("vmm-preferences")
win.show()
win.present()
# win.present()
def refresh_update_interval(self, ignore1=None,ignore2=None,ignore3=None,ignore4=None):
self.window.get_widget("stats-update-interval").set_value(self.config.get_stats_update_interval())
@@ -53,9 +61,14 @@ class vmmPreferences:
def refresh_history_length(self, ignore1=None,ignore2=None,ignore3=None,ignore4=None):
self.window.get_widget("stats-history-length").set_value(self.config.get_stats_history_length())
def refresh_console_pref(self,ignore1=None,ignore2=None,ignore3=None,ignore4=None):
self.window.get_widget("console-pref").set_active(self.config.get_console_pref())
def change_update_interval(self, src):
self.config.set_stats_update_interval(src.get_value_as_int())
def change_history_length(self, src):
self.config.set_stats_history_length(src.get_value_as_int())
def change_console_pref(self, box):
self.config.set_console_pref(box.get_active())