diff --git a/.rootkeys b/.rootkeys index 5f63542b10..d09ef0e183 100644 --- a/.rootkeys +++ b/.rootkeys @@ -371,6 +371,7 @@ 40dc4076St6AmPTmQPrtQ6LGHPxGmw tools/python/xen/lowlevel/xu/__init__.py 40dc4076pVeE1kEEWzcUaNZin65kCA tools/python/xen/lowlevel/xu/domain_controller.h 40dc4076CwBYRTUQDdbdU1L6KcLgSw tools/python/xen/lowlevel/xu/xu.c +41052eb84_irpx0E9N_kqBp9eoin5g tools/python/xen/sv/CreateDomain.py 40fcefb2qm13BbRZBydAatOavaS0fQ tools/python/xen/sv/DomInfo.py 40fcefb2-RIU8GB67mJMRzybME9bxw tools/python/xen/sv/DomList.py 40fcefb23FfQn-ZBCbcHqA0cPGqQxw tools/python/xen/sv/GenTabbed.py @@ -378,6 +379,7 @@ 40fcefb2vnfDbl4w_yCTedROPuqs0g tools/python/xen/sv/Main.py 40fcefb24h-04WaHag-Tg4nxWPhTig tools/python/xen/sv/NodeInfo.py 40fcefb2Sif__6AqrANeBQZZfvP-6w tools/python/xen/sv/TabView.py +41052eb8UrgtUkuJPg7oY1tutVQHsg tools/python/xen/sv/Wizzard.py 40fcefb2DqteqCCZYDCvvh4Q5jBd0w tools/python/xen/sv/__init__.py 40fcefb4rnaZNjqsBu7A5V2rlLyqRw tools/python/xen/sv/util.py 40d8915cyoVA0hJxiBFNymL7YvDaRg tools/python/xen/util/Brctl.py @@ -442,9 +444,11 @@ 40fcefb3K6ESt5sQhD9aCQRscQIlXQ tools/sv/images/left-end-no-highlight.jpg 40fcefb3BUT98zPzW8kAFKuxGdh4XA tools/sv/images/middle-highlight.jpg 40fcefb38OTgsUKHBpwshLLIsiIaCA tools/sv/images/middle-no-highlight.jpg +41052eb9SDUqSLGtG6rxk6Ep5fOhFA tools/sv/images/next.png 40fcefb32SPtrw36c4S6YGFlLvkKuw tools/sv/images/orb_01.jpg 40fcefb3Ok5qkX3iM7ZEPVkRInrUpg tools/sv/images/orb_02.jpg 4104ffca9_GhWOxRE-83uZIad2Z1gg tools/sv/images/pause.png +41052eb9NQqHe_f9-ev1CaA3y5YYZg tools/sv/images/previous.png 41013a82ILk71xLqWFH5ZO5VmOIvBw tools/sv/images/reboot.png 40fcefb3JnT5XeKTuVF4yUMGOtuNZg tools/sv/images/right-end-highlight.jpg 40fcefb3-DuYOS7noo2W7b_0p7TOUg tools/sv/images/right-end-no-highlight.jpg diff --git a/tools/python/xen/sv/CreateDomain.py b/tools/python/xen/sv/CreateDomain.py new file mode 100644 index 0000000000..13c45d8622 --- /dev/null +++ b/tools/python/xen/sv/CreateDomain.py @@ -0,0 +1,43 @@ +from xen.sv.Wizzard import Wizzard, Sheet + +class CreateDomain( Wizzard ): + def __init__( self, urlWriter ): + + sheets = { 0: CreatePage0, + 1: CreatePage1, + 2: CreatePage2, + 3: CreatePage3 } + + Wizzard.__init__( self, urlWriter, "Create Domain Wizzard", sheets ) + +class CreatePage0( Sheet ): + + def __init__( self, urlWriter ): + + feilds = [( 'name', 'Name')] + + Sheet.__init__( self, urlWriter, feilds, "Create New Domain - 1" ) + +class CreatePage1( Sheet ): + + def __init__( self, urlWriter ): + + feilds = [( 'name', 'Name')] + + Sheet.__init__( self, urlWriter, feilds, "Create New Domain - 2" ) + +class CreatePage2( Sheet ): + + def __init__( self, urlWriter ): + + feilds = [( 'name', 'Name')] + + Sheet.__init__( self, urlWriter, feilds, "Create New Domain - 3" ) + +class CreatePage3( Sheet ): + + def __init__( self, urlWriter ): + + feilds = [( 'name', 'Name')] + + Sheet.__init__( self, urlWriter, feilds, "Create New Domain - 4" ) \ No newline at end of file diff --git a/tools/python/xen/sv/DomInfo.py b/tools/python/xen/sv/DomInfo.py index 7e23ab792d..6f8ac1ab5b 100755 --- a/tools/python/xen/sv/DomInfo.py +++ b/tools/python/xen/sv/DomInfo.py @@ -12,7 +12,7 @@ class DomInfo( GenTabbed ): self.dom = 0; def tabUrlWriter( tab ): - return urlWriter( "mod=info&dom=%s%s" % ( self.dom, tab ) ) + return urlWriter( "&dom=%s%s" % ( self.dom, tab ) ) GenTabbed.__init__( self, "Domain Info", tabUrlWriter, [ 'General', 'SXP', 'Devices' ], [ DomGeneralTab, DomSXPTab, NullTab ] ) @@ -52,13 +52,11 @@ class DomGenTab( GeneralTab ): def write_BODY( self, request ): - dom = request.args.get('dom') + self.dom = getVar('dom', request) - if dom is None or len(dom) != 1: + if self.dom is None: request.write( "

Please Select a Domain

" ) return None - else: - self.dom = dom[0] self.dict = getDomInfoHash( self.dom ) @@ -72,17 +70,15 @@ class DomSXPTab( PreTab ): def write_BODY( self, request ): - dom = request.args.get('dom') + self.dom = getVar('dom', request) - if dom is None or len(dom) != 1: + if self.dom is None: request.write( "

Please Select a Domain

" ) return None - else: - self.dom = dom[0] - + domInfo = server.xend_domain( self.dom ) - self.source = sxp2string( domInfo ) + self.source = sxp2prettystring( domInfo ) PreTab.write_BODY( self, request ) diff --git a/tools/python/xen/sv/DomList.py b/tools/python/xen/sv/DomList.py index 82f7cc424b..145016cded 100755 --- a/tools/python/xen/sv/DomList.py +++ b/tools/python/xen/sv/DomList.py @@ -43,7 +43,7 @@ class DomList( HTMLBase ): def write_DOMAIN( self, request, domInfoHash, long=True ): request.write( "%(dom)-4d\n" % domInfoHash ) - url = self.urlWriter( "mod=info&dom=%(dom)-4d" % domInfoHash ) + url = self.urlWriter( "&mod=info&dom=%(dom)-4d" % domInfoHash ) request.write( "%s\n" % ( url, domInfoHash['name'] ) ) if long: diff --git a/tools/python/xen/sv/GenTabbed.py b/tools/python/xen/sv/GenTabbed.py index 1d5bd2d22a..aef1848e7a 100755 --- a/tools/python/xen/sv/GenTabbed.py +++ b/tools/python/xen/sv/GenTabbed.py @@ -2,35 +2,31 @@ import types from xen.sv.HTMLBase import HTMLBase from xen.sv.TabView import TabView +from xen.sv.util import getVar class GenTabbed( HTMLBase ): def __init__( self, title, urlWriter, tabStrings, tabObjects ): HTMLBase.__init__(self) - self.tab = 0; self.tabStrings = tabStrings self.tabObjects = tabObjects self.urlWriter = urlWriter self.title = title def write_BODY( self, request, urlWriter = None ): - tab = request.args.get('tab') - - if tab is None or len( tab) != 1: - self.tab = 0 - else: - self.tab = int( tab[0] ) + + tab = int( getVar( 'tab', request, 0 ) ) request.write( "" ) request.write( "
" ) request.write( "

%s

" % self.title ) - TabView( self.tab, self.tabStrings, self.urlWriter ).write_BODY( request ) + TabView( tab, self.tabStrings, self.urlWriter ).write_BODY( request ) request.write( "
" ) - render_tab = self.tabObjects[ self.tab ] + render_tab = self.tabObjects[ tab ] if render_tab is None: request.write( "

Bad Tab

" ) @@ -41,14 +37,9 @@ class GenTabbed( HTMLBase ): request.write( "
" ) def perform( self, request ): - tab = request.args.get('tab') - - if tab is None or len( tab) != 1: - self.tab = 0 - else: - self.tab = int( tab[0] ) + tab = int( getVar( 'tab', request, 0 ) ) - op_tab = self.tabObjects[ self.tab ] + op_tab = self.tabObjects[ tab ] if op_tab: op_tab().perform( request ) diff --git a/tools/python/xen/sv/Main.py b/tools/python/xen/sv/Main.py index 9de097a1d4..bf6119c600 100755 --- a/tools/python/xen/sv/Main.py +++ b/tools/python/xen/sv/Main.py @@ -2,35 +2,40 @@ from xen.sv.HTMLBase import HTMLBase from xen.sv.DomList import DomList from xen.sv.NodeInfo import NodeInfo from xen.sv.DomInfo import DomInfo +from xen.sv.CreateDomain import CreateDomain + +from xen.sv.util import getVar class Main( HTMLBase ): isLeaf = True def __init__( self, urlWriter = None ): - self.modules = { "node": ( "Node details", NodeInfo ), - "list": ( "Domain summary", DomList ), - "info": ( "Domain info", DomInfo ) } + self.modules = { "node": NodeInfo, + "list": DomList, + "info": DomInfo, + "create": CreateDomain } HTMLBase.__init__(self) def render_POST( self, request ): #decide what module post'd the action - mod = request.args.get('mod') + mod = getVar( 'mod', request ) - if not mod is None and len(mod) == 1: - modTup = self.modules[ mod[0] ] + if not mod is None: + module = self.modules[ mod ] #check module exists - if modTup: - (modName, module) = modTup + if module: module( self.mainUrlWriter ).perform( request ) return self.render_GET( request ) - def mainUrlWriter( self, s ): - return "Main.rpy?%s" % s - + def mainUrlWriter( self, module ): + def fun( f ): + return "Main.rpy?mod=%s%s" % ( module, f ) + return fun + def write_BODY( self, request ): request.write( "\n\n" ) @@ -43,8 +48,8 @@ class Main( HTMLBase ): request.write( " ") request.write( " " ) request.write( "

SV Web Interface
(C) Tom Wilkie 2004

" ) - for (modName, (modTitle, module)) in self.modules.items(): - module( self.mainUrlWriter ).write_MENU( request ) + for (modName, module) in self.modules.items(): + module( self.mainUrlWriter( modName ) ).write_MENU( request ) request.write( "
" ) @@ -56,15 +61,14 @@ class Main( HTMLBase ): request.write( " " ) request.write( " " ) - mod = request.args.get('mod') + modName = getVar('mod', request) - if mod is None or len(mod) != 1: + if modName is None: request.write( '

Please select a module

' ) else: - modTup = self.modules[ mod[0] ] - if modTup: - (modName, module) = modTup - module( self.mainUrlWriter ).write_BODY( request ) + module = self.modules[ modName ] + if module: + module( self.mainUrlWriter( modName ) ).write_BODY( request ) else: request.write( '

Invalid module. Please select another

' ) diff --git a/tools/python/xen/sv/NodeInfo.py b/tools/python/xen/sv/NodeInfo.py index a3aac1d34c..948acef4b6 100755 --- a/tools/python/xen/sv/NodeInfo.py +++ b/tools/python/xen/sv/NodeInfo.py @@ -7,10 +7,7 @@ class NodeInfo( GenTabbed ): def __init__( self, urlWriter ): - def newUrlWriter( url ): - return urlWriter( "mod=node%s" % url ) - - GenTabbed.__init__( self, "Node Details", newUrlWriter, [ 'General', 'Dmesg', ], [ NodeGeneralTab, NodeDmesgTab ] ) + GenTabbed.__init__( self, "Node Details", urlWriter, [ 'General', 'Dmesg', ], [ NodeGeneralTab, NodeDmesgTab ] ) def write_MENU( self, request ): request.write( "

Node details

" % self.urlWriter( '' ) ) diff --git a/tools/python/xen/sv/Wizzard.py b/tools/python/xen/sv/Wizzard.py new file mode 100755 index 0000000000..0f506d03b8 --- /dev/null +++ b/tools/python/xen/sv/Wizzard.py @@ -0,0 +1,66 @@ +from xen.sv.util import * +from xen.sv.HTMLBase import HTMLBase +from xen.xend import sxp + +class Wizzard( HTMLBase ): + + def __init__( self, urlWriter, title, sheets ): + HTMLBase.__init__( self ) + self.title = title + self.sheets = sheets + self.currSheet = 0 + self.urlWriter = urlWriter + + def write_MENU( self, request ): + request.write( "

%s

" % (self.urlWriter( '' ), self.title) ) + + def write_BODY( self, request ): + + request.write( "
" ) + request.write( "

%s

" % self.title ) + + currSheet = getVar( 'sheet', request ) + + if not currSheet is None: + + self.currSheet = int( currSheet ) + + self.sheets[ self.currSheet ]( self.urlWriter ).write_BODY( request ) + + request.write( "
" ) + request.write( "
" ) + request.write( "

 " ) + request.write( "

" ) + request.write( "

" ) + request.write( "
" ) + +class Sheet( HTMLBase ): + + def __init__( self, urlWriter, feilds, title ): + HTMLBase.__init__( self ) + self.urlWriter = urlWriter + self.feilds = feilds + self.title = title + + def parseForm( self, request ): + return sxp.toString( request.args ) + + def write_BODY( self, request ): + request.write( "

%s

" % self.title ) + + previous_values = request.args + + for (feild, name) in self.feilds: + value = sxp.child_value( previous_values, feild ) + if value is None: + value = '' + request.write( "

%s

" % (name, feild, value) ) + + def op_next( self, request ): + pass + + def op_prev( self, request ): + pass + + + diff --git a/tools/python/xen/sv/util.py b/tools/python/xen/sv/util.py index 57940d9287..adf75b073c 100755 --- a/tools/python/xen/sv/util.py +++ b/tools/python/xen/sv/util.py @@ -18,9 +18,9 @@ def sxp2hash( s ): else: sxphash[ child[0] ] = child[1] - return sxphash + return sxphash -def sxp2string( sxp ): +def sxp2prettystring( sxp ): class tmp: def __init__( self ): self.str = "" @@ -30,14 +30,14 @@ def sxp2string( sxp ): PrettyPrint.prettyprint( sxp, out=temp ) return temp.str -def getVar( var, request ): +def getVar( var, request, default=None ): arg = request.args.get( var ) - if arg is None or len(arg) != 1: - return None + if arg is None: + return default else: - return arg[0] + return arg[ len( arg )-1 ] def bigTimeFormatter( time ): time = float( time ) diff --git a/tools/sv/Makefile b/tools/sv/Makefile index 8a63d4ac1b..b8f2a7a116 100755 --- a/tools/sv/Makefile +++ b/tools/sv/Makefile @@ -33,6 +33,9 @@ install: install -m0644 images/reboot.png $(sv_insdir)/images install -m0644 images/pause.png $(sv_insdir)/images install -m0644 images/unpause.png $(sv_insdir)/images + + install -m0644 images/next.png $(sv_insdir)/images + install -m0644 images/previous.png $(sv_insdir)/images # make include folder mkdir -p $(sv_insdir)/inc diff --git a/tools/sv/images/next.png b/tools/sv/images/next.png new file mode 100644 index 0000000000..da10bbfb9b Binary files /dev/null and b/tools/sv/images/next.png differ diff --git a/tools/sv/images/previous.png b/tools/sv/images/previous.png new file mode 100644 index 0000000000..22292d6e9c Binary files /dev/null and b/tools/sv/images/previous.png differ