bitkeeper revision 1.1108.1.21 (4104ffcb0fLoE7HIdNvUGJI49n_Sxg)

Added menu writing, improving the menu on the left of the page,
and gerneralized getDomInfoHash, should work with upgraded versions
 of xend
This commit is contained in:
tw275@labyrinth.cl.cam.ac.uk committed 2004-07-26 12:57:47 +00:00
1 parent fe951a3415
commit a33793ae44
9 files changed
+73 -34

No files matched your search

+29 -4
View File
@@ -26,6 +26,9 @@ class DomInfo( GenTabbed ):
self.dom = dom[0]
GenTabbed.write_BODY( self, request )
def write_MENU( self, request ):
pass
class DomGeneralTab( CompositeTab ):
def __init__( self ):
@@ -86,15 +89,37 @@ class DomSXPTab( PreTab ):
class DomActionTab( ActionTab ):
def __init__( self ):
ActionTab.__init__( self, { "shutdown" : ( "Shutdown the Domain", "shutdown.png" ),
"reboot" : ( "Reboot the Domain", "reboot.png" ) } )
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" ) }
ActionTab.__init__( self, actions )
def op_shutdown( self, request ):
print ">DomShutDown"
dom = getVar( 'dom', request )
if not dom is None:
print ">DomShutDown %s" % dom
#server.xend_node_shutdown()
def op_reboot( self, request ):
print ">DomReboot"
dom = getVar( 'dom', request )
if not dom is None:
print ">DomReboot %s" % dom
#server.xend_node_reboot()
def op_pause( self, request ):
dom = getVar( 'dom', request )
if not dom is None:
print ">DomPause %s" % dom
server.xend_domain_pause( int( dom ) )
def op_unpause( self, request ):
dom = getVar( 'dom', request )
if not dom is None:
print ">DomUnpause %s" % dom
server.xend_domain_unpause( int( dom ) )
+5 -6
View File
@@ -11,6 +11,9 @@ class DomList( HTMLBase ):
def __init__( self, urlWriter ):
HTMLBase.__init__(self)
self.urlWriter = urlWriter
def write_MENU( self, request ):
return self.write_BODY( request, head=True, long=False )
def write_BODY( self, request, head=True, long=True ):
@@ -44,11 +47,9 @@ class DomList( HTMLBase ):
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'>%(mem)7d</td>\n" % domInfoHash )
request.write( "<td class='domainInfo' align='center'>%(cpu)3d</td>\n" % domInfoHash )
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 long:
request.write( "<td class='domainInfo' align='center'>%(cpu_time)7.1f</td>\n" % domInfoHash )
def write_DOMAIN_HEAD( self, request, long=True ):
request.write( "<td class='domainInfoHead' align='center'>Domain</td>\n" )
@@ -57,6 +58,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" )
if long:
request.write( "<td class='domainInfoHead' align='center'>CPU time / s</td>\n" )
+4 -5
View File
@@ -38,14 +38,13 @@ class Main( HTMLBase ):
request.write( " <td width='15px'>&nbsp;</td>" )
request.write( " <td width='175px' align='center' valign'center'>" )
request.write( " <table cellspacing='0' cellpadding='0' border='0' width='100%' height='100%'>" )
request.write( " <tr><td height='200px' align='center' valign='center'><a href='http://www.cl.cam.ac.uk/Research/SRG/netos/xen/'>" )
request.write( " <img src='images/xen.png' width='150' height='75' border='0'/></a></td></tr>" )
request.write( " <tr><td height='140px' align='center' valign='bottom'><a href='http://www.cl.cam.ac.uk/Research/SRG/netos/xen/'>" )
request.write( " <img src='images/xen.png' width='150' height='75' border='0'/></a><br/></td></tr>" )
request.write( " <tr><td height='60px' align='center'><p class='small'>SV Web Interface<br/>(C) <a href='mailto:tw275@cam.ac.uk'>Tom Wilkie</a> 2004</p></td></tr>")
request.write( " <tr><td align='center' valign='top'>" )
for (modName, (modTitle, module)) in self.modules.items():
request.write( " <p class='small'><a href='Main.rpy?mod=%s'>%s</a></p>" % (modName, modTitle))
DomList( self.mainUrlWriter ).write_BODY( request, True, False )
module( self.mainUrlWriter ).write_MENU( request )
request.write( " </td></tr>" )
request.write( " </table>" )
+3
View File
@@ -11,6 +11,9 @@ class NodeInfo( GenTabbed ):
return urlWriter( "mod=node%s" % url )
GenTabbed.__init__( self, "Node Details", newUrlWriter, [ 'General', 'Dmesg', ], [ NodeGeneralTab, NodeDmesgTab ] )
def write_MENU( self, request ):
request.write( "<p class='small'><a href='%s'>Node details</a></p>" % self.urlWriter( '' ) )
class NodeGeneralTab( CompositeTab ):
def __init__( self ):
+28 -19
View File
@@ -2,26 +2,21 @@ from xen.xend.XendClient import server
from xen.xend import sxp
from xen.xend import PrettyPrint
import types
def getDomInfoHash( domain ):
domInfo = server.xend_domain( int( domain ) )
d = {}
d['dom'] = int( domain )
d['name'] = sxp.child_value( domInfo, 'name' )
d['mem'] = int( sxp.child_value( domInfo, 'memory' ) )
d['cpu'] = int( sxp.child_value( domInfo, 'cpu' ) )
d['state'] = sxp.child_value( domInfo, 'state' )
d['cpu_time'] = float( sxp.child_value( domInfo, 'cpu_time' ) )
if( sxp.child_value( domInfo, 'up_time' ) ):
d['up_time'] = float( sxp.child_value( domInfo, 'up_time' ) )
if( sxp.child_value( domInfo, 'start_time' ) ):
d['start_time'] = float( sxp.child_value( domInfo, 'start_time' ) )
return d
domInfoHash = sxp2hash( server.xend_domain( int( domain ) ) )
domInfoHash['dom'] = int( domain )
return domInfoHash
def sxp2hash( s ):
sxphash = {}
for child in sxp.children( s ):
sxphash[ child[0] ] = child[1]
if child is types.ListType:
sxphash[ child[0] ] = sxp2hash( child[1] )
else:
sxphash[ child[0] ] = child[1]
return sxphash
@@ -33,9 +28,19 @@ def sxp2string( sxp ):
self.str = self.str + str
temp = tmp()
PrettyPrint.prettyprint( sxp, out=temp )
return temp.str
return temp.str
def getVar( var, request ):
arg = request.args.get( var )
if arg is None or len(arg) != 1:
return None
else:
return arg[0]
def bigTimeFormatter( time ):
time = float( time )
weeks = time // 604800
remainder = time % 604800
days = remainder // 86400
@@ -47,6 +52,7 @@ def bigTimeFormatter( time ):
return "%d weeks, %d days, %s" % ( weeks, days, hms )
def smallTimeFormatter( time ):
time = float( time )
hours = time // 3600
remainder = time % 3600
mins = remainder // 60
@@ -56,12 +62,14 @@ def smallTimeFormatter( time ):
def stateFormatter( state ):
states = [ 'Running', 'Blocked', 'Paused', 'Shutdown', 'Crashed' ]
stateStr = ""
for i in range( len( state ) ):
if state[i] != "-":
return states[ i ] + " (%s)" % state
return state
stateStr += "%s, " % states[ i ]
return stateStr + " (%s)" % state
def memoryFormatter( mem ):
mem = int( mem )
if mem >= 1024:
@@ -71,6 +79,7 @@ def memoryFormatter( mem ):
return "%7dMb" % mem
def cpuFormatter( mhz ):
mhz = int( mhz )
if mhz > 1000:
ghz = float( mhz ) / 1000.0
return "%4.2fGHz" % ghz
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.