mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
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.
This commit is contained in:
1 parent
636ff6f288
commit
992c4d6f0b
14 files changed
+153
-44
No files matched your search
@@ -442,6 +442,7 @@
|
||||
40cf2937Z8WCNOnO2FcWdubvEAF9QQ tools/python/xen/xm/shutdown.py
|
||||
40fcefb2K1xqVVT4D-p7nL2GzS4scg tools/sv/Main.rpy
|
||||
40ffbcb66Dj5F-1kCK9BcgSqCWkt1w tools/sv/Makefile
|
||||
4120b0e5L_nW-u0MWRfIdXg4ng4OjA tools/sv/images/destroy.png
|
||||
4107c921_OR9NTSv2dKFiLCXxrXoxA tools/sv/images/finish.png
|
||||
40fcefb3wXQMsl9WkgQAVtdrupm4sw tools/sv/images/left-end-highlight.jpg
|
||||
40fcefb3K6ESt5sQhD9aCQRscQIlXQ tools/sv/images/left-end-no-highlight.jpg
|
||||
@@ -459,6 +460,9 @@
|
||||
40fcefb3dgsa24WLk_BJeYQHrDLuOg tools/sv/images/seperator-right-highlight.jpg
|
||||
40fcefb3FtiX4Pd2kT8wDlp8u8xRhQ tools/sv/images/seperator.jpg
|
||||
41013a82sUdUqBv8EoAUJii3gsZ-4g tools/sv/images/shutdown.png
|
||||
4120b0e5RyNoIQNMjUs4A2kshovjaQ tools/sv/images/small-destroy.png
|
||||
4120b0e6vW66wW6WvjQyFD0AZH2tng tools/sv/images/small-pause.png
|
||||
4120b0e6USof7ieyGxEvtCdTMpxaQw tools/sv/images/small-unpause.png
|
||||
4104ffca-jPHLVOrW0n0VghEXXtKxg tools/sv/images/unpause.png
|
||||
40fcefb3yMSrZvApO9ToIi-iQwnchA tools/sv/images/xen.png
|
||||
41013a83z27rKvWIxAfUBMVZ1eDCDg tools/sv/inc/script.js
|
||||
|
||||
@@ -25,6 +25,7 @@ class CreatePage0( Sheet ):
|
||||
self.addControl( InputControl( 'name', 'VM Name', 'VM Name:', "[\\w|\\S]+", "You must enter a name in this field" ) )
|
||||
self.addControl( InputControl( 'memory', '64', 'Memory (Mb):', "[\\d]+", "You must enter a number in this field" ) )
|
||||
self.addControl( InputControl( 'cpu', '0', 'CPU:', "[\\d]+", "You must enter a number in this feild" ) )
|
||||
self.addControl( InputControl( 'cpu_weight', '1', 'CPU Weight:', "[\\d]+", "You must enter a number in this feild" ) )
|
||||
|
||||
class CreatePage1( Sheet ):
|
||||
|
||||
@@ -83,9 +84,16 @@ class CreateFinish( Sheet ):
|
||||
|
||||
xend_sxp = self.translate_sxp( string2sxp( self.passback ) )
|
||||
|
||||
dom_sxp = server.xend_domain_create( xend_sxp )
|
||||
try:
|
||||
dom_sxp = server.xend_domain_create( xend_sxp )
|
||||
success = "Your domain was successfully created.\n"
|
||||
except:
|
||||
success = "There was an error creating your domain.\nThe configuration used is as follows:\n"
|
||||
dom_sxp = xend_sxp
|
||||
|
||||
|
||||
|
||||
pt = PreTab( sxp2prettystring( dom_sxp ) )
|
||||
pt = PreTab( success + sxp2prettystring( dom_sxp ) )
|
||||
pt.write_BODY( request )
|
||||
|
||||
request.write( "<input type='hidden' name='passback' value=\"%s\"></p>" % self.passback )
|
||||
@@ -106,6 +114,7 @@ class CreateFinish( Sheet ):
|
||||
vals.name = get( 'name' )
|
||||
vals.memory = get( 'memory' )
|
||||
vals.cpu = get( 'cpu' )
|
||||
vals.cpu_weight = get( 'cpu_weight' )
|
||||
|
||||
vals.builder = get( 'builder' )
|
||||
vals.kernel = get( 'kernel' )
|
||||
@@ -121,7 +130,7 @@ class CreateFinish( Sheet ):
|
||||
|
||||
vals.disk = vbds
|
||||
|
||||
#misc crap
|
||||
#misc
|
||||
|
||||
vals.pci = []
|
||||
|
||||
@@ -145,4 +154,8 @@ class CreateFinish( Sheet ):
|
||||
|
||||
vals.cmdline_ip = "%s:%s:%s:%s:%s:eth0:%s" % (ip, nfs, gate, mask, host, dhcp)
|
||||
|
||||
return make_config( vals )
|
||||
try:
|
||||
return make_config( vals )
|
||||
except:
|
||||
return [["Error creating domain config."]]
|
||||
|
||||
@@ -5,6 +5,8 @@ from xen.sv.HTMLBase import HTMLBase
|
||||
from xen.sv.util import *
|
||||
from xen.sv.GenTabbed import *
|
||||
|
||||
DEBUG=1
|
||||
|
||||
class DomInfo( GenTabbed ):
|
||||
|
||||
def __init__( self, urlWriter ):
|
||||
@@ -76,8 +78,11 @@ class DomSXPTab( PreTab ):
|
||||
request.write( "<p>Please Select a Domain</p>" )
|
||||
return None
|
||||
|
||||
domInfo = server.xend_domain( self.dom )
|
||||
|
||||
try:
|
||||
domInfo = server.xend_domain( self.dom )
|
||||
except:
|
||||
domInfo = [["Error getting domain details."]]
|
||||
|
||||
self.source = sxp2prettystring( domInfo )
|
||||
|
||||
PreTab.write_BODY( self, request )
|
||||
@@ -88,32 +93,54 @@ class DomActionTab( ActionTab ):
|
||||
actions = { "shutdown" : ( "Shutdown the Domain", "shutdown.png" ),
|
||||
"reboot" : ( "Reboot the Domain", "reboot.png" ),
|
||||
"pause" : ( "Pause the Domain", "pause.png" ),
|
||||
"unpause" : ( "Unpause the Domain", "unpause.png" ) }
|
||||
"unpause" : ( "Unpause the Domain", "unpause.png" ),
|
||||
"destroy" : ( "Destroy the Domain", "destroy.png" ) }
|
||||
ActionTab.__init__( self, actions )
|
||||
|
||||
def op_shutdown( self, request ):
|
||||
dom = getVar( 'dom', request )
|
||||
if not dom is None:
|
||||
print ">DomShutDown %s" % dom
|
||||
#server.xend_node_shutdown()
|
||||
if not dom is None and dom != '0':
|
||||
if DEBUG: print ">DomShutDown %s" % dom
|
||||
try:
|
||||
server.xend_domain_shutdown( int( dom ), "halt" )
|
||||
except:
|
||||
pass
|
||||
|
||||
def op_reboot( self, request ):
|
||||
dom = getVar( 'dom', request )
|
||||
if not dom is None:
|
||||
print ">DomReboot %s" % dom
|
||||
#server.xend_node_reboot()
|
||||
|
||||
if not dom is None and dom != '0':
|
||||
if DEBUG: print ">DomReboot %s" % dom
|
||||
try:
|
||||
server.xend_domain_shutdown( int( dom ), "reboot" )
|
||||
except:
|
||||
pass
|
||||
|
||||
def op_pause( self, request ):
|
||||
dom = getVar( 'dom', request )
|
||||
if not dom is None:
|
||||
print ">DomPause %s" % dom
|
||||
server.xend_domain_pause( int( dom ) )
|
||||
|
||||
if not dom is None and dom != '0':
|
||||
if DEBUG: print ">DomPause %s" % dom
|
||||
try:
|
||||
server.xend_domain_pause( int( dom ) )
|
||||
except:
|
||||
pass
|
||||
|
||||
def op_unpause( self, request ):
|
||||
dom = getVar( 'dom', request )
|
||||
if not dom is None:
|
||||
print ">DomUnpause %s" % dom
|
||||
server.xend_domain_unpause( int( dom ) )
|
||||
if not dom is None and dom != '0':
|
||||
if DEBUG: print ">DomUnpause %s" % dom
|
||||
try:
|
||||
server.xend_domain_unpause( int( dom ) )
|
||||
except:
|
||||
pass
|
||||
|
||||
def op_destroy( self, request ):
|
||||
dom = getVar( 'dom', request )
|
||||
if not dom is None and dom != '0':
|
||||
if DEBUG: print ">DomDestroy %s" % dom
|
||||
try:
|
||||
server.xend_domain_destroy( int( dom ), "halt" )
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -17,9 +17,14 @@ class DomList( HTMLBase ):
|
||||
|
||||
def write_BODY( self, request, head=True, long=True ):
|
||||
|
||||
domains = map(int, server.xend_domains())
|
||||
domains.sort()
|
||||
domains = None
|
||||
|
||||
try:
|
||||
domains = server.xend_domains()
|
||||
domains.sort()
|
||||
except:
|
||||
pass
|
||||
|
||||
request.write( "\n<table style='border:0px solid white' cellspacing='0' cellpadding='0' border='0' width='100%'>\n" )
|
||||
|
||||
if head:
|
||||
@@ -29,28 +34,42 @@ class DomList( HTMLBase ):
|
||||
|
||||
odd = True
|
||||
|
||||
for domain in domains:
|
||||
if odd:
|
||||
request.write( "<tr class='domainInfoOdd'>\n" )
|
||||
odd = False
|
||||
else:
|
||||
request.write( "<tr class='domainInfoEven'>\n" )
|
||||
odd = True
|
||||
self.write_DOMAIN( request, getDomInfoHash( domain ), long )
|
||||
request.write( "</tr>\n" )
|
||||
|
||||
if not domains is None:
|
||||
for domain in domains:
|
||||
if odd:
|
||||
request.write( "<tr class='domainInfoOdd'>\n" )
|
||||
odd = False
|
||||
else:
|
||||
request.write( "<tr class='domainInfoEven'>\n" )
|
||||
odd = True
|
||||
self.write_DOMAIN( request, getDomInfoHash( domain ), long )
|
||||
request.write( "</tr>\n" )
|
||||
else:
|
||||
request.write( "<tr colspan='10'><p class='small'>Error getting domain list<br/>Perhaps XenD not running?</p></tr>")
|
||||
|
||||
request.write( "</table>\n" )
|
||||
|
||||
def write_DOMAIN( self, request, domInfoHash, long=True ):
|
||||
request.write( "<td class='domainInfo' align='center'>%(dom)-4d</td>\n" % domInfoHash )
|
||||
request.write( "<td class='domainInfo' align='center'>%(id)s</td>\n" % domInfoHash )
|
||||
|
||||
url = self.urlWriter( "&mod=info&dom=%(dom)-4d" % domInfoHash )
|
||||
url = self.urlWriter( "&mod=info&dom=%(id)s" % domInfoHash )
|
||||
|
||||
request.write( "<td class='domainInfo' align='center'><a href='%s'>%s</a></td>\n" % ( url, domInfoHash['name'] ) )
|
||||
if long:
|
||||
request.write( "<td class='domainInfo' align='center'>%(memory)5s</td>\n" % domInfoHash )
|
||||
request.write( "<td class='domainInfo' align='center'>%(cpu)2s</td>\n" % domInfoHash )
|
||||
request.write( "<td class='domainInfo' align='center'>%(state)5s</td>\n" % domInfoHash )
|
||||
if domInfoHash[ 'id' ] != "0":
|
||||
request.write( "<td class='domainInfo' align='center'>" )
|
||||
|
||||
if domInfoHash[ 'state' ][ 2 ] == "-":
|
||||
request.write( "<img src='images/small-pause.png' onclick='doOp2( \"pause\", \"%(dom)-4d\" )'>" % domInfoHash )
|
||||
else:
|
||||
request.write( "<img src='images/small-unpause.png' onclick='doOp2( \"unpause\", \"%(dom)-4d\" )'>" % domInfoHash )
|
||||
|
||||
request.write( "<img src='images/small-destroy.png' onclick='doOp2( \"destroy\", \"%(dom)-4d\" )'></td>" % domInfoHash)
|
||||
else:
|
||||
request.write( "<td> </td>" )
|
||||
|
||||
def write_DOMAIN_HEAD( self, request, long=True ):
|
||||
request.write( "<td class='domainInfoHead' align='center'>Domain</td>\n" )
|
||||
@@ -59,4 +78,4 @@ class DomList( HTMLBase ):
|
||||
request.write( "<td class='domainInfoHead' align='center'>Memory / Mb</td>\n" )
|
||||
request.write( "<td class='domainInfoHead' align='center'>CPU</td>\n" )
|
||||
request.write( "<td class='domainInfoHead' align='center'>State</td>\n" )
|
||||
|
||||
request.write( "<td class='domainInfoHead' align='center'></td>\n" )
|
||||
@@ -1,4 +1,5 @@
|
||||
from twisted.web.resource import Resource
|
||||
from xen.sv.util import *
|
||||
|
||||
class HTMLBase( Resource ):
|
||||
|
||||
@@ -28,6 +29,7 @@ class HTMLBase( Resource ):
|
||||
|
||||
def write_BOTTOM( self, request ):
|
||||
request.write('<input type="hidden" name="op" value="">')
|
||||
request.write('<input type="hidden" name="args" value="">')
|
||||
request.write('</form>')
|
||||
request.write( "</body></html>" )
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ from xen.sv.NodeInfo import NodeInfo
|
||||
from xen.sv.DomInfo import DomInfo
|
||||
from xen.sv.CreateDomain import CreateDomain
|
||||
|
||||
from xen.xend.XendClient import server
|
||||
|
||||
from xen.sv.util import getVar
|
||||
|
||||
class Main( HTMLBase ):
|
||||
@@ -20,14 +22,18 @@ class Main( HTMLBase ):
|
||||
def render_POST( self, request ):
|
||||
|
||||
#decide what module post'd the action
|
||||
|
||||
args = getVar( 'args', request )
|
||||
|
||||
mod = getVar( 'mod', request )
|
||||
|
||||
if not mod is None:
|
||||
if not mod is None and args is None:
|
||||
module = self.modules[ mod ]
|
||||
#check module exists
|
||||
if module:
|
||||
module( self.mainUrlWriter ).perform( request )
|
||||
module( self.mainUrlWriter ).perform( request )
|
||||
else:
|
||||
self.perform( request )
|
||||
|
||||
return self.render_GET( request )
|
||||
|
||||
@@ -80,3 +86,18 @@ class Main( HTMLBase ):
|
||||
|
||||
request.write( "</table>\n" )
|
||||
|
||||
|
||||
def op_destroy( self, request ):
|
||||
dom = getVar( 'args', request )
|
||||
if not dom is None and dom != "0":
|
||||
server.xend_domain_destroy( int( dom ), "halt" )
|
||||
|
||||
def op_pause( self, request ):
|
||||
dom = getVar( 'args', request )
|
||||
if not dom is None and dom != "0":
|
||||
server.xend_domain_pause( int( dom ) )
|
||||
|
||||
def op_unpause( self, request ):
|
||||
dom = getVar( 'args', request )
|
||||
if not dom is None and dom != "0":
|
||||
server.xend_domain_unpause( int( dom ) )
|
||||
@@ -20,8 +20,12 @@ class NodeInfoTab( GeneralTab ):
|
||||
|
||||
def __init__( self ):
|
||||
|
||||
nodeInfo = sxp2hash( server.xend_node() )
|
||||
|
||||
nodeInfo = {}
|
||||
try:
|
||||
nodeInfo = sxp2hash( server.xend_node() )
|
||||
except:
|
||||
nodeInfo[ 'system' ] = 'Error getting node info'
|
||||
|
||||
dictTitles = {}
|
||||
dictTitles[ 'System' ] = 'system'
|
||||
dictTitles[ 'Hostname' ] = 'host'
|
||||
@@ -39,8 +43,11 @@ class NodeInfoTab( GeneralTab ):
|
||||
class NodeDmesgTab( PreTab ):
|
||||
|
||||
def __init__( self ):
|
||||
dmesg = server.xend_node_dmesg()
|
||||
PreTab.__init__( self, dmesg[ 1 ] )
|
||||
try:
|
||||
dmesg = server.xend_node_dmesg()
|
||||
except:
|
||||
dmesg = "Error getting node information: XenD not running?"
|
||||
PreTab.__init__( self, dmesg )
|
||||
|
||||
class NodeActionTab( ActionTab ):
|
||||
|
||||
|
||||
@@ -5,8 +5,12 @@ from xen.xend import PrettyPrint
|
||||
import types
|
||||
|
||||
def getDomInfoHash( domain ):
|
||||
domInfoHash = sxp2hash( server.xend_domain( int( domain ) ) )
|
||||
domInfoHash['dom'] = int( domain )
|
||||
domInfoHash = {}
|
||||
try:
|
||||
domInfoHash = sxp2hash( server.xend_domain( domain ) )
|
||||
domInfoHash['dom'] = domain
|
||||
except:
|
||||
domInfoHash['name'] = "Error getting domain details"
|
||||
return domInfoHash
|
||||
|
||||
def sxp2hash( s ):
|
||||
|
||||
@@ -33,7 +33,12 @@ install:
|
||||
install -m0644 images/reboot.png $(sv_insdir)/images
|
||||
install -m0644 images/pause.png $(sv_insdir)/images
|
||||
install -m0644 images/unpause.png $(sv_insdir)/images
|
||||
install -m0644 images/destroy.png $(sv_insdir)/images
|
||||
|
||||
install -m0644 images/small-destroy.png $(sv_insdir)/images
|
||||
install -m0644 images/small-pause.png $(sv_insdir)/images
|
||||
install -m0644 images/small-unpause.png $(sv_insdir)/images
|
||||
|
||||
install -m0644 images/next.png $(sv_insdir)/images
|
||||
install -m0644 images/previous.png $(sv_insdir)/images
|
||||
install -m0644 images/finish.png $(sv_insdir)/images
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 483 B |
Binary file not shown.
|
After Width: | Height: | Size: 434 B |
Binary file not shown.
|
After Width: | Height: | Size: 500 B |
@@ -13,3 +13,10 @@ function doOp( op )
|
||||
document.forms[0].op.value = op
|
||||
document.forms[0].submit()
|
||||
}
|
||||
|
||||
function doOp2( op, args )
|
||||
{
|
||||
document.forms[0].op.value = op
|
||||
document.forms[0].args.value = args
|
||||
document.forms[0].submit()
|
||||
}
|
||||