ia64/xen-unstable

changeset 1955:6daa82a1130a

bitkeeper revision 1.1108.1.36 (4107c92bdU3CUVZu3R2o9eIsKdi9gg)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into labyrinth.cl.cam.ac.uk:/local/scratch/tw275/xeno.bk
author tw275@labyrinth.cl.cam.ac.uk
date Wed Jul 28 15:41:31 2004 +0000 (2004-07-28)
parents dfcf11e557ce 4af2b646c55b
children 2cf5a0ee2c00 ac93dc78a47d
files .rootkeys tools/python/xen/sv/CreateDomain.py tools/python/xen/sv/Wizard.py tools/python/xen/sv/util.py tools/sv/Makefile tools/sv/images/finish.png
line diff
     1.1 --- a/.rootkeys	Wed Jul 28 15:35:54 2004 +0000
     1.2 +++ b/.rootkeys	Wed Jul 28 15:41:31 2004 +0000
     1.3 @@ -452,6 +452,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 +4107c921_OR9NTSv2dKFiLCXxrXoxA tools/sv/images/finish.png
     1.8  40fcefb3wXQMsl9WkgQAVtdrupm4sw tools/sv/images/left-end-highlight.jpg
     1.9  40fcefb3K6ESt5sQhD9aCQRscQIlXQ tools/sv/images/left-end-no-highlight.jpg
    1.10  40fcefb3BUT98zPzW8kAFKuxGdh4XA tools/sv/images/middle-highlight.jpg
     2.1 --- a/tools/python/xen/sv/CreateDomain.py	Wed Jul 28 15:35:54 2004 +0000
     2.2 +++ b/tools/python/xen/sv/CreateDomain.py	Wed Jul 28 15:41:31 2004 +0000
     2.3 @@ -1,46 +1,70 @@
     2.4 -from xen.sv.Wizard import Wizard, Sheet
     2.5 +from xen.sv.Wizard import *
     2.6 +from xen.sv.util import *
     2.7  
     2.8  class CreateDomain( Wizard ):
     2.9      def __init__( self, urlWriter ):
    2.10      	
    2.11 -    	sheets = { 0: CreatePage0,
    2.12 -          	   1: CreatePage1,
    2.13 -          	   2: CreatePage2,
    2.14 -                   3: CreatePage3 }
    2.15 +    	sheets = [ CreatePage0,
    2.16 +          	   CreatePage1,
    2.17 +          	   CreatePage2,
    2.18 +                   CreatePage3,
    2.19 +                   CreatePage4,
    2.20 +                   CreateFinish ]
    2.21      
    2.22      	Wizard.__init__( self, urlWriter, "Create Domain Wizard", sheets )
    2.23         
    2.24  class CreatePage0( Sheet ):
    2.25  
    2.26      def __init__( self, urlWriter ):
    2.27 -    
    2.28 -    	feilds = [( 'name', 'VM Name:'),
    2.29 -                  ( 'memory', 'RAM (Mb):' )]
    2.30 -    
    2.31 -        Sheet.__init__( self, urlWriter, feilds, "Create New Domain", 0 )
    2.32 -                
    2.33 +        Sheet.__init__( self, urlWriter, "General", 0 )
    2.34 +        self.addControl( InputControl( 'vm_name', 'VM Name', 'VM Name:' ) )
    2.35 +        self.addControl( InputControl( 'memory', '64', 'Memory (Mb):' ) )
    2.36 +                        
    2.37  class CreatePage1( Sheet ):
    2.38  
    2.39      def __init__( self, urlWriter ):
    2.40 -    
    2.41 -    	feilds = [( 'kernel_type', 'Kernel Type:'),
    2.42 -                  ( 'kernel_location', 'Kernel location:')]
    2.43 -        
    2.44 -        Sheet.__init__( self, urlWriter, feilds, "Setup Kernel Image", 1 )
    2.45 -        
    2.46 +        Sheet.__init__( self, urlWriter, "Setup Kernel Image", 1 )
    2.47 +        self.addControl( InputControl( 'kernel_image', '/boot/vmlinuz-2.4.26-xenU', 'Kernel Image:' ) )
    2.48 +        self.addControl( InputControl( 'kernel_params', '', 'Kernel Command Line Parame:' ) )
    2.49 +
    2.50  class CreatePage2( Sheet ):
    2.51  
    2.52      def __init__( self, urlWriter ):
    2.53 -    
    2.54 -    	feilds = [( 'vbd_dom0', 'Location of vbd:'),
    2.55 -        	  ( 'vbd_dom0', 'Vitualised location:')]    
    2.56 -   
    2.57 -        Sheet.__init__( self, urlWriter, feilds, "Setup Virtual Block Devices", 2 )
    2.58 -                
    2.59 +    	Sheet.__init__( self, urlWriter, "Setup Virtual Block Device", 2 )
    2.60 +        self.addControl( InputControl( 'num_vbds', '1', 'Number of VBDs:' ) )
    2.61 +
    2.62  class CreatePage3( Sheet ):
    2.63  
    2.64      def __init__( self, urlWriter ):
    2.65 -    
    2.66 -    	feilds = [( 'vifs', 'Number of Vifs:')]
    2.67 +        Sheet.__init__( self, urlWriter, "Setup Virtual Block Device", 3 )
    2.68 +        
    2.69 +    def write_BODY( self, request ):
    2.70 +    	previous_values = sxp2hash( string2sxp( self.passback ) ) #get the hash for quick reference
    2.71 +        num_vbds = previous_values.get( 'num_vbds' )
    2.72 +        
    2.73 +        for i in range( int( num_vbds ) ):
    2.74 +            self.addControl( InputControl( 'vbd%s_dom0' % i, '/dev/sda%i' % i, 'Device %s name:' % i  ) )
    2.75 +            self.addControl( InputControl( 'vbd%s_domU' % i, '/dev/sda%i' % i, 'Virtualized device %s:' % i ) )
    2.76 +            
    2.77 +        self.addControl( InputControl( 'root_dev', '/dev/sda1', 'Root device (in VM):' ) )
    2.78          
    2.79 -        Sheet.__init__( self, urlWriter, feilds, "Create New Domain - 4", 3 )       
    2.80 +        Sheet.write_BODY( self, request )
    2.81 +                
    2.82 +class CreatePage4( Sheet ):
    2.83 +
    2.84 +    def __init__( self, urlWriter ):        
    2.85 +        Sheet.__init__( self, urlWriter, "Network settings", 4 )  
    2.86 +        self.addControl( InputControl( 'hostname', 'hostname', 'VM Hostname:' ) )
    2.87 +        self.addControl( InputControl( 'ip_addr', '1.2.3.4', 'VM IP Address:' ) )
    2.88 +        self.addControl( InputControl( 'ip_subnet', '255.255.255.0', 'VM Subnet Mask:' ) ) 
    2.89 +        self.addControl( InputControl( 'ip_gateway', '1.2.3.4', 'VM Gateway:' ) )           
    2.90 +         
    2.91 +class CreateFinish( Sheet ):
    2.92 +
    2.93 +    def __init__( self, urlWriter ):
    2.94 +        Sheet.__init__( self, urlWriter, "All Done", 5 )
    2.95 +        
    2.96 +    def write_BODY( self, request ):
    2.97 +    	request.write( "<pre>%s</pre>" % sxp2prettystring( string2sxp( self.passback ) ) )
    2.98 +        request.write( "<input type='hidden' name='passback' value=\"%s\"></p>" % self.passback )
    2.99 +        request.write( "<input type='hidden' name='sheet' value='%s'></p>" % self.location )
     3.1 --- a/tools/python/xen/sv/Wizard.py	Wed Jul 28 15:35:54 2004 +0000
     3.2 +++ b/tools/python/xen/sv/Wizard.py	Wed Jul 28 15:41:31 2004 +0000
     3.3 @@ -32,16 +32,21 @@ class Wizard( HTMLBase ):
     3.4          if op == 'next':
     3.5              currSheet += 1
     3.6          elif op == 'prev':
     3.7 -            currSheet -= 1    
     3.8 +             currSheet -= 1
     3.9 +             
    3.10 +        sheet = self.sheets[ currSheet ]( self.urlWriter )    
    3.11              
    3.12 -        self.sheets[ currSheet ]( self.urlWriter ).write_BODY( request )
    3.13 +        sheet.parseForm( request )
    3.14 +        sheet.write_BODY( request )
    3.15          
    3.16          request.write( "</td></tr><tr><td><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr>" )
    3.17          request.write( "<td width='80%'></td><td width='20%' align='center'><p align='center'>" )
    3.18  	if currSheet > 0:
    3.19 -       		request.write( "<img src='images/previous.png' onclick='doOp( \"prev\" )' onmouseover='update( \"wizText\", \"Previous\" )' onmouseout='update( \"wizText\", \"&nbsp;\" )'>&nbsp;" )
    3.20 -        if currSheet < ( len( self.sheets ) - 1 ):        
    3.21 -        	request.write( "<img src='images/next.png' onclick='doOp( \"next\" )' onmouseover='update( \"wizText\", \"Next\" )' onmouseout='update( \"wizText\", \"&nbsp;\" )'>" )
    3.22 +       	    request.write( "<img src='images/previous.png' onclick='doOp( \"prev\" )' onmouseover='update( \"wizText\", \"Previous\" )' onmouseout='update( \"wizText\", \"&nbsp;\" )'>&nbsp;" )
    3.23 +        if currSheet < ( len( self.sheets ) - 2 ):        
    3.24 +            request.write( "<img src='images/next.png' onclick='doOp( \"next\" )' onmouseover='update( \"wizText\", \"Next\" )' onmouseout='update( \"wizText\", \"&nbsp;\" )'>" )
    3.25 +        elif currSheet == ( len( self.sheets ) - 2 ):
    3.26 +            request.write( "<img src='images/finish.png' onclick='doOp( \"next\" )' onmouseover='update( \"wizText\", \"Finish\" )' onmouseout='update( \"wizText\", \"&nbsp;\" )'>" )
    3.27          request.write( "</p><p align='center'><span id='wizText'></span></p></td></tr></table>" )
    3.28          request.write( "</td></tr></table>" )
    3.29          
    3.30 @@ -49,14 +54,17 @@ class Wizard( HTMLBase ):
    3.31      	pass
    3.32          
    3.33      def op_prev( self, request ):
    3.34 +    	pass
    3.35 +        
    3.36 +    def op_finish( self, request ):
    3.37      	pass  
    3.38          
    3.39  class Sheet( HTMLBase ):
    3.40  
    3.41 -    def __init__( self, urlWriter, feilds, title, location ):
    3.42 +    def __init__( self, urlWriter, title, location ):
    3.43          HTMLBase.__init__( self )
    3.44          self.urlWriter = urlWriter
    3.45 -        self.feilds = feilds
    3.46 +        self.feilds = []
    3.47          self.title = title
    3.48          self.location = location
    3.49          self.passback = "()"
    3.50 @@ -71,9 +79,9 @@ class Sheet( HTMLBase ):
    3.51          if temp_passback is not None and len( temp_passback ) > 0:
    3.52              temp_passback = temp_passback[ len( temp_passback )-1 ]
    3.53          else:
    3.54 -            temp_passback = "(passback )"        
    3.55 +            temp_passback = "( )"        
    3.56          
    3.57 -        last_passback = ssxp2hash( string2sxp( temp_passback ) )
    3.58 +        last_passback = ssxp2hash( string2sxp( temp_passback ) ) #use special function - will work with no head on sxp
    3.59          
    3.60          if DEBUG: print last_passback
    3.61          
    3.62 @@ -90,22 +98,76 @@ class Sheet( HTMLBase ):
    3.63          
    3.64          if DEBUG: print self.passback
    3.65          
    3.66 -        return last_passback #return the hash
    3.67 -        
    3.68      def write_BODY( self, request ):
    3.69          
    3.70     	request.write( "<p>%s</p>" % self.title )
    3.71      
    3.72 -    	previous_values = self.parseForm( request ) #get the hash for quick reference
    3.73 +    	previous_values = sxp2hash( string2sxp( self.passback ) ) #get the hash for quick reference
    3.74 +        
    3.75 +        request.write( "<table width='100%' cellpadding='0' cellspacing='1' border='0'>" )
    3.76 +        
    3.77 +    	for (feild, control) in self.feilds:
    3.78 +            control.write_Control( request, previous_values.get( feild ) )
    3.79 +            
    3.80 +        request.write( "</table>" )
    3.81 +            
    3.82 +        request.write( "<input type='hidden' name='passback' value=\"%s\"></p>" % self.passback )
    3.83 +        request.write( "<input type='hidden' name='sheet' value='%s'></p>" % self.location )
    3.84 +        
    3.85 +    def addControl( self, control ):
    3.86 +    	self.feilds.append( [ control.getName(), control ] )
    3.87 +        
    3.88 +class SheetControl( HTMLBase ):
    3.89 +
    3.90 +    def __init__( self ):
    3.91 +        HTMLBase.__init__( self )
    3.92 +        self.name = ""
    3.93 +        
    3.94 +    def write_Control( self, request, persistedValue ):
    3.95 +        request.write( "<tr colspan='2'><td>%s</td></tr>" % persistedValue )
    3.96 +        
    3.97 +    def validate( self ):
    3.98 +    	return True
    3.99 +        
   3.100 +    def getName( self ):
   3.101 +    	return self.name
   3.102 +        
   3.103 +    def setName( self, name ):
   3.104 +    	self.name = name
   3.105          
   3.106 -    	for (feild, name) in self.feilds:
   3.107 -            value = previous_values.get( feild )
   3.108 -            if value is None:
   3.109 -            	value = ''
   3.110 -            request.write( "<p>%s<input type='text' name='%s' value='%s'></p>" % (name, feild, value) )
   3.111 +class InputControl( SheetControl ):
   3.112 +
   3.113 +    def __init__( self, name, defaultValue, humanText):
   3.114 +        SheetControl.__init__( self )
   3.115 +        self.setName( name )
   3.116 +        
   3.117 +        self.defaultValue = defaultValue
   3.118 +        self.humanText = humanText
   3.119 +        
   3.120 +    def write_Control( self, request, persistedValue ):
   3.121 +    	if persistedValue is None:
   3.122 +            persistedValue = self.defaultValue
   3.123          
   3.124 -        request.write( "<input type='hidden' name='passback' value=\"%s\"></p>" % self.passback )
   3.125 -        request.write( "<input type='hidden' name='sheet' value='%s'></p>" % self.location )        
   3.126 +        request.write( "<tr><td width='50%%'><p>%s</p></td><td width='50%%'><input type='text' name='%s' value=\"%s\"></td></tr>" % (self.humanText, self.getName(), persistedValue) )
   3.127 +
   3.128 +class TextControl( SheetControl ):
   3.129 +
   3.130 +    def __init__( self, text ):
   3.131 +    	SheetControl.__init__( self )
   3.132 +        self.text = text
   3.133 +        
   3.134 +    def write_Control( self, request, persistedValue ):
   3.135 +    	request.write( "<tr><td colspan='2'><p>%s</p></td></tr>" % self.text )
   3.136 +
   3.137 +class SmallTextControl( SheetControl ):
   3.138 +
   3.139 +    def __init__( self, text ):
   3.140 +    	SheetControl.__init__( self )
   3.141 +        self.text = text
   3.142 +        
   3.143 +    def write_Control( self, request, persistedValue ):
   3.144 +    	request.write( "<tr><td colspan='2'><p class='small'>%s</p></tr></td>" % self.text )
   3.145 +        
   3.146                   
   3.147              
   3.148      
     4.1 --- a/tools/python/xen/sv/util.py	Wed Jul 28 15:35:54 2004 +0000
     4.2 +++ b/tools/python/xen/sv/util.py	Wed Jul 28 15:41:31 2004 +0000
     4.3 @@ -13,10 +13,11 @@ def sxp2hash( s ):
     4.4      sxphash = {}
     4.5          
     4.6      for child in sxp.children( s ):
     4.7 -    	if child is types.ListType:
     4.8 -            sxphash[ child[0] ] = sxp2hash( child[1] )
     4.9 -        else:
    4.10 -            sxphash[ child[0] ] = child[1]
    4.11 +    	if isinstance( child, types.ListType ) and len( child ) > 1:
    4.12 +            if isinstance( child[1], types.ListType ) and len( child ) > 1:
    4.13 +                sxphash[ child[0] ] = sxp2hash( child[1] )
    4.14 +            else:
    4.15 +                sxphash[ child[0] ] = child[1]
    4.16          
    4.17      return sxphash  
    4.18      
     5.1 --- a/tools/sv/Makefile	Wed Jul 28 15:35:54 2004 +0000
     5.2 +++ b/tools/sv/Makefile	Wed Jul 28 15:41:31 2004 +0000
     5.3 @@ -36,7 +36,8 @@ install:
     5.4          
     5.5  	install -m0644 images/next.png $(sv_insdir)/images
     5.6  	install -m0644 images/previous.png $(sv_insdir)/images        
     5.7 -
     5.8 +	install -m0644 images/finish.png $(sv_insdir)/images 
     5.9 +        
    5.10  	# make include folder
    5.11  	mkdir -p $(sv_insdir)/inc
    5.12  	
     6.1 Binary file tools/sv/images/finish.png has changed