diff --git a/configure.ac b/configure.ac index 3398070e..639bd582 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_INIT(gnome-virt-manager.spec.in) -AM_INIT_AUTOMAKE(gnome-virt-manager, 0.0.1) +AM_INIT_AUTOMAKE(gnome-virt-manager, 0.0.2) AC_OUTPUT(Makefile src/Makefile diff --git a/docs/dbus-remote-control.txt b/docs/dbus-remote-control.txt new file mode 100644 index 00000000..dc8e5705 --- /dev/null +++ b/docs/dbus-remote-control.txt @@ -0,0 +1,75 @@ + DBus Remote Control + =================== + +The GNOME virt manager provides the ability to control its high level +UI actions via a DBus service. + +Interface description +--------------------- + +The service is intended to run on the session bus, and when launched +will register a well known bus name of 'com.redhat.virt.manager.ui'. +Within this service, a single object is to be exported under the +path of '/com/redhat/virt/manager/ui'. + +This object implements a single interface 'com.redhat.virt.manager.ui' +which contains the following methods: + + - show_domain_performance(string:uuid) + Takes a domain's UUID in printable string format and displays + the window showing detailed performance data + + - show_domain_editor(string:uuid) + Takes a domain's UUID in printable string format and displays + the window for configuring the VM hardware resources + + - show_domain_console(string:uuid) + Takes a domain's UUID in printable string format and displays + the window for accessing the graphical framebuffer associated + with the VM. + + - show_domain_creator() + Displys the window for creating & configuring a new domain + + - show_host_summary() + Displays the window showing a summary of all active domains + on the host + +Example usage from shell +------------------------ + +To display the performance window for the domain with a UUID of +'349025e8-ad34-34ff-239a-12ae095249f3', one would use the dbus-send +command as follows: + + # First ensure the application is running + $ dbus-send --session --dest="org.freedesktop.DBus" \ + "/org/freedesktop/DBus" \ + "org.freedesktop.DBus.StartServiceByName" \ + "string:com.redhat.virt.manager.ui" + + # Now call the show_domain_performance method + $dbus-send --session --dest="com.redhat.virt.manager.ui" \ + "/com/redhat/virt/manager/ui" + "com.redhat.virt.manager.ui.show_domain_performance" \ + "string:349025e8-ad34-34ff-239a-12ae095249f3" + +Example usage from python +------------------------- + + import dbus + + bus = dbus.SessionBus() + + bus_object = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus") + bus_iface = dbus.Interface(bus_object, "org.freedesktop.DBus") + bus_iface.StartServiceByName("com.redhat.virt.manager.ui") + + + virt_object = bus.get_object("com.redhat.virt.manager.ui", + "/com/redhat/virt/manager/ui") + virt_iface = dbus.Interface(virt_object, "com.redhat.virt.manager.ui") + virt_iface.show_domain_performance("349025e8-ad34-34ff-239a-12ae095249f3") + + + diff --git a/gnome-virt-manager.spec.in b/gnome-virt-manager.spec.in index e243b4dc..a528ea4e 100644 --- a/gnome-virt-manager.spec.in +++ b/gnome-virt-manager.spec.in @@ -16,7 +16,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Requires: python Requires: pygtk2 >= 1.99.12-6 Requires: gnome-python2-gconf >= 1.99.11-7 -Requires: libvirt-python >= 0.0.6 +Requires: libvirt-python >= 0.1.0 Requires: python-matplotlib BuildArchitectures: noarch @@ -43,9 +43,14 @@ rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) /usr/bin/%{name} +/usr/libexec/%{name}-launch /usr/share/%{name}/* /usr/share/applications/%{name}.desktop +/usr/share/dbus-1/services/%{name}.service %changelog -* Wed Mar 29 2006 - 0.0.1-1 +* Thu Apr 20 2006 Daniel Berrange - 0.0.2-1 +- Added DBus remote control service + +* Wed Mar 29 2006 Daniel Berrange - 0.0.1-1 - Initial RPM build diff --git a/src/Makefile.am b/src/Makefile.am index 8d221365..56261bbd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,6 +6,9 @@ pythondir = $(pkgdatadir) python_SOURCES = $(PACKAGE).py.in python_DATA = $(PACKAGE).py +libexec_SOURCES = $(PACKAGE)-launch.in +libexec_SCRIPTS = $(PACKAGE)-launch + gladedir = $(pkgdatadir) glade_DATA = $(wildcard $(srcdir)/*.glade) @@ -13,18 +16,28 @@ desktopdir = $(datadir)/applications desktop_SOURCES = $(PACKAGE).desktop.in desktop_DATA = $(PACKAGE).desktop -CLEANFILES = $(PACKAGE) $(PACKAGE).py $(PACKAGE).desktop +dbusdir = $(datadir)/dbus-1/services +dbus_SOURCES = $(PACKAGE).service.in +dbus_DATA = $(PACKAGE).service -EXTRA_DIST = $(bin_SOURCES) $(desktop_SOURCES) $(python_SOURCES) $(glade_DATA) +CLEANFILES = $(bin_SCRIPTS) $(desktop_DATA) $(dbus_DATA) $(python_DATA) $(libexec_SCRIPTS) + +EXTRA_DIST = $(bin_SOURCES) $(desktop_SOURCES) $(dbus_SOURCES) $(python_SOURCES) $(glade_DATA) $(libexec_SOURCES) %.desktop: $(srcdir)/%.desktop.in sed -e "s,::PACKAGE::,$(PACKAGE)," -e "s,::ICONDIR::,$(pkgdatadir)," < $< > $@ +%.service: $(srcdir)/%.service.in + sed -e "s,::PACKAGE::,$(PACKAGE)," -e "s,::PREFIX::,$(prefix)," < $< > $@ + %.py: $(srcdir)/%.py.in sed -e "s,::PACKAGE::,$(PACKAGE)," -e "s,::ASSETDIR::,$(pkgdatadir)," < $< > $@ gnome-virt-manager: $(srcdir)/gnome-virt-manager.in sed -e "s,::PACKAGE::,$(PACKAGE)," -e "s,::PYTHONDIR::,$(pkgdatadir)," < $< > $@ +gnome-virt-manager-launch: $(srcdir)/gnome-virt-manager-launch.in + sed -e "s,::PACKAGE::,$(PACKAGE)," -e "s,::PYTHONDIR::,$(pkgdatadir)," < $< > $@ + diff --git a/src/gnome-virt-manager-launch.in b/src/gnome-virt-manager-launch.in new file mode 100644 index 00000000..742a4ce2 --- /dev/null +++ b/src/gnome-virt-manager-launch.in @@ -0,0 +1,3 @@ +#!/bin/sh + +exec python "::PYTHONDIR::/::PACKAGE::.py" diff --git a/src/gnome-virt-manager.in b/src/gnome-virt-manager.in index 742a4ce2..0db87349 100755 --- a/src/gnome-virt-manager.in +++ b/src/gnome-virt-manager.in @@ -1,3 +1,7 @@ #!/bin/sh -exec python "::PYTHONDIR::/::PACKAGE::.py" +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 diff --git a/src/gnome-virt-manager.py.in b/src/gnome-virt-manager.py.in index 8d73e08a..d098f8e6 100755 --- a/src/gnome-virt-manager.py.in +++ b/src/gnome-virt-manager.py.in @@ -6,6 +6,9 @@ import gtk import gobject import gtk.gdk import gtk.glade +import dbus +import dbus.glib +import dbus.service from time import time import re import os @@ -1249,10 +1252,39 @@ class vmmEngine: uuid.append('-') return "".join(uuid) +class vmmRemote(dbus.service.Object): + def __init__(self, engine, bus_name, object_path="/com/redhat/virt/manager/ui"): + 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): + # XXX fixme + self.engine.show_about() + + @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.ui", in_signature="s") + def show_domain_performance(self, uuid): + self.engine.show_details(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.ui") + def show_host_summary(self): + self.engine.show_details(uuid) # Run me! def main(): engine = vmmEngine() + bus = dbus.SessionBus() + name = dbus.service.BusName("com.redhat.virt.manager.ui", bus=bus) + remote = vmmRemote(engine, name) engine.show_manager() gtk.main() diff --git a/src/gnome-virt-manager.service.in b/src/gnome-virt-manager.service.in new file mode 100644 index 00000000..a0320b66 --- /dev/null +++ b/src/gnome-virt-manager.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=com.redhat.virt.manager.ui +Exec=::PREFIX::/libexec/::PACKAGE::-launch