From: Mark Williamson Subject: Re: [Patch] add XenStore viewer Date: Thu, 4 Oct 2007 13:35:30 +0100 Message-ID: <200710041335.30568.mark.williamson@cl.cam.ac.uk> References: <200710040326.49642.mark.williamson@cl.cam.ac.uk> Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_S4NBHGpmL7PaQ4r" Return-path: In-Reply-To: <200710040326.49642.mark.williamson@cl.cam.ac.uk> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org --Boundary-00=_S4NBHGpmL7PaQ4r Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Now with patched attached - bonus! Thanks to those who pointed out my error ;-) Cheers, Mark On Thursday 04 October 2007, Mark Williamson wrote: > Hi, > > Rejigged my XenStore viewer to apply to unstable, use the python distutils > properly, etc. > > What is it? A small PyQT application that displays the contents of > XenStore graphically as a collapsible tree, making it easy to inspect the > contents of XenStore and manipulate its values. I've wished for something > like this many times when trying to debug xenbus interactions. > > It's small chunk of code and adds useful but non-critical functionality, so > I'd propose it be merged unless anyone has objections (nobody squealed last > time, so I'm guessing not). > > I'm open to suggestions regarding other features that'd be useful but it > does what I want for the moment, I think. > > Cheers, > Mark -- Dave: Just a question. What use is a unicyle with no seat? And no pedals! Mark: To answer a question with a question: What use is a skateboard? Dave: Skateboards have wheels. Mark: My wheel has a wheel! --Boundary-00=_S4NBHGpmL7PaQ4r Content-Type: all/allfiles; name="xsview.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xsview.patch" diff --exclude=.hg -ruP xen-incoming.hg/tools/misc/Makefile xen-xsview.hg/tools/misc/Makefile --- xen-incoming.hg/tools/misc/Makefile 2007-03-23 19:00:13.000000000 +0000 +++ xen-xsview.hg/tools/misc/Makefile 2007-10-03 17:59:34.000000000 +0100 @@ -14,7 +14,7 @@ TARGETS := $(TARGETS-y) INSTALL_BIN = $(TARGETS) xencons -INSTALL_SBIN = netfix xm xen-bugtool xen-python-path xend xenperf +INSTALL_SBIN = netfix xm xen-bugtool xen-python-path xend xenperf xsview .PHONY: all all: build diff --exclude=.hg -ruP xen-incoming.hg/tools/misc/xsview xen-xsview.hg/tools/misc/xsview --- xen-incoming.hg/tools/misc/xsview 1970-01-01 01:00:00.000000000 +0100 +++ xen-xsview.hg/tools/misc/xsview 2007-10-04 01:13:52.000000000 +0100 @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +import sys + +sys.path.append('/usr/lib/python') +sys.path.append('/usr/lib64/python') +from xen.xsview import main + +main.main(sys.argv) + + diff --exclude=.hg -ruP xen-incoming.hg/tools/python/setup.py xen-xsview.hg/tools/python/setup.py --- xen-incoming.hg/tools/python/setup.py 2007-09-08 18:00:31.000000000 +0100 +++ xen-xsview.hg/tools/python/setup.py 2007-10-04 02:49:54.000000000 +0100 @@ -79,6 +79,7 @@ 'xen.xm', 'xen.web', 'xen.sv', + 'xen.xsview', 'xen.xend.tests', 'xen.xend.server.tests', diff --exclude=.hg -ruP xen-incoming.hg/tools/python/xen/xsview/main.py xen-xsview.hg/tools/python/xen/xsview/main.py --- xen-incoming.hg/tools/python/xen/xsview/main.py 1970-01-01 01:00:00.000000000 +0100 +++ xen-xsview.hg/tools/python/xen/xsview/main.py 2007-10-03 17:56:46.000000000 +0100 @@ -0,0 +1,10 @@ +from xsviewer import * +from qt import * + +def main(args): + app = QApplication(args) + mainwin = XSViewer(app) + mainwin.show() + app.connect(app, SIGNAL("lastWindowClosed()"), + app, SLOT("quit()")) + app.exec_loop() diff --exclude=.hg -ruP xen-incoming.hg/tools/python/xen/xsview/xsviewer.py xen-xsview.hg/tools/python/xen/xsview/xsviewer.py --- xen-incoming.hg/tools/python/xen/xsview/xsviewer.py 1970-01-01 01:00:00.000000000 +0100 +++ xen-xsview.hg/tools/python/xen/xsview/xsviewer.py 2007-10-04 03:14:21.000000000 +0100 @@ -0,0 +1,168 @@ +from qt import * + +import xen.lowlevel.xs + +class XSViewer(QMainWindow): + + def __init__(self, app): + apply(QMainWindow.__init__, (self,)) + + self.setCaption('XenStore Viewer') + + self.new_node = QAction(self, 'New Node') + self.new_node.setText('New Node...') + self.connect(self.new_node, SIGNAL('activated()'), + self.do_new_node) + + self.rm_node = QAction(self, 'Remove Node') + self.rm_node.setText('Remove Node') + self.connect(self.rm_node, SIGNAL('activated()'), + self.do_rm_node) + + self.refresh = QAction(self, 'Refresh') + self.refresh.setText('Refresh') + self.connect(self.refresh, SIGNAL('activated()'), + self.do_refresh) + + self.file_menu = QPopupMenu(self) + self.new_node.addTo(self.file_menu) + self.rm_node.addTo(self.file_menu) + self.refresh.addTo(self.file_menu) + + + self.about = QAction(self, 'About') + self.about.setText('About...') + self.connect(self.about, SIGNAL('activated()'), + self.do_about) + + self.help_menu = QPopupMenu(self) + self.about.addTo(self.help_menu) + + self.menubar = QMenuBar(self) + self.menubar.insertItem('&File', self.file_menu) + self.menubar.insertItem('&Help', self.help_menu) + + self.vbox = QVBox(self) + self.setCentralWidget(self.vbox) + + self.xs_tree = QListView(self.vbox) + self.xs_tree.addColumn('Key') + self.xs_tree.setRootIsDecorated(1) + self.xs_tree.connect(self.xs_tree, SIGNAL('selectionChanged(QListViewItem*)'), self.showValue) + + self.info_box = QHBox(self.vbox) + self.info_box.setMargin(2) + self.info_box.setSpacing(2) + self.info_label = QLabel(self.info_box) + self.info_label.setText('Value') + self.info = QLineEdit(self.info_box) + self.setval = QPushButton(self.info_box) + self.setval.setText('Set') + self.setval.connect(self.setval, SIGNAL('clicked()'), self.setValue) + + self.xs_handle = xen.lowlevel.xs.xs() + + self.showtree() + + + def showtree(self): + xstransact = self.xs_handle.transaction_start() + self.walktree(xstransact, '/', '/', self.xs_tree) + self.xs_handle.transaction_end(xstransact) + + def walktree(self, trans, node, subdir_prepend, parent_widget): + + ents = self.xs_handle.ls(trans, node) + if ents == None: + return + + for e in ents: + i = QListViewItem(parent_widget, e) + i.full_path = subdir_prepend + e + self.walktree(trans, i.full_path, i.full_path + '/', i) + + + def showValue(self, item): + trans = self.xs_handle.transaction_start() + val = self.xs_handle.read(trans, item.full_path) + self.info.setText(val) + self.xs_handle.transaction_end(trans) + + + def setValue(self): + trans = self.xs_handle.transaction_start() + item = self.xs_tree.currentItem() + newval = str(self.info.text()) + + self.xs_handle.write(trans, item.full_path, newval) + + self.xs_handle.transaction_end(trans) + + + def do_refresh(self): + self.xs_tree.clear() + self.info.clear() + self.showtree() + + def do_new_node(self): + dia = QDialog(self) + dia.setCaption('Create new node') + + vbox = QVBox(dia) + + setting_hbox = QHBox(vbox) + + path_label = QLabel(setting_hbox) + path_label.setText('Node path') + path = QLineEdit(setting_hbox) + + value_label = QLabel(setting_hbox) + value_label.setText('Node value') + val = QLineEdit(setting_hbox) + + button_hbox = QHBox(vbox) + + set = QPushButton(button_hbox) + set.setText('Set') + self.connect(set, SIGNAL('clicked()'), dia, SLOT('accept()')) + + cancel = QPushButton(button_hbox) + cancel.setText('Cancel') + self.connect(cancel, SIGNAL('clicked()'), dia, SLOT('reject()')) + + setting_hbox.adjustSize() + button_hbox.adjustSize() + vbox.adjustSize() + + if dia.exec_loop() == QDialog.Accepted: + trans = self.xs_handle.transaction_start() + self.xs_handle.write(trans, str(path.text()), str(val.text())) + + self.xs_handle.transaction_end(trans) + + self.do_refresh() + + # nothing to set. + + def do_rm_node(self): + trans = self.xs_handle.transaction_start() + item = self.xs_tree.currentItem() + newval = str(self.info.text()) + + self.xs_handle.rm(trans, item.full_path) + + self.xs_handle.transaction_end(trans) + + self.do_refresh() + + def do_about(self): + about_dia = QMessageBox(self) + about_dia.setIcon(QMessageBox.Information) + + about_dia.setCaption('About XenStore Viewer') + about_dia.setText('XenStore Viewer\n' + 'by Mark Williamson ') + + about_dia.exec_loop() + + --Boundary-00=_S4NBHGpmL7PaQ4r Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_S4NBHGpmL7PaQ4r--