bitkeeper revision 1.1159.1.71 (41222dd4fZJ-eLP-14ipE-SQAgV3uQ)

Merge ssh://xenbk@gandalf.hpl.hp.com//var/bk/xeno-unstable.bk
into labyrinth.cl.cam.ac.uk:/auto/anfs/scratch/labyrinth/iap10/xeno-clone/xeno.bk
This commit is contained in:
iap10@labyrinth.cl.cam.ac.uk committed 2004-08-17 16:09:56 +00:00
commit f18f81f295
31 files changed
+573 -160

No files matched your search

+17 -4
View File
@@ -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."]]
+44 -17
View File
@@ -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
+34 -15
View File
@@ -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>&nbsp;</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" )
+2
View File
@@ -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>" )
+23 -2
View File
@@ -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 ) )
+11 -4
View File
@@ -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 ):
+6 -2
View File
@@ -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 ):
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.