ia64/xen-unstable
changeset 2251:f36e0e397466
bitkeeper revision 1.1159.32.1 (4120b0e7LRYrL1B3ICa0Qkit5txAbQ)
Added error checking, small button on domain list,
updated to be compatible with latest xend, and
some small changes to domain creation.
Added error checking, small button on domain list,
updated to be compatible with latest xend, and
some small changes to domain creation.
author | tw275@labyrinth.cl.cam.ac.uk |
---|---|
date | Mon Aug 16 13:04:39 2004 +0000 (2004-08-16) |
parents | caf120933dc8 |
children | 2a65e83681e6 |
files | .rootkeys tools/python/xen/sv/CreateDomain.py tools/python/xen/sv/DomInfo.py tools/python/xen/sv/DomList.py tools/python/xen/sv/HTMLBase.py tools/python/xen/sv/Main.py tools/python/xen/sv/NodeInfo.py tools/python/xen/sv/util.py tools/sv/Makefile tools/sv/images/destroy.png tools/sv/images/small-destroy.png tools/sv/images/small-pause.png tools/sv/images/small-unpause.png tools/sv/inc/script.js |
line diff
1.1 --- a/.rootkeys Mon Aug 16 08:16:04 2004 +0000 1.2 +++ b/.rootkeys Mon Aug 16 13:04:39 2004 +0000 1.3 @@ -442,6 +442,7 @@ 40cf2937PSslwBliN1g7ofDy2H_RhA tools/pyt 1.4 40cf2937Z8WCNOnO2FcWdubvEAF9QQ tools/python/xen/xm/shutdown.py 1.5 40fcefb2K1xqVVT4D-p7nL2GzS4scg tools/sv/Main.rpy 1.6 40ffbcb66Dj5F-1kCK9BcgSqCWkt1w tools/sv/Makefile 1.7 +4120b0e5L_nW-u0MWRfIdXg4ng4OjA tools/sv/images/destroy.png 1.8 4107c921_OR9NTSv2dKFiLCXxrXoxA tools/sv/images/finish.png 1.9 40fcefb3wXQMsl9WkgQAVtdrupm4sw tools/sv/images/left-end-highlight.jpg 1.10 40fcefb3K6ESt5sQhD9aCQRscQIlXQ tools/sv/images/left-end-no-highlight.jpg 1.11 @@ -459,6 +460,9 @@ 40fcefb3qNbAZR5FYGPAZ9sFPVMTDA tools/sv/ 1.12 40fcefb3dgsa24WLk_BJeYQHrDLuOg tools/sv/images/seperator-right-highlight.jpg 1.13 40fcefb3FtiX4Pd2kT8wDlp8u8xRhQ tools/sv/images/seperator.jpg 1.14 41013a82sUdUqBv8EoAUJii3gsZ-4g tools/sv/images/shutdown.png 1.15 +4120b0e5RyNoIQNMjUs4A2kshovjaQ tools/sv/images/small-destroy.png 1.16 +4120b0e6vW66wW6WvjQyFD0AZH2tng tools/sv/images/small-pause.png 1.17 +4120b0e6USof7ieyGxEvtCdTMpxaQw tools/sv/images/small-unpause.png 1.18 4104ffca-jPHLVOrW0n0VghEXXtKxg tools/sv/images/unpause.png 1.19 40fcefb3yMSrZvApO9ToIi-iQwnchA tools/sv/images/xen.png 1.20 41013a83z27rKvWIxAfUBMVZ1eDCDg tools/sv/inc/script.js
2.1 --- a/tools/python/xen/sv/CreateDomain.py Mon Aug 16 08:16:04 2004 +0000 2.2 +++ b/tools/python/xen/sv/CreateDomain.py Mon Aug 16 13:04:39 2004 +0000 2.3 @@ -25,6 +25,7 @@ class CreatePage0( Sheet ): 2.4 self.addControl( InputControl( 'name', 'VM Name', 'VM Name:', "[\\w|\\S]+", "You must enter a name in this field" ) ) 2.5 self.addControl( InputControl( 'memory', '64', 'Memory (Mb):', "[\\d]+", "You must enter a number in this field" ) ) 2.6 self.addControl( InputControl( 'cpu', '0', 'CPU:', "[\\d]+", "You must enter a number in this feild" ) ) 2.7 + self.addControl( InputControl( 'cpu_weight', '1', 'CPU Weight:', "[\\d]+", "You must enter a number in this feild" ) ) 2.8 2.9 class CreatePage1( Sheet ): 2.10 2.11 @@ -83,9 +84,16 @@ class CreateFinish( Sheet ): 2.12 2.13 xend_sxp = self.translate_sxp( string2sxp( self.passback ) ) 2.14 2.15 - dom_sxp = server.xend_domain_create( xend_sxp ) 2.16 + try: 2.17 + dom_sxp = server.xend_domain_create( xend_sxp ) 2.18 + success = "Your domain was successfully created.\n" 2.19 + except: 2.20 + success = "There was an error creating your domain.\nThe configuration used is as follows:\n" 2.21 + dom_sxp = xend_sxp 2.22 + 2.23 + 2.24 2.25 - pt = PreTab( sxp2prettystring( dom_sxp ) ) 2.26 + pt = PreTab( success + sxp2prettystring( dom_sxp ) ) 2.27 pt.write_BODY( request ) 2.28 2.29 request.write( "<input type='hidden' name='passback' value=\"%s\"></p>" % self.passback ) 2.30 @@ -106,6 +114,7 @@ class CreateFinish( Sheet ): 2.31 vals.name = get( 'name' ) 2.32 vals.memory = get( 'memory' ) 2.33 vals.cpu = get( 'cpu' ) 2.34 + vals.cpu_weight = get( 'cpu_weight' ) 2.35 2.36 vals.builder = get( 'builder' ) 2.37 vals.kernel = get( 'kernel' ) 2.38 @@ -121,7 +130,7 @@ class CreateFinish( Sheet ): 2.39 2.40 vals.disk = vbds 2.41 2.42 - #misc crap 2.43 + #misc 2.44 2.45 vals.pci = [] 2.46 2.47 @@ -145,4 +154,8 @@ class CreateFinish( Sheet ): 2.48 2.49 vals.cmdline_ip = "%s:%s:%s:%s:%s:eth0:%s" % (ip, nfs, gate, mask, host, dhcp) 2.50 2.51 - return make_config( vals ) 2.52 + try: 2.53 + return make_config( vals ) 2.54 + except: 2.55 + return [["Error creating domain config."]] 2.56 +
3.1 --- a/tools/python/xen/sv/DomInfo.py Mon Aug 16 08:16:04 2004 +0000 3.2 +++ b/tools/python/xen/sv/DomInfo.py Mon Aug 16 13:04:39 2004 +0000 3.3 @@ -5,6 +5,8 @@ from xen.sv.HTMLBase import HTMLBase 3.4 from xen.sv.util import * 3.5 from xen.sv.GenTabbed import * 3.6 3.7 +DEBUG=1 3.8 + 3.9 class DomInfo( GenTabbed ): 3.10 3.11 def __init__( self, urlWriter ): 3.12 @@ -76,8 +78,11 @@ class DomSXPTab( PreTab ): 3.13 request.write( "<p>Please Select a Domain</p>" ) 3.14 return None 3.15 3.16 - domInfo = server.xend_domain( self.dom ) 3.17 - 3.18 + try: 3.19 + domInfo = server.xend_domain( self.dom ) 3.20 + except: 3.21 + domInfo = [["Error getting domain details."]] 3.22 + 3.23 self.source = sxp2prettystring( domInfo ) 3.24 3.25 PreTab.write_BODY( self, request ) 3.26 @@ -88,32 +93,54 @@ class DomActionTab( ActionTab ): 3.27 actions = { "shutdown" : ( "Shutdown the Domain", "shutdown.png" ), 3.28 "reboot" : ( "Reboot the Domain", "reboot.png" ), 3.29 "pause" : ( "Pause the Domain", "pause.png" ), 3.30 - "unpause" : ( "Unpause the Domain", "unpause.png" ) } 3.31 + "unpause" : ( "Unpause the Domain", "unpause.png" ), 3.32 + "destroy" : ( "Destroy the Domain", "destroy.png" ) } 3.33 ActionTab.__init__( self, actions ) 3.34 3.35 def op_shutdown( self, request ): 3.36 dom = getVar( 'dom', request ) 3.37 - if not dom is None: 3.38 - print ">DomShutDown %s" % dom 3.39 - #server.xend_node_shutdown() 3.40 + if not dom is None and dom != '0': 3.41 + if DEBUG: print ">DomShutDown %s" % dom 3.42 + try: 3.43 + server.xend_domain_shutdown( int( dom ), "halt" ) 3.44 + except: 3.45 + pass 3.46 3.47 def op_reboot( self, request ): 3.48 dom = getVar( 'dom', request ) 3.49 - if not dom is None: 3.50 - print ">DomReboot %s" % dom 3.51 - #server.xend_node_reboot() 3.52 - 3.53 + if not dom is None and dom != '0': 3.54 + if DEBUG: print ">DomReboot %s" % dom 3.55 + try: 3.56 + server.xend_domain_shutdown( int( dom ), "reboot" ) 3.57 + except: 3.58 + pass 3.59 + 3.60 def op_pause( self, request ): 3.61 dom = getVar( 'dom', request ) 3.62 - if not dom is None: 3.63 - print ">DomPause %s" % dom 3.64 - server.xend_domain_pause( int( dom ) ) 3.65 - 3.66 + if not dom is None and dom != '0': 3.67 + if DEBUG: print ">DomPause %s" % dom 3.68 + try: 3.69 + server.xend_domain_pause( int( dom ) ) 3.70 + except: 3.71 + pass 3.72 + 3.73 def op_unpause( self, request ): 3.74 dom = getVar( 'dom', request ) 3.75 - if not dom is None: 3.76 - print ">DomUnpause %s" % dom 3.77 - server.xend_domain_unpause( int( dom ) ) 3.78 + if not dom is None and dom != '0': 3.79 + if DEBUG: print ">DomUnpause %s" % dom 3.80 + try: 3.81 + server.xend_domain_unpause( int( dom ) ) 3.82 + except: 3.83 + pass 3.84 + 3.85 + def op_destroy( self, request ): 3.86 + dom = getVar( 'dom', request ) 3.87 + if not dom is None and dom != '0': 3.88 + if DEBUG: print ">DomDestroy %s" % dom 3.89 + try: 3.90 + server.xend_domain_destroy( int( dom ), "halt" ) 3.91 + except: 3.92 + pass 3.93 3.94 3.95
4.1 --- a/tools/python/xen/sv/DomList.py Mon Aug 16 08:16:04 2004 +0000 4.2 +++ b/tools/python/xen/sv/DomList.py Mon Aug 16 13:04:39 2004 +0000 4.3 @@ -17,9 +17,14 @@ class DomList( HTMLBase ): 4.4 4.5 def write_BODY( self, request, head=True, long=True ): 4.6 4.7 - domains = map(int, server.xend_domains()) 4.8 - domains.sort() 4.9 + domains = None 4.10 4.11 + try: 4.12 + domains = server.xend_domains() 4.13 + domains.sort() 4.14 + except: 4.15 + pass 4.16 + 4.17 request.write( "\n<table style='border:0px solid white' cellspacing='0' cellpadding='0' border='0' width='100%'>\n" ) 4.18 4.19 if head: 4.20 @@ -29,28 +34,42 @@ class DomList( HTMLBase ): 4.21 4.22 odd = True 4.23 4.24 - for domain in domains: 4.25 - if odd: 4.26 - request.write( "<tr class='domainInfoOdd'>\n" ) 4.27 - odd = False 4.28 - else: 4.29 - request.write( "<tr class='domainInfoEven'>\n" ) 4.30 - odd = True 4.31 - self.write_DOMAIN( request, getDomInfoHash( domain ), long ) 4.32 - request.write( "</tr>\n" ) 4.33 - 4.34 + if not domains is None: 4.35 + for domain in domains: 4.36 + if odd: 4.37 + request.write( "<tr class='domainInfoOdd'>\n" ) 4.38 + odd = False 4.39 + else: 4.40 + request.write( "<tr class='domainInfoEven'>\n" ) 4.41 + odd = True 4.42 + self.write_DOMAIN( request, getDomInfoHash( domain ), long ) 4.43 + request.write( "</tr>\n" ) 4.44 + else: 4.45 + request.write( "<tr colspan='10'><p class='small'>Error getting domain list<br/>Perhaps XenD not running?</p></tr>") 4.46 + 4.47 request.write( "</table>\n" ) 4.48 4.49 def write_DOMAIN( self, request, domInfoHash, long=True ): 4.50 - request.write( "<td class='domainInfo' align='center'>%(dom)-4d</td>\n" % domInfoHash ) 4.51 + request.write( "<td class='domainInfo' align='center'>%(id)s</td>\n" % domInfoHash ) 4.52 4.53 - url = self.urlWriter( "&mod=info&dom=%(dom)-4d" % domInfoHash ) 4.54 + url = self.urlWriter( "&mod=info&dom=%(id)s" % domInfoHash ) 4.55 4.56 request.write( "<td class='domainInfo' align='center'><a href='%s'>%s</a></td>\n" % ( url, domInfoHash['name'] ) ) 4.57 if long: 4.58 request.write( "<td class='domainInfo' align='center'>%(memory)5s</td>\n" % domInfoHash ) 4.59 request.write( "<td class='domainInfo' align='center'>%(cpu)2s</td>\n" % domInfoHash ) 4.60 request.write( "<td class='domainInfo' align='center'>%(state)5s</td>\n" % domInfoHash ) 4.61 + if domInfoHash[ 'id' ] != "0": 4.62 + request.write( "<td class='domainInfo' align='center'>" ) 4.63 + 4.64 + if domInfoHash[ 'state' ][ 2 ] == "-": 4.65 + request.write( "<img src='images/small-pause.png' onclick='doOp2( \"pause\", \"%(dom)-4d\" )'>" % domInfoHash ) 4.66 + else: 4.67 + request.write( "<img src='images/small-unpause.png' onclick='doOp2( \"unpause\", \"%(dom)-4d\" )'>" % domInfoHash ) 4.68 + 4.69 + request.write( "<img src='images/small-destroy.png' onclick='doOp2( \"destroy\", \"%(dom)-4d\" )'></td>" % domInfoHash) 4.70 + else: 4.71 + request.write( "<td> </td>" ) 4.72 4.73 def write_DOMAIN_HEAD( self, request, long=True ): 4.74 request.write( "<td class='domainInfoHead' align='center'>Domain</td>\n" ) 4.75 @@ -59,4 +78,4 @@ class DomList( HTMLBase ): 4.76 request.write( "<td class='domainInfoHead' align='center'>Memory / Mb</td>\n" ) 4.77 request.write( "<td class='domainInfoHead' align='center'>CPU</td>\n" ) 4.78 request.write( "<td class='domainInfoHead' align='center'>State</td>\n" ) 4.79 - 4.80 + request.write( "<td class='domainInfoHead' align='center'></td>\n" )
5.1 --- a/tools/python/xen/sv/HTMLBase.py Mon Aug 16 08:16:04 2004 +0000 5.2 +++ b/tools/python/xen/sv/HTMLBase.py Mon Aug 16 13:04:39 2004 +0000 5.3 @@ -1,4 +1,5 @@ 5.4 from twisted.web.resource import Resource 5.5 +from xen.sv.util import * 5.6 5.7 class HTMLBase( Resource ): 5.8 5.9 @@ -28,6 +29,7 @@ class HTMLBase( Resource ): 5.10 5.11 def write_BOTTOM( self, request ): 5.12 request.write('<input type="hidden" name="op" value="">') 5.13 + request.write('<input type="hidden" name="args" value="">') 5.14 request.write('</form>') 5.15 request.write( "</body></html>" ) 5.16
6.1 --- a/tools/python/xen/sv/Main.py Mon Aug 16 08:16:04 2004 +0000 6.2 +++ b/tools/python/xen/sv/Main.py Mon Aug 16 13:04:39 2004 +0000 6.3 @@ -4,6 +4,8 @@ from xen.sv.NodeInfo import NodeInfo 6.4 from xen.sv.DomInfo import DomInfo 6.5 from xen.sv.CreateDomain import CreateDomain 6.6 6.7 +from xen.xend.XendClient import server 6.8 + 6.9 from xen.sv.util import getVar 6.10 6.11 class Main( HTMLBase ): 6.12 @@ -20,14 +22,18 @@ class Main( HTMLBase ): 6.13 def render_POST( self, request ): 6.14 6.15 #decide what module post'd the action 6.16 + 6.17 + args = getVar( 'args', request ) 6.18 6.19 mod = getVar( 'mod', request ) 6.20 6.21 - if not mod is None: 6.22 + if not mod is None and args is None: 6.23 module = self.modules[ mod ] 6.24 #check module exists 6.25 if module: 6.26 - module( self.mainUrlWriter ).perform( request ) 6.27 + module( self.mainUrlWriter ).perform( request ) 6.28 + else: 6.29 + self.perform( request ) 6.30 6.31 return self.render_GET( request ) 6.32 6.33 @@ -80,3 +86,18 @@ class Main( HTMLBase ): 6.34 6.35 request.write( "</table>\n" ) 6.36 6.37 + 6.38 + def op_destroy( self, request ): 6.39 + dom = getVar( 'args', request ) 6.40 + if not dom is None and dom != "0": 6.41 + server.xend_domain_destroy( int( dom ), "halt" ) 6.42 + 6.43 + def op_pause( self, request ): 6.44 + dom = getVar( 'args', request ) 6.45 + if not dom is None and dom != "0": 6.46 + server.xend_domain_pause( int( dom ) ) 6.47 + 6.48 + def op_unpause( self, request ): 6.49 + dom = getVar( 'args', request ) 6.50 + if not dom is None and dom != "0": 6.51 + server.xend_domain_unpause( int( dom ) ) 6.52 \ No newline at end of file
7.1 --- a/tools/python/xen/sv/NodeInfo.py Mon Aug 16 08:16:04 2004 +0000 7.2 +++ b/tools/python/xen/sv/NodeInfo.py Mon Aug 16 13:04:39 2004 +0000 7.3 @@ -20,8 +20,12 @@ class NodeInfoTab( GeneralTab ): 7.4 7.5 def __init__( self ): 7.6 7.7 - nodeInfo = sxp2hash( server.xend_node() ) 7.8 - 7.9 + nodeInfo = {} 7.10 + try: 7.11 + nodeInfo = sxp2hash( server.xend_node() ) 7.12 + except: 7.13 + nodeInfo[ 'system' ] = 'Error getting node info' 7.14 + 7.15 dictTitles = {} 7.16 dictTitles[ 'System' ] = 'system' 7.17 dictTitles[ 'Hostname' ] = 'host' 7.18 @@ -39,8 +43,11 @@ class NodeInfoTab( GeneralTab ): 7.19 class NodeDmesgTab( PreTab ): 7.20 7.21 def __init__( self ): 7.22 - dmesg = server.xend_node_dmesg() 7.23 - PreTab.__init__( self, dmesg[ 1 ] ) 7.24 + try: 7.25 + dmesg = server.xend_node_dmesg() 7.26 + except: 7.27 + dmesg = "Error getting node information: XenD not running?" 7.28 + PreTab.__init__( self, dmesg ) 7.29 7.30 class NodeActionTab( ActionTab ): 7.31
8.1 --- a/tools/python/xen/sv/util.py Mon Aug 16 08:16:04 2004 +0000 8.2 +++ b/tools/python/xen/sv/util.py Mon Aug 16 13:04:39 2004 +0000 8.3 @@ -5,8 +5,12 @@ from xen.xend import PrettyPrint 8.4 import types 8.5 8.6 def getDomInfoHash( domain ): 8.7 - domInfoHash = sxp2hash( server.xend_domain( int( domain ) ) ) 8.8 - domInfoHash['dom'] = int( domain ) 8.9 + domInfoHash = {} 8.10 + try: 8.11 + domInfoHash = sxp2hash( server.xend_domain( domain ) ) 8.12 + domInfoHash['dom'] = domain 8.13 + except: 8.14 + domInfoHash['name'] = "Error getting domain details" 8.15 return domInfoHash 8.16 8.17 def sxp2hash( s ):
9.1 --- a/tools/sv/Makefile Mon Aug 16 08:16:04 2004 +0000 9.2 +++ b/tools/sv/Makefile Mon Aug 16 13:04:39 2004 +0000 9.3 @@ -33,7 +33,12 @@ install: 9.4 install -m0644 images/reboot.png $(sv_insdir)/images 9.5 install -m0644 images/pause.png $(sv_insdir)/images 9.6 install -m0644 images/unpause.png $(sv_insdir)/images 9.7 + install -m0644 images/destroy.png $(sv_insdir)/images 9.8 9.9 + install -m0644 images/small-destroy.png $(sv_insdir)/images 9.10 + install -m0644 images/small-pause.png $(sv_insdir)/images 9.11 + install -m0644 images/small-unpause.png $(sv_insdir)/images 9.12 + 9.13 install -m0644 images/next.png $(sv_insdir)/images 9.14 install -m0644 images/previous.png $(sv_insdir)/images 9.15 install -m0644 images/finish.png $(sv_insdir)/images
10.1 Binary file tools/sv/images/destroy.png has changed
11.1 Binary file tools/sv/images/small-destroy.png has changed
12.1 Binary file tools/sv/images/small-pause.png has changed
13.1 Binary file tools/sv/images/small-unpause.png has changed
14.1 --- a/tools/sv/inc/script.js Mon Aug 16 08:16:04 2004 +0000 14.2 +++ b/tools/sv/inc/script.js Mon Aug 16 13:04:39 2004 +0000 14.3 @@ -13,3 +13,10 @@ function doOp( op ) 14.4 document.forms[0].op.value = op 14.5 document.forms[0].submit() 14.6 } 14.7 + 14.8 +function doOp2( op, args ) 14.9 +{ 14.10 + document.forms[0].op.value = op 14.11 + document.forms[0].args.value = args 14.12 + document.forms[0].submit() 14.13 +}