ia64/xen-unstable

changeset 1905:1a4ae7399519

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
author tw275@labyrinth.cl.cam.ac.uk
date Mon Jul 26 12:57:47 2004 +0000 (2004-07-26)
parents 9fd9d87a5a61
children 997d615bd58b edc7bf00ee37 f4ad7cdea334
files .rootkeys tools/python/xen/sv/DomInfo.py tools/python/xen/sv/DomList.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/pause.png tools/sv/images/unpause.png
line diff
     1.1 --- a/.rootkeys	Fri Jul 23 22:39:55 2004 +0000
     1.2 +++ b/.rootkeys	Mon Jul 26 12:57:47 2004 +0000
     1.3 @@ -442,6 +442,7 @@ 40fcefb3BUT98zPzW8kAFKuxGdh4XA tools/sv/
     1.4  40fcefb38OTgsUKHBpwshLLIsiIaCA tools/sv/images/middle-no-highlight.jpg
     1.5  40fcefb32SPtrw36c4S6YGFlLvkKuw tools/sv/images/orb_01.jpg
     1.6  40fcefb3Ok5qkX3iM7ZEPVkRInrUpg tools/sv/images/orb_02.jpg
     1.7 +4104ffca9_GhWOxRE-83uZIad2Z1gg tools/sv/images/pause.png
     1.8  41013a82ILk71xLqWFH5ZO5VmOIvBw tools/sv/images/reboot.png
     1.9  40fcefb3JnT5XeKTuVF4yUMGOtuNZg tools/sv/images/right-end-highlight.jpg
    1.10  40fcefb3-DuYOS7noo2W7b_0p7TOUg tools/sv/images/right-end-no-highlight.jpg
    1.11 @@ -449,6 +450,7 @@ 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 +4104ffca-jPHLVOrW0n0VghEXXtKxg tools/sv/images/unpause.png
    1.16  40fcefb3yMSrZvApO9ToIi-iQwnchA tools/sv/images/xen.png
    1.17  41013a83z27rKvWIxAfUBMVZ1eDCDg tools/sv/inc/script.js
    1.18  40fcefb3zGC9XNBkSwTEobCoq8YClA tools/sv/inc/style.css
     2.1 --- a/tools/python/xen/sv/DomInfo.py	Fri Jul 23 22:39:55 2004 +0000
     2.2 +++ b/tools/python/xen/sv/DomInfo.py	Mon Jul 26 12:57:47 2004 +0000
     2.3 @@ -26,6 +26,9 @@ class DomInfo( GenTabbed ):
     2.4              self.dom = dom[0]
     2.5          
     2.6          GenTabbed.write_BODY( self, request )
     2.7 +        
     2.8 +    def write_MENU( self, request ):
     2.9 +        pass
    2.10  
    2.11  class DomGeneralTab( CompositeTab ):
    2.12      def __init__( self ):
    2.13 @@ -86,15 +89,37 @@ class DomSXPTab( PreTab ):
    2.14  class DomActionTab( ActionTab ):
    2.15  
    2.16      def __init__( self ):
    2.17 -        ActionTab.__init__( self, { "shutdown" : ( "Shutdown the Domain", "shutdown.png" ),
    2.18 -        	"reboot" : ( "Reboot the Domain", "reboot.png" ) } )    
    2.19 +    	actions = { "shutdown" : ( "Shutdown the Domain", "shutdown.png" ),
    2.20 +        	    "reboot" : ( "Reboot the Domain", "reboot.png" ),
    2.21 +                    "pause" : ( "Pause the Domain", "pause.png" ),
    2.22 +                    "unpause" : ( "Unpause the Domain", "unpause.png" ) }
    2.23 +        ActionTab.__init__( self, actions )    
    2.24          
    2.25      def op_shutdown( self, request ):
    2.26 -    	print ">DomShutDown"
    2.27 +   	dom = getVar( 'dom', request )
    2.28 +        if not dom is None:
    2.29 +    	   print ">DomShutDown %s" % dom
    2.30      	#server.xend_node_shutdown()
    2.31      
    2.32      def op_reboot( self, request ):
    2.33 -    	print ">DomReboot"
    2.34 +       	dom = getVar( 'dom', request )
    2.35 +        if not dom is None:
    2.36 +    	    print ">DomReboot %s" % dom
    2.37          #server.xend_node_reboot()
    2.38          
    2.39 +    def op_pause( self, request ):
    2.40 +       	dom = getVar( 'dom', request )
    2.41 +        if not dom is None:
    2.42 +    	    print ">DomPause %s" % dom
    2.43 +            server.xend_domain_pause( int( dom ) )
    2.44 +        
    2.45 +    def op_unpause( self, request ):
    2.46 +       	dom = getVar( 'dom', request )
    2.47 +        if not dom is None:
    2.48 +    	   print ">DomUnpause %s" % dom
    2.49 +           server.xend_domain_unpause( int( dom ) )
    2.50 +        
    2.51 +    
    2.52 +    
    2.53 +        
    2.54  
     3.1 --- a/tools/python/xen/sv/DomList.py	Fri Jul 23 22:39:55 2004 +0000
     3.2 +++ b/tools/python/xen/sv/DomList.py	Mon Jul 26 12:57:47 2004 +0000
     3.3 @@ -11,6 +11,9 @@ class DomList( HTMLBase ):
     3.4      def __init__( self, urlWriter ):
     3.5          HTMLBase.__init__(self)
     3.6          self.urlWriter = urlWriter
     3.7 +        
     3.8 +    def write_MENU( self, request ):
     3.9 +    	return self.write_BODY( request, head=True, long=False ) 
    3.10  
    3.11      def write_BODY( self, request, head=True, long=True ):
    3.12      
    3.13 @@ -44,11 +47,9 @@ class DomList( HTMLBase ):
    3.14  
    3.15          request.write( "<td class='domainInfo' align='center'><a href='%s'>%s</a></td>\n" % ( url, domInfoHash['name'] ) )
    3.16          if long: 
    3.17 -            request.write( "<td class='domainInfo' align='center'>%(mem)7d</td>\n" % domInfoHash )
    3.18 -            request.write( "<td class='domainInfo' align='center'>%(cpu)3d</td>\n" % domInfoHash )
    3.19 +            request.write( "<td class='domainInfo' align='center'>%(memory)5s</td>\n" % domInfoHash )
    3.20 +            request.write( "<td class='domainInfo' align='center'>%(cpu)2s</td>\n" % domInfoHash )
    3.21          request.write( "<td class='domainInfo' align='center'>%(state)5s</td>\n" % domInfoHash )
    3.22 -        if long:
    3.23 -            request.write( "<td class='domainInfo' align='center'>%(cpu_time)7.1f</td>\n" % domInfoHash )
    3.24  
    3.25      def write_DOMAIN_HEAD( self, request, long=True ):
    3.26          request.write( "<td class='domainInfoHead' align='center'>Domain</td>\n" )      
    3.27 @@ -57,6 +58,4 @@ class DomList( HTMLBase ):
    3.28              request.write( "<td class='domainInfoHead' align='center'>Memory / Mb</td>\n" )      
    3.29              request.write( "<td class='domainInfoHead' align='center'>CPU</td>\n" )      
    3.30          request.write( "<td class='domainInfoHead' align='center'>State</td>\n" )      
    3.31 -        if long:
    3.32 -            request.write( "<td class='domainInfoHead' align='center'>CPU time / s</td>\n" )
    3.33              
     4.1 --- a/tools/python/xen/sv/Main.py	Fri Jul 23 22:39:55 2004 +0000
     4.2 +++ b/tools/python/xen/sv/Main.py	Mon Jul 26 12:57:47 2004 +0000
     4.3 @@ -38,14 +38,13 @@ class Main( HTMLBase ):
     4.4          request.write( " <td width='15px'>&nbsp;</td>" )
     4.5          request.write( " <td width='175px' align='center' valign'center'>" )
     4.6          request.write( "  <table cellspacing='0' cellpadding='0' border='0' width='100%' height='100%'>" )
     4.7 -        request.write( "   <tr><td height='200px' align='center' valign='center'><a href='http://www.cl.cam.ac.uk/Research/SRG/netos/xen/'>" )
     4.8 -        request.write( "   <img src='images/xen.png' width='150' height='75' border='0'/></a></td></tr>" )
     4.9 +        request.write( "   <tr><td height='140px' align='center' valign='bottom'><a href='http://www.cl.cam.ac.uk/Research/SRG/netos/xen/'>" )
    4.10 +        request.write( "   <img src='images/xen.png' width='150' height='75' border='0'/></a><br/></td></tr>" )
    4.11 +        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>")
    4.12          request.write( "   <tr><td align='center' valign='top'>" )
    4.13          
    4.14          for (modName, (modTitle, module)) in self.modules.items():
    4.15 -            request.write( "    <p class='small'><a href='Main.rpy?mod=%s'>%s</a></p>" % (modName, modTitle))
    4.16 -    
    4.17 -        DomList( self.mainUrlWriter ).write_BODY( request, True, False )
    4.18 +            module( self.mainUrlWriter ).write_MENU( request )
    4.19  
    4.20          request.write( "   </td></tr>" )
    4.21          request.write( "  </table>" )
     5.1 --- a/tools/python/xen/sv/NodeInfo.py	Fri Jul 23 22:39:55 2004 +0000
     5.2 +++ b/tools/python/xen/sv/NodeInfo.py	Mon Jul 26 12:57:47 2004 +0000
     5.3 @@ -11,6 +11,9 @@ class NodeInfo( GenTabbed ):
     5.4              return urlWriter( "mod=node%s" % url )
     5.5      
     5.6          GenTabbed.__init__( self, "Node Details", newUrlWriter, [ 'General', 'Dmesg', ], [ NodeGeneralTab, NodeDmesgTab ] )
     5.7 +    
     5.8 +    def write_MENU( self, request ):
     5.9 +        request.write( "<p class='small'><a href='%s'>Node details</a></p>" % self.urlWriter( '' ) )
    5.10  
    5.11  class NodeGeneralTab( CompositeTab ):
    5.12      def __init__( self ):
     6.1 --- a/tools/python/xen/sv/util.py	Fri Jul 23 22:39:55 2004 +0000
     6.2 +++ b/tools/python/xen/sv/util.py	Mon Jul 26 12:57:47 2004 +0000
     6.3 @@ -2,26 +2,21 @@ from xen.xend.XendClient import server
     6.4  from xen.xend import sxp
     6.5  from xen.xend import PrettyPrint
     6.6  
     6.7 +import types
     6.8 +
     6.9  def getDomInfoHash( domain ):
    6.10 -    domInfo = server.xend_domain( int( domain ) )
    6.11 -    d = {}
    6.12 -    d['dom']    = int( domain )
    6.13 -    d['name']   = sxp.child_value( domInfo, 'name' )
    6.14 -    d['mem']    = int( sxp.child_value( domInfo, 'memory' ) )
    6.15 -    d['cpu']    = int( sxp.child_value( domInfo, 'cpu' ) )
    6.16 -    d['state']  = sxp.child_value( domInfo, 'state' )
    6.17 -    d['cpu_time'] = float( sxp.child_value( domInfo, 'cpu_time' ) )
    6.18 -    if( sxp.child_value( domInfo, 'up_time' ) ):
    6.19 -        d['up_time'] =  float( sxp.child_value( domInfo, 'up_time' ) )
    6.20 -    if( sxp.child_value( domInfo, 'start_time' ) ):
    6.21 -        d['start_time'] = float( sxp.child_value( domInfo, 'start_time' ) )
    6.22 -    return d
    6.23 +    domInfoHash = sxp2hash( server.xend_domain( int( domain ) ) )
    6.24 +    domInfoHash['dom'] = int( domain )
    6.25 +    return domInfoHash
    6.26  
    6.27  def sxp2hash( s ):
    6.28      sxphash = {}
    6.29          
    6.30      for child in sxp.children( s ):
    6.31 -        sxphash[ child[0] ] = child[1]
    6.32 +    	if child is types.ListType:
    6.33 +            sxphash[ child[0] ] = sxp2hash( child[1] )
    6.34 +        else:
    6.35 +            sxphash[ child[0] ] = child[1]
    6.36          
    6.37      return sxphash
    6.38      
    6.39 @@ -33,9 +28,19 @@ def sxp2string( sxp ):
    6.40                  self.str = self.str + str
    6.41      temp = tmp()
    6.42      PrettyPrint.prettyprint( sxp, out=temp )
    6.43 -    return temp.str    
    6.44 +    return temp.str
    6.45 +
    6.46 +def getVar( var, request ):
    6.47 +   
    6.48 +    arg = request.args.get( var )
    6.49 +
    6.50 +    if arg is None or len(arg) != 1:
    6.51 +        return None
    6.52 +    else:
    6.53 +        return arg[0]
    6.54  
    6.55  def bigTimeFormatter( time ):
    6.56 +    time = float( time )
    6.57      weeks = time // 604800
    6.58      remainder = time % 604800
    6.59      days = remainder // 86400
    6.60 @@ -47,6 +52,7 @@ def bigTimeFormatter( time ):
    6.61      return "%d weeks, %d days, %s" % ( weeks, days, hms )
    6.62  
    6.63  def smallTimeFormatter( time ):
    6.64 +    time = float( time )
    6.65      hours = time // 3600
    6.66      remainder = time % 3600
    6.67      mins = remainder // 60
    6.68 @@ -56,12 +62,14 @@ def smallTimeFormatter( time ):
    6.69  def stateFormatter( state ):
    6.70      states = [ 'Running', 'Blocked', 'Paused', 'Shutdown', 'Crashed' ]
    6.71      
    6.72 +    stateStr = ""
    6.73 +    
    6.74      for i in range( len( state ) ):
    6.75          if state[i] != "-":
    6.76 -            return states[ i ] + " (%s)" % state
    6.77 -    
    6.78 -    return state
    6.79 -    
    6.80 +            stateStr += "%s, " % states[ i ] 
    6.81 +           
    6.82 +    return stateStr + " (%s)" % state
    6.83 +
    6.84  def memoryFormatter( mem ):
    6.85      mem = int( mem )
    6.86      if mem >= 1024:
    6.87 @@ -71,6 +79,7 @@ def memoryFormatter( mem ):
    6.88          return "%7dMb" % mem
    6.89  
    6.90  def cpuFormatter( mhz ):
    6.91 +    mhz = int( mhz )
    6.92      if mhz > 1000:
    6.93          ghz = float( mhz ) / 1000.0
    6.94          return "%4.2fGHz" % ghz
     7.1 --- a/tools/sv/Makefile	Fri Jul 23 22:39:55 2004 +0000
     7.2 +++ b/tools/sv/Makefile	Mon Jul 26 12:57:47 2004 +0000
     7.3 @@ -31,6 +31,8 @@ install:
     7.4  	
     7.5  	install -m0644 images/shutdown.png $(sv_insdir)/images
     7.6  	install -m0644 images/reboot.png $(sv_insdir)/images
     7.7 +	install -m0644 images/pause.png $(sv_insdir)/images
     7.8 +	install -m0644 images/unpause.png $(sv_insdir)/images
     7.9  
    7.10  	# make include folder
    7.11  	mkdir -p $(sv_insdir)/inc
     8.1 Binary file tools/sv/images/pause.png has changed
     9.1 Binary file tools/sv/images/unpause.png has changed