This commit is contained in:
Jeremy Katz 2006-08-29 18:21:56 -04:00
commit 45b21ebbd9
4 changed files with 193 additions and 4 deletions

View File

@ -2142,7 +2142,7 @@ Máirín Duffy <duffy@redhat.com>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="rules_hint">True</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
@ -2445,11 +2445,11 @@ Máirín Duffy &lt;duffy@redhat.com&gt;
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="treeview2">
<widget class="GtkTreeView" id="network-view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="rules_hint">True</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
@ -3305,6 +3305,24 @@ Máirín Duffy &lt;duffy@redhat.com&gt;
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToggleToolButton" id="control-fullscreen">
<property name="visible">True</property>
<property name="label" translatable="yes">Full screen</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-zoom-fit</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
<property name="active">False</property>
<signal name="toggled" handler="on_control_fullscreen_toggled" last_modification_time="Tue, 29 Aug 2006 20:00:28 GMT"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>

View File

@ -87,6 +87,8 @@ class vmmConsole(gobject.GObject):
"on_control_shutdown_clicked": self.control_vm_shutdown,
"on_control_pause_toggled": self.control_vm_pause,
"on_control_fullscreen_toggled": self.toggle_fullscreen,
"on_menu_vm_run_activate": self.control_vm_run,
"on_menu_vm_shutdown_activate": self.control_vm_shutdown,
"on_menu_vm_pause_activate": self.control_vm_pause,
@ -126,6 +128,14 @@ class vmmConsole(gobject.GObject):
vp.set_size_request(vncWidth+2, vncHeight+2)
def toggle_fullscreen(self, src):
if src.get_active():
self.window.get_widget("vmm-console").fullscreen()
#gtk.gdk.keyboard_grab(self.window.get_widget("vmm-console").get_root_window())
else:
self.window.get_widget("vmm-console").unfullscreen()
#gtk.gdk.keyboard_ungrab()
def show(self):
dialog = self.window.get_widget("vmm-console")

View File

@ -127,6 +127,12 @@ class vmmDetails(gobject.GObject):
self.update_widget_states(vm, vm.status())
self.refresh_resources(vm)
self.prepare_disk_list()
self.populate_disk_list()
self.prepare_network_list()
self.populate_network_list()
def show(self):
dialog = self.window.get_widget("vmm-details")
dialog.show_all()
@ -280,4 +286,81 @@ class vmmDetails(gobject.GObject):
self.window.get_widget("config-memory-apply").set_sensitive(False)
self.window.get_widget("state-vm-memory").set_text("%d MB" % (newmem/1024))
def prepare_disk_list(self):
disks = self.window.get_widget("storage-view")
disksModel = gtk.TreeStore(str,str,str,str)
disks.set_model(disksModel)
diskType_col = gtk.TreeViewColumn("Type")
diskType_text = gtk.CellRendererText()
diskType_col.pack_start(diskType_text, True)
diskType_col.add_attribute(diskType_text, 'text', 0)
diskSrc_col = gtk.TreeViewColumn("Source")
diskSrc_text = gtk.CellRendererText()
diskSrc_col.pack_start(diskSrc_text, True)
diskSrc_col.add_attribute(diskSrc_text, 'text', 1)
diskDevice_col = gtk.TreeViewColumn("Device")
diskDevice_text = gtk.CellRendererText()
diskDevice_col.pack_start(diskDevice_text, True)
diskDevice_col.add_attribute(diskDevice_text, 'text', 2)
diskDst_col = gtk.TreeViewColumn(_("Destination"))
diskDst_text = gtk.CellRendererText()
diskDst_col.pack_start(diskDst_text, True)
diskDst_col.add_attribute(diskDst_text, 'text', 3)
disks.append_column(diskType_col)
disks.append_column(diskSrc_col)
disks.append_column(diskDevice_col)
disks.append_column(diskDst_col)
def populate_disk_list(self):
diskList = self.vm.get_disk_devices()
disks = self.window.get_widget("storage-view")
disksModel = disks.get_model()
for d in diskList:
disksModel.append(None, d)
def prepare_network_list(self):
nets = self.window.get_widget("network-view")
netsModel = gtk.TreeStore(str,str,str,str)
nets.set_model(netsModel)
netType_col = gtk.TreeViewColumn("Type")
netType_text = gtk.CellRendererText()
netType_col.pack_start(netType_text, True)
netType_col.add_attribute(netType_text, 'text', 0)
netSrc_col = gtk.TreeViewColumn("Source")
netSrc_text = gtk.CellRendererText()
netSrc_col.pack_start(netSrc_text, True)
netSrc_col.add_attribute(netSrc_text, 'text', 1)
netDevice_col = gtk.TreeViewColumn("Device")
netDevice_text = gtk.CellRendererText()
netDevice_col.pack_start(netDevice_text, True)
netDevice_col.add_attribute(netDevice_text, 'text', 2)
netDst_col = gtk.TreeViewColumn(_("MAC address"))
netDst_text = gtk.CellRendererText()
netDst_col.pack_start(netDst_text, True)
netDst_col.add_attribute(netDst_text, 'text', 3)
nets.append_column(netType_col)
nets.append_column(netSrc_col)
nets.append_column(netDevice_col)
nets.append_column(netDst_col)
def populate_network_list(self):
netList = self.vm.get_network_devices()
nets = self.window.get_widget("network-view")
netsModel = nets.get_model()
for d in netList:
netsModel.append(None, d)
gobject.type_register(vmmDetails)

View File

@ -21,6 +21,7 @@ import gobject
import libvirt
import libxml2
import os
import sys
class vmmDomain(gobject.GObject):
__gsignals__ = {
@ -306,6 +307,83 @@ class vmmDomain(gobject.GObject):
port = int(port)
return [type, "localhost", port]
def get_disk_devices(self):
xml = self.vm.XMLDesc(0)
doc = None
try:
doc = libxml2.parseDoc(xml)
except:
return []
ctx = doc.xpathNewContext()
disks = []
try:
ret = ctx.xpathEval("/domain/devices/disk")
for node in ret:
type = node.prop("type")
srcpath = None
devdst = None
for child in node.children:
if child.name == "source":
if type == "file":
srcpath = child.prop("file")
elif type == "block":
srcpath = child.prop("dev")
elif child.name == "target":
devdst = child.prop("dev")
if srcpath == None:
raise "missing source path"
if devdst == None:
raise "missing destination device"
devtype = node.prop("device")
if devtype == None:
devtype = "disk"
disks.append([type, srcpath, devtype, devdst])
finally:
if ctx != None:
ctx.xpathFreeContext()
if doc != None:
doc.freeDoc()
return disks
def get_network_devices(self):
xml = self.vm.XMLDesc(0)
doc = None
try:
doc = libxml2.parseDoc(xml)
except:
return []
ctx = doc.xpathNewContext()
disks = []
try:
ret = ctx.xpathEval("/domain/devices/interface")
for node in ret:
type = node.prop("type")
devmac = None
source = None
for child in node.children:
if child.name == "source":
if type == "bridge":
source = child.prop("bridge")
elif child.name == "mac":
devmac = child.prop("address")
if source == None:
source = "-"
devdst = "eth%d" % len(disks)
disks.append([type, source, devdst, devmac])
finally:
if ctx != None:
ctx.xpathFreeContext()
if doc != None:
doc.freeDoc()
return disks
def set_vcpu_count(self, vcpus):
vcpus = int(vcpus)
self.vm.setVcpus(vcpus)