ia64/xen-unstable

changeset 1966:ac93dc78a47d

bitkeeper revision 1.1108.32.1 (4107e4e2YMdWDsDVr_ptn6faQ7KwmA)

Virtually finished Domain Creation from sv.
Needs work to make it more robust.
author tw275@labyrinth.cl.cam.ac.uk
date Wed Jul 28 17:39:46 2004 +0000 (2004-07-28)
parents 6daa82a1130a
children 6670d27fd5df
files tools/python/xen/sv/CreateDomain.py
line diff
     1.1 --- a/tools/python/xen/sv/CreateDomain.py	Wed Jul 28 15:41:31 2004 +0000
     1.2 +++ b/tools/python/xen/sv/CreateDomain.py	Wed Jul 28 17:39:46 2004 +0000
     1.3 @@ -1,5 +1,10 @@
     1.4  from xen.sv.Wizard import *
     1.5  from xen.sv.util import *
     1.6 +from xen.sv.GenTabbed import PreTab
     1.7 +
     1.8 +from xen.xm.create import make_config
     1.9 +
    1.10 +from xen.xend.XendClient import server
    1.11  
    1.12  class CreateDomain( Wizard ):
    1.13      def __init__( self, urlWriter ):
    1.14 @@ -17,15 +22,17 @@ class CreatePage0( Sheet ):
    1.15  
    1.16      def __init__( self, urlWriter ):
    1.17          Sheet.__init__( self, urlWriter, "General", 0 )
    1.18 -        self.addControl( InputControl( 'vm_name', 'VM Name', 'VM Name:' ) )
    1.19 +        self.addControl( InputControl( 'name', 'VM Name', 'VM Name:' ) )
    1.20          self.addControl( InputControl( 'memory', '64', 'Memory (Mb):' ) )
    1.21 +        self.addControl( InputControl( 'cpu', '0', 'CPU:' ) )
    1.22                          
    1.23  class CreatePage1( Sheet ):
    1.24  
    1.25      def __init__( self, urlWriter ):
    1.26          Sheet.__init__( self, urlWriter, "Setup Kernel Image", 1 )
    1.27 -        self.addControl( InputControl( 'kernel_image', '/boot/vmlinuz-2.4.26-xenU', 'Kernel Image:' ) )
    1.28 -        self.addControl( InputControl( 'kernel_params', '', 'Kernel Command Line Parame:' ) )
    1.29 +        self.addControl( InputControl( 'builder', 'linux', 'Kernel Type:' ) )
    1.30 +        self.addControl( InputControl( 'kernel', '/boot/vmlinuz-2.4.26-xenU', 'Kernel Image:' ) )
    1.31 +        self.addControl( InputControl( 'extra', '', 'Kernel Command Line Parame:' ) )
    1.32  
    1.33  class CreatePage2( Sheet ):
    1.34  
    1.35 @@ -45,8 +52,9 @@ class CreatePage3( Sheet ):
    1.36          for i in range( int( num_vbds ) ):
    1.37              self.addControl( InputControl( 'vbd%s_dom0' % i, '/dev/sda%i' % i, 'Device %s name:' % i  ) )
    1.38              self.addControl( InputControl( 'vbd%s_domU' % i, '/dev/sda%i' % i, 'Virtualized device %s:' % i ) )
    1.39 +            self.addControl( InputControl( 'vbd%s_mode' % i, 'w', 'Device %s mode:' % i ) )
    1.40              
    1.41 -        self.addControl( InputControl( 'root_dev', '/dev/sda1', 'Root device (in VM):' ) )
    1.42 +        self.addControl( InputControl( 'root', '/dev/sda1', 'Root device (in VM):' ) )
    1.43          
    1.44          Sheet.write_BODY( self, request )
    1.45                  
    1.46 @@ -65,6 +73,58 @@ class CreateFinish( Sheet ):
    1.47          Sheet.__init__( self, urlWriter, "All Done", 5 )
    1.48          
    1.49      def write_BODY( self, request ):
    1.50 -    	request.write( "<pre>%s</pre>" % sxp2prettystring( string2sxp( self.passback ) ) )
    1.51 +    	fin_sxp = string2sxp( self.passback )
    1.52 +    
    1.53 +        xend_sxp = self.translate_sxp( fin_sxp )
    1.54 +        
    1.55 +        pt = PreTab( sxp2prettystring( xend_sxp ) )
    1.56 +        pt.write_BODY( request )
    1.57 +        
    1.58 +        server.xend_domain_create( xend_sxp )
    1.59 +       
    1.60          request.write( "<input type='hidden' name='passback' value=\"%s\"></p>" % self.passback )
    1.61          request.write( "<input type='hidden' name='sheet' value='%s'></p>" % self.location )
    1.62 +    
    1.63 +    def translate_sxp( self, fin_sxp ):
    1.64 +   	fin_hash = ssxp2hash( fin_sxp )
    1.65 +    
    1.66 +    	vals = OptVals()
    1.67 +        
    1.68 +        setattr(vals, "name", 	fin_hash.get( 'name' ) )
    1.69 +        setattr(vals, "memory", fin_hash.get( 'memory' ) )
    1.70 +        setattr(vals, "cpu", 	fin_hash.get( 'cpu' ) )
    1.71 +        
    1.72 +        setattr(vals, "builder", 	fin_hash.get( 'builder' ) )        
    1.73 +        setattr(vals, "kernel", 	fin_hash.get( 'kernel' ) )
    1.74 +	setattr(vals, "root", 		fin_hash.get( 'root' ) )
    1.75 +        setattr(vals, "extra", 		fin_hash.get( 'extra' ) ) 
    1.76 +        
    1.77 +        vbds = []
    1.78 +        
    1.79 +        for i in range( int( fin_hash.get( 'num_vbds' ) ) ):
    1.80 +            vbds.append( ( fin_hash.get('vbd%s_domU' % i ), fin_hash.get( 'vbd%s_dom0' % i ), fin_hash.get( 'vbd%s_mode' % i ) ) )
    1.81 +        
    1.82 +        vals.disk = vbds    
    1.83 +            
    1.84 +        vals.pci = []
    1.85 +        
    1.86 +        vals.vif = []
    1.87 +        vals.nics = 1
    1.88 +        
    1.89 +        vals.blkif = None
    1.90 +        vals.netif = None
    1.91 +        vals.restart = None
    1.92 +        vals.console = None
    1.93 +        vals.ramdisk = None
    1.94 +        
    1.95 +        #todo: setup ip addr stuff
    1.96 +        
    1.97 +        vals.cmdline_ip = None
    1.98 +        
    1.99 +        return make_config( vals )
   1.100 +
   1.101 +        
   1.102 +class OptVals:
   1.103 +    """Class to hold option values.
   1.104 +    """
   1.105 +    pass
   1.106 \ No newline at end of file