Make it possible to open multiple connections

This commit is contained in:
Daniel P. Berrange
2006-06-12 16:45:48 -04:00
parent bf526cb528
commit 36d1f99845
4 changed files with 640 additions and 49 deletions

View File

@ -1,3 +1,3 @@
#!/bin/sh
exec python "::PYTHONDIR::/::PACKAGE::.py"
exec python "::PYTHONDIR::/::PACKAGE::.py" --no-connect --own-service

View File

@ -19,7 +19,6 @@
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</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"/>
<child>
@ -31,8 +30,6 @@
<child>
<widget class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
<property name="pack_direction">GTK_PACK_DIRECTION_LTR</property>
<property name="child_pack_direction">GTK_PACK_DIRECTION_LTR</property>
<child>
<widget class="GtkMenuItem" id="menuitem4">
@ -46,9 +43,48 @@
<child>
<widget class="GtkImageMenuItem" id="menu_file_new">
<property name="visible">True</property>
<property name="label">gtk-new</property>
<property name="use_stock">True</property>
<property name="label" translatable="yes">New machine...</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_menu_file_new_activate" last_modification_time="Tue, 28 Mar 2006 17:06:34 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image15">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator4">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="open_connection">
<property name="visible">True</property>
<property name="label" translatable="yes">Open connection...</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_menu_file_open_connection_activate" last_modification_time="Mon, 12 Jun 2006 20:34:47 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image16">
<property name="visible">True</property>
<property name="stock">gtk-connect</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
@ -83,12 +119,12 @@
<child>
<widget class="GtkImageMenuItem" id="menu_edit_details">
<property name="visible">True</property>
<property name="label" translatable="yes">VM details</property>
<property name="label" translatable="yes">Machine details</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_menu_edit_details_activate" last_modification_time="Tue, 28 Mar 2006 17:06:34 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image6">
<widget class="GtkImage" id="image17">
<property name="visible">True</property>
<property name="stock">gtk-properties</property>
<property name="icon_size">1</property>
@ -104,9 +140,21 @@
<child>
<widget class="GtkImageMenuItem" id="menu_edit_delete">
<property name="visible">True</property>
<property name="label">gtk-delete</property>
<property name="use_stock">True</property>
<property name="label" translatable="yes">Delete machine</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_menu_edit_delete_activate" last_modification_time="Tue, 28 Mar 2006 17:06:34 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image18">
<property name="visible">True</property>
<property name="stock">gtk-delete</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
@ -513,7 +561,6 @@ Inactive virtual machines</property>
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
</property>
<property name="wrap_license">False</property>
<property name="authors">Daniel P. Berrange &lt;berrange@redhat.com&gt;</property>
<property name="translator_credits" translatable="yes" comments="TRANSLATORS: Replace this string with your names, one name per line.">translator-credits</property>
<signal name="delete_event" handler="on_vmm_about_delete_event" last_modification_time="Wed, 29 Mar 2006 10:31:19 GMT"/>
@ -535,7 +582,6 @@ Inactive virtual machines</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<signal name="delete_event" handler="on_vmm_details_delete_event" last_modification_time="Wed, 29 Mar 2006 18:04:05 GMT"/>
<child>
@ -1865,7 +1911,6 @@ Inactive virtual machines</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="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"/>
@ -2168,7 +2213,6 @@ Inactive virtual machines</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<signal name="delete_event" handler="on_vmm_console_delete_event" last_modification_time="Mon, 03 Apr 2006 14:21:14 GMT"/>
<child>
@ -2180,8 +2224,6 @@ Inactive virtual machines</property>
<child>
<widget class="GtkMenuBar" id="menubar2">
<property name="visible">True</property>
<property name="pack_direction">GTK_PACK_DIRECTION_LTR</property>
<property name="child_pack_direction">GTK_PACK_DIRECTION_LTR</property>
<child>
<widget class="GtkMenuItem" id="menuitem8">
@ -2473,4 +2515,433 @@ Inactive virtual machines</property>
</child>
</widget>
<widget class="GtkDialog" id="vmm-open-connection">
<property name="visible">True</property>
<property name="title" translatable="yes">Open connection</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<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="has_separator">False</property>
<signal name="delete_event" handler="on_vmm_open_connection_delete_event" last_modification_time="Mon, 12 Jun 2006 20:42:45 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox2">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area2">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancel">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_cancel_clicked" last_modification_time="Mon, 12 Jun 2006 19:41:44 GMT"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="connect">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_connect_clicked" last_modification_time="Mon, 12 Jun 2006 19:41:53 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment11">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox12">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image9">
<property name="visible">True</property>
<property name="stock">gtk-connect</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label86">
<property name="visible">True</property>
<property name="label" translatable="yes">Connect</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="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="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox12">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkRadioButton" id="type-local-xen">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Local Xen host</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_type_local_xen_toggled" last_modification_time="Mon, 12 Jun 2006 19:46:14 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="type-remote-xen">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Remote Xen host</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">type-local-xen</property>
<signal name="toggled" handler="on_type_remote_xen_toggled" last_modification_time="Mon, 12 Jun 2006 19:46:23 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="remote-xen-options">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">4</property>
<property name="homogeneous">False</property>
<property name="row_spacing">3</property>
<property name="column_spacing">3</property>
<child>
<widget class="GtkEntry" id="remote-xen-port">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="remote-xen-host">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label84">
<property name="visible">True</property>
<property name="label" translatable="yes">Port:</property>
<property name="use_underline">False</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="xalign">0</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="left_attach">2</property>
<property name="right_attach">3</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>
<child>
<widget class="GtkLabel" id="label85">
<property name="visible">True</property>
<property name="label" translatable="yes">Host:</property>
<property name="use_underline">False</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="xalign">0</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="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>
<child>
<widget class="GtkCheckButton" id="remote-xen-secure">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Secure connection</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="type-other-hv">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Other hypervisor</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">type-local-xen</property>
<signal name="toggled" handler="on_type_other_hv_toggled" last_modification_time="Mon, 12 Jun 2006 19:46:32 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="other-hv-options">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">3</property>
<child>
<widget class="GtkLabel" id="label82">
<property name="visible">True</property>
<property name="label" translatable="yes">URI:</property>
<property name="use_underline">False</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="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="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="other-hv-uri">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator2">
<property name="visible">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="option-read-only">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Read only connection</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -1,7 +1,3 @@
#!/bin/sh
#!/usr/bin/python
set -e
dbus-send --session --dest="org.freedesktop.DBus" /org/freedesktop/DBus org.freedesktop.DBus.StartServiceByName string:'com.redhat.virt.manager.ui'
dbus-send --session --dest="com.redhat.virt.manager.ui" /com/redhat/virt/manager/ui com.redhat.virt.manager.ui.show_host_summary
exec python "::PYTHONDIR::/::PACKAGE::.py" "$@"

