Added remote control via DBus
This commit is contained in:
parent
6210c00c2e
commit
3fb8aa350d
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
||||
|
|
@ -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 <berrange@redhat.com> - 0.0.1-1
|
||||
* Thu Apr 20 2006 Daniel Berrange <berrange@redhat.com> - 0.0.2-1
|
||||
- Added DBus remote control service
|
||||
|
||||
* Wed Mar 29 2006 Daniel Berrange <berrange@redhat.com> - 0.0.1-1
|
||||
- Initial RPM build
|
||||
|
|
|
@ -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)," < $< > $@
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
exec python "::PYTHONDIR::/::PACKAGE::.py"
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[D-BUS Service]
|
||||
Name=com.redhat.virt.manager.ui
|
||||
Exec=::PREFIX::/libexec/::PACKAGE::-launch
|
Loading…
Reference in New Issue