View File

@ -16,8 +16,13 @@ import os.path
import sys
import libvirt
from optparse import OptionParser
import matplotlib
matplotlib.use('GTK')
# Obnoxious matplotlib sets its own icon as the default
# which is a totally inappropriate action for a library
# to take
#gtk.window_set_default_icon(None)
from matplotlib.figure import Figure
from matplotlib.axes import Subplot
@ -478,6 +483,62 @@ class vmmPreferences:
self.config.set_stats_history_length(src.get_value_as_int())
class vmmOpenConnection:
def __init__(self, engine):
self.window = gtk.glade.XML(glade_dir + "/" + appname + ".glade", "vmm-open-connection")
self.engine = engine
self.window.get_widget("vmm-open-connection").hide()
self.window.get_widget("remote-xen-options").set_sensitive(False)
self.window.get_widget("other-hv-options").set_sensitive(False)
self.window.signal_autoconnect({
"on_type_local_xen_toggled": self.change_active_type,
"on_type_remote_xen_toggled": self.change_active_type,
"on_type_other_hv_toggled": self.change_active_type,
"on_cancel_clicked": self.close,
"on_connect_clicked": self.open_connection,
"on_vmm_open_connection_delete_event": self.close,
})
def close(self,ignore1=None,ignore2=None):
self.window.get_widget("vmm-open-connection").hide()
return 1
def show(self):
win = self.window.get_widget("vmm-open-connection")
win.show_all()
win.present()
def change_active_type(self, src):
if src.get_active():
if src.get_name() == "type-local-xen":
self.window.get_widget("remote-xen-options").set_sensitive(False)
self.window.get_widget("other-hv-options").set_sensitive(False)
elif src.get_name() == "type-remote-xen":
self.window.get_widget("remote-xen-options").set_sensitive(True)
self.window.get_widget("other-hv-options").set_sensitive(False)
else:
self.window.get_widget("remote-xen-options").set_sensitive(False)
self.window.get_widget("other-hv-options").set_sensitive(True)
def open_connection(self,src):
uri = None
if self.window.get_widget("type-local-xen").get_active():
uri = None
elif self.window.get_widget("type-remote-xen").get_active():
protocol = "http"
if self.window.get_widget("remote-xen-secure").get_active():
protocol = "https"
uri = protocol + "://" + self.window.get_widget("remote-xen-host").get_text() + ":" + self.window.get_widget("remote-xen-port").get_text()
else:
uri = self.window.get_widget("other-hv-uri").get_text()
con = self.engine.get_connection(uri, self.window.get_widget("option-read-only").get_active())
con.show_manager()
self.close()
class vmmManager:
def __init__(self, config, connection):
self.window = gtk.glade.XML(glade_dir + "/" + appname + ".glade", "vmm-manager")
@ -530,6 +591,7 @@ class vmmManager:
"on_menu_view_network_traffic_activate" : self.toggle_network_traffic_visible_conf,
"on_vm_manager_delete_event": self.exit_app,
"on_menu_file_open_connection_activate": self.open_connection,
"on_menu_file_quit_activate": self.exit_app,
"on_vmm_close_clicked": self.exit_app,
"on_vm_details_clicked": self.show_vm_details,
@ -557,6 +619,8 @@ class vmmManager:
def exit_app(self, ignore=None,ignore2=None):
gtk.main_quit()
def open_connection(self, src=None):
self.connection.show_open_connection()
def vm_added(self, vmuuid, name):
vmlist = self.window.get_widget("vm-list")
@ -1128,11 +1192,15 @@ class vmmStats:
return self.status_icons[status.lower()]
class vmmConnection:
def __init__(self, engine, config, uri):
def __init__(self, engine, config, uri, readOnly):
self.engine = engine
self.config = config
self.vmm = libvirt.openReadOnly(uri)
if readOnly:
self.vmm = libvirt.openReadOnly(uri)
else:
self.vmm = libvirt.open(uri)
self.windowManager = None
self.windowDetails = {}
self.windowConsole = {}
@ -1148,7 +1216,7 @@ class vmmConnection:
self.engine.show_about()
def show_preferences(self):
self.engine.show_config()
self.engine.show_preferences()
def show_manager(self):
if self.windowManager == None:
@ -1170,12 +1238,19 @@ class vmmConnection:
self.windowConsole[vmuuid].show()
def show_open_connection(self):
self.engine.show_open_connection()
def connect_to_signal(self, name, callback):
if not(self.callbacks.has_key(name)):
raise "unknown signal " + name + "requested"
self.callbacks[name].append(callback)
if name == "vm_removed":
for uuid in self.vms.keys():
self.notify_vm_added(uuid, self.vms[uuid].name())
def disconnect_from_signal(self, name, callback):
for i in len(self.callbacks[name]):
if self.callbacks[i] == callback:
@ -1231,6 +1306,7 @@ class vmmConnection:
class vmmEngine:
def __init__(self):
self.windowOpenConnection = None
self.windowPreferences = None
self.windowAbout = None
@ -1265,6 +1341,7 @@ class vmmEngine:
except:
print str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1])
print "Error refreshing connection " + uri
return 1
def change_timer_interval(self,ignore1,ignore2,ignore3,ignore4):
gobject.source_remove(self.timer)
@ -1280,58 +1357,105 @@ class vmmEngine:
def show_preferences(self):
if self.windowPreferences == None:
self.windowPreferences = vmmPreferences(self)
self.windowPreferences = vmmPreferences(self.get_config())
self.windowPreferences.show()
def get_connection(self, uri):
def show_open_connection(self):
if self.windowOpenConnection == None:
self.windowOpenConnection = vmmOpenConnection(self)
self.windowOpenConnection.show()
def show_console(self, uri, uuid):
con = self.get_connection(uri)
con.show_console(uuid)
def show_details(self, uri, uuid):
con = self.get_connection(uri)
con.show_details(uuid)
def show_manager(self, uri):
con = self.get_connection(uri)
con.show_manager()
def get_connection(self, uri, readOnly=True):
key = uri
if key == None:
if key == None or key == "":
key = "__default__"
if not(self.connections.has_key(key)):
self.connections[key] = vmmConnection(self, self.get_config(), uri)
self.connections[key] = vmmConnection(self, self.get_config(), uri, readOnly)
self.connections[key].tick()
return self.connections[key]
class vmmRemote(dbus.service.Object):
def __init__(self, engine, bus_name, object_path="/com/redhat/virt/manager/ui"):
def __init__(self, engine, bus_name, object_path="/com/redhat/virt/manager"):
dbus.service.Object.__init__(self, bus_name, object_path)
self.engine = engine
@dbus.service.method("com.redhat.virt.manager.ui")
def show_domain_creator(self):
@dbus.service.method("com.redhat.virt.manager", in_signature="s")
def show_domain_creator(self, uri):
# XXX fixme
self.engine.show_about()
self.engine.show_manager(uri)
@dbus.service.method("com.redhat.virt.manager.ui", in_signature="s")
def show_domain_editor(self, uuid):
self.engine.show_details(uuid)
@dbus.service.method("com.redhat.virt.manager", in_signature="ss")
def show_domain_editor(self, uri, uuid):
self.engine.show_details(uri, uuid)
@dbus.service.method("com.redhat.virt.manager.ui", in_signature="s")
def show_domain_performance(self, uuid):
self.engine.show_details(uuid)
@dbus.service.method("com.redhat.virt.manager", in_signature="ss")
def show_domain_performance(self, uri, uuid):
self.engine.show_details(uri, uuid)
@dbus.service.method("com.redhat.virt.manager.ui", in_signature="s")
def show_domain_console(self, uuid):
self.engine.show_console(uuid)
@dbus.service.method("com.redhat.virt.manager", in_signature="ss")
def show_domain_console(self, uri, uuid):
self.engine.show_console(uri, uuid)
@dbus.service.method("com.redhat.virt.manager.ui")
def show_host_summary(self):
self.engine.show_details(uuid)
@dbus.service.method("com.redhat.virt.manager", in_signature="s")
def show_host_summary(self, uri):
print "Openning manage " + uri
self.engine.show_manager(uri)
@dbus.service.method("com.redhat.virt.manager")
def show_open_connection(self):
self.engine.show_open_connection()
# Run me!
def main():
optParser = OptionParser()
optParser.add_option("-c", "--connect", dest="uri", help="Connect to hypervisor at URI", metavar="URI")
(options, args) = optParser.parse_args()
engine = vmmEngine()
bus = None
try:
bus = dbus.SessionBus()
name = dbus.service.BusName("com.redhat.virt.manager.ui", bus=bus)
remote = vmmRemote(engine, name)
dbusProxy = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
dbusObj = dbus.Interface(dbusProxy, "org.freedesktop.DBus")
# If we're already running, then just talk to existing process
if os.getenv("DBUS_ACTIVATION_BUS_ADDRESS"):
name = dbus.service.BusName("com.redhat.virt.manager", bus=bus)
remote = vmmRemote(engine, name)
else:
managerProxy = bus.get_object("com.redhat.virt.manager", "/com/redhat/virt/manager")
managerObj = dbus.Interface(managerProxy, "com.redhat.virt.manager")
if options.uri != None:
print "Asking existing instance to open URI '" + str(options.uri) + "'"
managerObj.show_host_summary(options.uri)
else:
managerObj.show_open_connection()
# yes, we exit completely now - remote service is in charge
return
except:
print str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1])
print "Could not initialize DBus sub-system, disabling bus service"
engine.get_connection(None).show_manager()
print "Could not connection to session bus, disabling DBus service"
if options.uri != None:
engine.show_manager(options.uri)
else:
engine.show_open_connection()
gtk.main()
if __name__ == "__main__":