direct-io.hg
changeset 1835:15f6d38481b0
bitkeeper revision 1.1108.2.7 (40fcf080LWtcDHL3kwES2Lj8iJCtPA)
Merge scramble.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into scramble.cl.cam.ac.uk:/local/scratch/kaf24/xeno
Merge scramble.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into scramble.cl.cam.ac.uk:/local/scratch/kaf24/xeno
line diff
1.1 --- a/.rootkeys Tue Jul 20 10:04:22 2004 +0000 1.2 +++ b/.rootkeys Tue Jul 20 10:14:24 2004 +0000 1.3 @@ -365,6 +365,35 @@ 40d83983OXjt-y3HjSCcuoPp9rzvmw tools/pyt 1.4 40c9c469yrm31i60pGKslTi2Zgpotg tools/python/xen/xend/server/messages.py 1.5 40c9c46925x-Rjb0Cv2f1-l2jZrPYg tools/python/xen/xend/server/netif.py 1.6 40c9c469ZqILEQ8x6yWy0_51jopiCg tools/python/xen/xend/server/params.py 1.7 +40fcefb2qm13BbRZBydAatOavaS0fQ tools/python/xen/xend/sv/DomInfo.py 1.8 +40fcefb2-RIU8GB67mJMRzybME9bxw tools/python/xen/xend/sv/DomList.py 1.9 +40fcefb23FfQn-ZBCbcHqA0cPGqQxw tools/python/xen/xend/sv/GenTabbed.py 1.10 +40fcefb2QZAn3u3sX-M7NXBjOv5HGg tools/python/xen/xend/sv/HTMLBase.py 1.11 +40fcefb2vnfDbl4w_yCTedROPuqs0g tools/python/xen/xend/sv/Main.py 1.12 +40fcefb2K1xqVVT4D-p7nL2GzS4scg tools/python/xen/xend/sv/Main.rpy 1.13 +40fcefb24h-04WaHag-Tg4nxWPhTig tools/python/xen/xend/sv/NodeInfo.py 1.14 +40fcefb2Sif__6AqrANeBQZZfvP-6w tools/python/xen/xend/sv/TabView.py 1.15 +40fcefb23s0sQlDfl4sPP0Un8oZGhg tools/python/xen/xend/sv/XendClientDeferred.py 1.16 +40fcefb2DqteqCCZYDCvvh4Q5jBd0w tools/python/xen/xend/sv/__init__.py 1.17 +40fcefb2Nhe-sT74KBB_3mYQg9Dl4Q tools/python/xen/xend/sv/images/internet copy.jpg 1.18 +40fcefb2QmVa4xdjdnSTXEdF2fZCDA tools/python/xen/xend/sv/images/internet.jpg 1.19 +40fcefb2g8Ez5jJIPHGN_KX7GtxV4w tools/python/xen/xend/sv/images/internet.psd 1.20 +40fcefb3wXQMsl9WkgQAVtdrupm4sw tools/python/xen/xend/sv/images/left-end-highlight.jpg 1.21 +40fcefb3K6ESt5sQhD9aCQRscQIlXQ tools/python/xen/xend/sv/images/left-end-no-highlight.jpg 1.22 +40fcefb3BUT98zPzW8kAFKuxGdh4XA tools/python/xen/xend/sv/images/middle-highlight.jpg 1.23 +40fcefb38OTgsUKHBpwshLLIsiIaCA tools/python/xen/xend/sv/images/middle-no-highlight.jpg 1.24 +40fcefb32SPtrw36c4S6YGFlLvkKuw tools/python/xen/xend/sv/images/orb_01.jpg 1.25 +40fcefb3Ok5qkX3iM7ZEPVkRInrUpg tools/python/xen/xend/sv/images/orb_02.jpg 1.26 +40fcefb3JnT5XeKTuVF4yUMGOtuNZg tools/python/xen/xend/sv/images/right-end-highlight.jpg 1.27 +40fcefb3-DuYOS7noo2W7b_0p7TOUg tools/python/xen/xend/sv/images/right-end-no-highlight.jpg 1.28 +40fcefb3qNbAZR5FYGPAZ9sFPVMTDA tools/python/xen/xend/sv/images/seperator-left-highlight.jpg 1.29 +40fcefb3dgsa24WLk_BJeYQHrDLuOg tools/python/xen/xend/sv/images/seperator-right-highlight.jpg 1.30 +40fcefb3FtiX4Pd2kT8wDlp8u8xRhQ tools/python/xen/xend/sv/images/seperator.jpg 1.31 +40fcefb3yMSrZvApO9ToIi-iQwnchA tools/python/xen/xend/sv/images/xen.png 1.32 +40fcefb310mW7U0p7JMoBQVnjf76xg tools/python/xen/xend/sv/inc/bottom.htm 1.33 +40fcefb3zGC9XNBkSwTEobCoq8YClA tools/python/xen/xend/sv/inc/style.css 1.34 +40fcefb4oxovdYkUvExZSkHN0cy_Ow tools/python/xen/xend/sv/inc/top.htm 1.35 +40fcefb4rnaZNjqsBu7A5V2rlLyqRw tools/python/xen/xend/sv/util.py 1.36 40c9c469LNxLVizOUpOjEaTKKCm8Aw tools/python/xen/xend/sxp.py 1.37 40d05079aFRp6NQdo5wIh5Ly31c0cg tools/python/xen/xm/__init__.py 1.38 40cf2937gKQcATgXKGtNeWb1PDH5nA tools/python/xen/xm/create.py
2.1 --- a/tools/python/xen/xend/server/SrvServer.py Tue Jul 20 10:04:22 2004 +0000 2.2 +++ b/tools/python/xen/xend/server/SrvServer.py Tue Jul 20 10:14:24 2004 +0000 2.3 @@ -25,8 +25,8 @@ 2.4 # todo Support security settings etc. in the config file. 2.5 # todo Support command-line args. 2.6 2.7 -from twisted.web import server 2.8 -from twisted.web import resource 2.9 +from twisted.web import server, static 2.10 +from twisted.web import resource, script 2.11 from twisted.internet import reactor 2.12 2.13 from xen.xend import XendRoot 2.14 @@ -44,8 +44,12 @@ def create(port=None, interface=None, br 2.15 if bridge or xroot.rebooted: 2.16 Vifctl.network('start') 2.17 root = resource.Resource() 2.18 + sv = static.File( "/usr/lib/python2.2/site-packages/xen/xend/sv/" ) 2.19 + sv.indexNames=['Main.rpy'] 2.20 + sv.processors={'.rpy':script.ResourceScript} 2.21 xend = SrvRoot() 2.22 root.putChild('xend', xend) 2.23 + root.putChild('sv', sv) 2.24 site = server.Site(root) 2.25 reactor.listenTCP(port, site, interface=interface) 2.26
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/tools/python/xen/xend/sv/DomInfo.py Tue Jul 20 10:14:24 2004 +0000 3.3 @@ -0,0 +1,99 @@ 3.4 +from HTMLBase import HTMLBase 3.5 +from XendClientDeferred import server 3.6 +from xen.xend import PrettyPrint 3.7 + 3.8 +from xen.xend.sv.util import * 3.9 +from xen.xend.sv.GenTabbed import * 3.10 + 3.11 +class DomInfo( GenTabbed ): 3.12 + 3.13 + def __init__( self, urlWriter, callback ): 3.14 + 3.15 + self.dom = 0; 3.16 + 3.17 + def tabUrlWriter( tab ): 3.18 + return urlWriter( "mod=info&dom=%s%s" % ( self.dom, tab ) ) 3.19 + 3.20 + GenTabbed.__init__( self, tabUrlWriter, [ 'General', 'SXP', 'Devices' ], [ DomGenTab, DomSXPTab, NullTab ], callback ) 3.21 + 3.22 + def write_BODY( self, request ): 3.23 + dom = request.args.get('dom') 3.24 + 3.25 + if dom is None or len(dom) != 1: 3.26 + request.write( "<p>Please Select a Domain</p>" ) 3.27 + return None 3.28 + else: 3.29 + self.dom = dom[0] 3.30 + 3.31 + GenTabbed.write_BODY( self, request ) 3.32 + 3.33 +class DomGenTab( GeneralTab ): 3.34 + 3.35 + def __init__( self ): 3.36 + 3.37 + titles = {} 3.38 + 3.39 + titles[ 'ID' ] = 'dom' 3.40 + titles[ 'Name' ] = 'name' 3.41 + titles[ 'CPU' ] = 'cpu' 3.42 + titles[ 'Memory' ] = ( 'mem', memoryFormatter ) 3.43 + titles[ 'State' ] = ( 'state', stateFormatter ) 3.44 + titles[ 'Total CPU' ] = ( 'cpu_time', smallTimeFormatter ) 3.45 + titles[ 'Up Time' ] = ( 'up_time', bigTimeFormatter ) 3.46 + 3.47 + GeneralTab.__init__( self, "General Domain Info", {}, titles ) 3.48 + 3.49 + def write_BODY( self, request, callback ): 3.50 + dom = request.args.get('dom') 3.51 + 3.52 + if dom is None or len(dom) != 1: 3.53 + request.write( "<p>Please Select a Domain</p>" ) 3.54 + return None 3.55 + else: 3.56 + self.dom = dom[0] 3.57 + 3.58 + deferred = getDomInfoHash( self.dom ) 3.59 + deferred.addCallback( self.continue_BODY, request, callback ) 3.60 + 3.61 + def continue_BODY( self, dict, request, callback ): 3.62 + 3.63 + self.dict = dict 3.64 + 3.65 + GeneralTab.write_BODY( self, request, callback ) 3.66 + 3.67 +class DomSXPTab( PreTab ): 3.68 + 3.69 + def __init__( self ): 3.70 + self.dom = 0 3.71 + PreTab.__init__( self, "" ) 3.72 + 3.73 + def fn( self, x, request ): 3.74 + class tmp: 3.75 + def __init__( self ): 3.76 + self.str = "" 3.77 + def write( self, str ): 3.78 + self.str = self.str + str 3.79 + temp = tmp() 3.80 + PrettyPrint.prettyprint( x, out=temp ) 3.81 + self.source = temp.str 3.82 + return request 3.83 + 3.84 + def fn2( self, request, callback ): 3.85 + PreTab.write_BODY( self, request, callback ) 3.86 + 3.87 + def write_BODY( self, request, callback ): 3.88 + dom = request.args.get('dom') 3.89 + 3.90 + if dom is None or len(dom) != 1: 3.91 + request.write( "<p>Please Select a Domain</p>" ) 3.92 + return None 3.93 + else: 3.94 + self.dom = dom[0] 3.95 + 3.96 + deferred = server.xend_domain( self.dom ) 3.97 + 3.98 + deferred.addCallback( self.fn, request ) 3.99 + deferred.addCallback( self.fn2, callback ) 3.100 + def errback( x ): 3.101 + print ">err ", x 3.102 + deferred.addErrback( errback ) 3.103 \ No newline at end of file
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/tools/python/xen/xend/sv/DomList.py Tue Jul 20 10:14:24 2004 +0000 4.3 @@ -0,0 +1,101 @@ 4.4 +from twisted.web import resource 4.5 +from twisted.web.server import NOT_DONE_YET 4.6 + 4.7 +from XendClientDeferred import server as XendServer 4.8 +from xen.xend import sxp 4.9 + 4.10 +from xen.xend.sv.HTMLBase import HTMLBase 4.11 +from xen.xend.sv.util import * 4.12 + 4.13 +from twisted.internet import reactor 4.14 + 4.15 +class DomList( HTMLBase ): 4.16 + 4.17 + isLeaf = True 4.18 + 4.19 + def __init__( self, urlWriter, callback ): 4.20 + HTMLBase.__init__(self) 4.21 + self.urlWriter = urlWriter 4.22 + self.head = None 4.23 + self.long = None 4.24 + self.rendered_domains = {} 4.25 + self.domCount = 0 4.26 + self.callback = callback 4.27 + 4.28 + def write_BODY( self, request, head=True, long=True ): 4.29 + deferred = XendServer.xend_domains() 4.30 + deferred.addCallback( self.get_domain_info, request ) 4.31 + deferred.addErrback( self.errback ) 4.32 + 4.33 + self.head = head 4.34 + self.long = long 4.35 + 4.36 + def errback( self, err ): 4.37 + print 'errback>', err 4.38 + 4.39 + def get_domain_info( self, domains, request ): 4.40 + 4.41 + self.domCount = len( domains ) 4.42 + 4.43 + for domain in domains: 4.44 + deferred = getDomInfoHash( domain ) 4.45 + deferred.addCallback( self.render_domain, request ) 4.46 + deferred.addErrback( self.errback ) 4.47 + 4.48 + def render_domain( self, domInfoHash, request ): 4.49 + 4.50 + domStr = "<td class='domainInfo' align='center'>%(dom)-4d</td>\n" % domInfoHash 4.51 + 4.52 + url = self.urlWriter( "mod=info&dom=%(dom)-4d" % domInfoHash ) 4.53 + 4.54 + domStr += "<td class='domainInfo' align='center'><a href='%s'>%s</a></td>\n" % ( url, domInfoHash['name'] ) 4.55 + 4.56 + if self.long: 4.57 + domStr += "<td class='domainInfo' align='center'>%(mem)7d</td>\n" % domInfoHash 4.58 + domStr += "<td class='domainInfo' align='center'>%(cpu)3d</td>\n" % domInfoHash 4.59 + 4.60 + domStr += "<td class='domainInfo' align='center'>%(state)5s</td>\n" % domInfoHash 4.61 + 4.62 + if self.long: 4.63 + domStr += "<td class='domainInfo' align='center'>%(cpu_time)7.1f</td>\n" % domInfoHash 4.64 + 4.65 + self.rendered_domains[ domInfoHash[ 'dom' ] ] = domStr 4.66 + self.domCount -= 1 4.67 + 4.68 + if self.domCount == 0: 4.69 + self.finish_write_BODY( request ) 4.70 + 4.71 + def finish_write_BODY( self, request ): 4.72 + 4.73 + request.write( "\n<table style='border:0px solid white' cellspacing='0' cellpadding='0' border='0' width='100%'>\n" ) 4.74 + 4.75 + if self.head: 4.76 + request.write( "<tr class='domainInfoHead'>" ) 4.77 + self.write_DOMAIN_HEAD( request, self.long ) 4.78 + request.write( "</tr>" ) 4.79 + 4.80 + odd = True 4.81 + for domain in self.rendered_domains.values(): 4.82 + if odd: 4.83 + request.write( "<tr class='domainInfoOdd'>\n" ) 4.84 + odd = False 4.85 + else: 4.86 + request.write( "<tr class='domainInfoEven'>\n" ) 4.87 + odd = True 4.88 + request.write( domain ) 4.89 + request.write( "</tr>\n" ) 4.90 + 4.91 + request.write( "</table>\n" ) 4.92 + 4.93 + self.callback( request ) 4.94 + 4.95 + def write_DOMAIN_HEAD( self, request, long=True ): 4.96 + request.write( "<td class='domainInfoHead' align='center'>Domain</td>\n" ) 4.97 + request.write( "<td class='domainInfoHead' align='center'>Name</td>\n" ) 4.98 + if long: 4.99 + request.write( "<td class='domainInfoHead' align='center'>Memory / Mb</td>\n" ) 4.100 + request.write( "<td class='domainInfoHead' align='center'>CPU</td>\n" ) 4.101 + request.write( "<td class='domainInfoHead' align='center'>State</td>\n" ) 4.102 + if long: 4.103 + request.write( "<td class='domainInfoHead' align='center'>CPU time / s</td>\n" ) 4.104 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/tools/python/xen/xend/sv/GenTabbed.py Tue Jul 20 10:14:24 2004 +0000 5.3 @@ -0,0 +1,103 @@ 5.4 +import types 5.5 + 5.6 +from HTMLBase import HTMLBase 5.7 +from TabView import TabView 5.8 + 5.9 +class GenTabbed( HTMLBase ): 5.10 + 5.11 + def __init__( self, urlWriter, tabStrings, tabObjects, callback ): 5.12 + HTMLBase.__init__(self) 5.13 + self.tab = 0; 5.14 + self.tabStrings = tabStrings 5.15 + self.tabObjects = tabObjects 5.16 + self.urlWriter = urlWriter 5.17 + self.callback = callback 5.18 + 5.19 + def write_BODY( self, request, urlWriter = None ): 5.20 + tab = request.args.get('tab') 5.21 + 5.22 + if tab is None or len( tab) != 1: 5.23 + self.tab = 0 5.24 + else: 5.25 + self.tab = int( tab[0] ) 5.26 + 5.27 + request.write( "<table style='' width='100%' border='0' cellspacing='0' cellpadding='0'>" ) 5.28 + request.write( "<tr><td>" ) 5.29 + 5.30 + TabView( self.tab, self.tabStrings, self.urlWriter ).write_BODY( request ) 5.31 + 5.32 + request.write( "</td></tr><tr><td>" ) 5.33 + 5.34 + render_tab = self.tabObjects[ self.tab ]() 5.35 + 5.36 + if render_tab is None: 5.37 + request.write( "<p>Bad Tab</p>" ) 5.38 + self.finish_BODY( request ) 5.39 + else: 5.40 + render_tab.write_BODY( request, self.finish_BODY ) 5.41 + 5.42 + def finish_BODY( self, request ): 5.43 + 5.44 + request.write( "</td></tr></table>" ) 5.45 + 5.46 + self.callback( request ) 5.47 + 5.48 +class PreTab( HTMLBase ): 5.49 + 5.50 + def __init__( self, source ): 5.51 + HTMLBase.__init__( self ) 5.52 + self.source = source 5.53 + 5.54 + def write_BODY( self, request, callback ): 5.55 + 5.56 + request.write( "<div style='display: block; overflow: auto; border: 0px solid black; height: 400px; width: 540px; padding: 5px; z-index:0; align: center'><pre>" ) 5.57 + 5.58 + request.write( self.source ) 5.59 + 5.60 + request.write( "</pre></div>" ) 5.61 + 5.62 + callback( request ) 5.63 + 5.64 +class GeneralTab( HTMLBase ): 5.65 + 5.66 + def __init__( self, title, dict, titles ): 5.67 + HTMLBase.__init__( self ) 5.68 + self.title = title 5.69 + self.dict = dict 5.70 + self.titles = titles 5.71 + 5.72 + def write_BODY( self, request, callback ): 5.73 + 5.74 + request.write( "<p><u>%s</u></p>" % self.title ) 5.75 + 5.76 + request.write( "<table width='100%' cellspacing='0' cellpadding='0' border='0'>" ) 5.77 + 5.78 + def writeAttr( niceName, attr, formatter=None ): 5.79 + if type( attr ) is types.TupleType: 5.80 + ( attr, formatter ) = attr 5.81 + 5.82 + if attr in self.dict: 5.83 + if formatter: 5.84 + temp = formatter( self.dict[ attr ] ) 5.85 + else: 5.86 + temp = str( self.dict[ attr ] ) 5.87 + request.write( "<tr><td width='50%%'><p>%s:</p></td><td width='50%%'><p>%s</p></td></tr>" % ( niceName, temp ) ) 5.88 + 5.89 + for niceName, attr in self.titles.items(): 5.90 + writeAttr( niceName, attr ) 5.91 + 5.92 + request.write( "</table>" ) 5.93 + 5.94 + callback( request ) 5.95 + 5.96 +class NullTab( HTMLBase ): 5.97 + 5.98 + def __init__( self ): 5.99 + HTMLBase.__init__( self ) 5.100 + self.title = "Null Tab" 5.101 + 5.102 + def write_BODY( self, request, callback ): 5.103 + request.write( "<p>%s</p>" % self.title ) 5.104 + callback( request ) 5.105 + 5.106 + 5.107 \ No newline at end of file
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/tools/python/xen/xend/sv/HTMLBase.py Tue Jul 20 10:14:24 2004 +0000 6.3 @@ -0,0 +1,30 @@ 6.4 +from twisted.web import server, resource 6.5 +from twisted.internet import reactor 6.6 + 6.7 +class HTMLBase( resource.Resource ): 6.8 + 6.9 + isLeaf = True 6.10 + 6.11 + defaultPath = "/usr/lib/python2.2/site-packages/xen/xend/sv/" 6.12 + 6.13 + def __init__( self ): 6.14 + resource.Resource.__init__(self) 6.15 + 6.16 + def render_GET( self, request ): 6.17 + self.write_TOP( request ) 6.18 + return self.write_BODY( request, self.finish_render_GET ) 6.19 + 6.20 + def finish_render_GET( self, request ): 6.21 + self.write_BOTTOM( request ) 6.22 + request.finish() 6.23 + 6.24 + def write_BODY( self, request ): 6.25 + request.write( "BODY" ) 6.26 + 6.27 + def write_TOP( self, request ): 6.28 + f = open( self.defaultPath + 'inc/top.htm', 'r' ) 6.29 + request.write( f.read() ) 6.30 + 6.31 + def write_BOTTOM( self, request ): 6.32 + f = open( self.defaultPath + 'inc/bottom.htm', 'r' ) 6.33 + request.write( f.read() ) 6.34 \ No newline at end of file
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/tools/python/xen/xend/sv/Main.py Tue Jul 20 10:14:24 2004 +0000 7.3 @@ -0,0 +1,81 @@ 7.4 +from twisted.web import resource 7.5 +from twisted.web.server import NOT_DONE_YET 7.6 + 7.7 +from xen.xend.XendClient import server as XendServer 7.8 +from xen.xend import sxp 7.9 + 7.10 +from HTMLBase import HTMLBase 7.11 + 7.12 +from xen.xend.sv import DomList, NodeInfo, DomInfo 7.13 + 7.14 +class Main( HTMLBase ): 7.15 + 7.16 + isLeaf = True 7.17 + 7.18 + def __init__( self ): 7.19 + HTMLBase.__init__(self) 7.20 + 7.21 + def render_POST( self, request ): 7.22 + return self.render_GET( request ) 7.23 + 7.24 + def mainUrlWriter( self, s ): 7.25 + return "Main.rpy?%s" % s 7.26 + 7.27 + def write_BODY( self, request, callback ): 7.28 + 7.29 + self.callback = callback 7.30 + 7.31 + request.write( "\n<table style='border:0px solid black; background: url(images/orb_01.jpg) no-repeat' cellspacing='0' cellpadding='0' border='0' width='780px' height='536px'>\n" ) 7.32 + request.write( "<tr>\n" ) 7.33 + request.write( " <td width='15px'> </td>" ) 7.34 + request.write( " <td width='175px' align='center' valign'center'>" ) 7.35 + request.write( " <table cellspacing='0' cellpadding='0' border='0' width='100%' height='100%'>" ) 7.36 + request.write( " <tr><td height='200px' align='center' valign='center'><a href='http://www.cl.cam.ac.uk/Research/SRG/netos/xen/'>" ) 7.37 + request.write( " <img src='images/xen.png' width='150' height='75' border='0'/></a></td></tr>" ) 7.38 + request.write( " <tr><td align='center' valign='top'>" ) 7.39 + 7.40 + request.write( " <p class='small'><a href='Main.rpy?mod=node'>Node details</a></p>" ) 7.41 + request.write( " <p class='small'><a href='Main.rpy?mod=list'>Domains summary</a></p>" ) 7.42 + 7.43 + DomList.DomList( self.mainUrlWriter, self.continue_BODY ).write_BODY( request, True, False ) 7.44 + 7.45 + return NOT_DONE_YET 7.46 + 7.47 + def continue_BODY( self, request ): 7.48 + request.write( " </td></tr>" ) 7.49 + request.write( " </table>" ) 7.50 + request.write( " " ) 7.51 + request.write( " </td>\n" ) 7.52 + request.write( " <td width='15px'> </td>" ) 7.53 + request.write( " <td width='558px' align='left' valign='top'>" ) 7.54 + request.write( " <table cellspacing='0' cellpadding='0' border='0' width='100%' height='100%'>" ) 7.55 + request.write( " <tr><td height='20px'></td></tr>" ) 7.56 + request.write( " <tr><td align='center' valign='top'>" ) 7.57 + 7.58 + mod = request.args.get('mod') 7.59 + 7.60 + if mod is None or len(mod) != 1: 7.61 + request.write( '<p>Please select a module</p>' ) 7.62 + self.finish_BODY( request ) 7.63 + elif mod[0] == 'info': 7.64 + DomInfo.DomInfo( self.mainUrlWriter, self.finish_BODY ).write_BODY( request ) 7.65 + elif mod[0] == 'list': 7.66 + DomList.DomList( self.mainUrlWriter, self.finish_BODY ).write_BODY( request ) 7.67 + elif mod[0] == 'node': 7.68 + NodeInfo.NodeInfo( self.mainUrlWriter, self.finish_BODY ).write_BODY( request ) 7.69 + else: 7.70 + request.write( '<p>Invalid module. Please select another</p>' ) 7.71 + self.finish_BODY( request ) 7.72 + 7.73 + def finish_BODY( self, request ): 7.74 + 7.75 + request.write( " </td></tr>" ) 7.76 + request.write( " </table>" ) 7.77 + request.write( " </td>\n" ) 7.78 + request.write( " <td width='17px'> </td>" ) 7.79 + request.write( "</tr>\n" ) 7.80 + 7.81 + request.write( "</table>\n" ) 7.82 + 7.83 + self.callback( request ) 7.84 + 7.85 \ No newline at end of file
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/tools/python/xen/xend/sv/Main.rpy Tue Jul 20 10:14:24 2004 +0000 8.3 @@ -0,0 +1,3 @@ 8.4 +from xen.xend.sv.Main import * 8.5 + 8.6 +resource = Main() 8.7 \ No newline at end of file
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/tools/python/xen/xend/sv/NodeInfo.py Tue Jul 20 10:14:24 2004 +0000 9.3 @@ -0,0 +1,47 @@ 9.4 +from xen.xend import XendDmesg 9.5 +from xen.xend import XendNode 9.6 + 9.7 +from xen.xend.sv.util import * 9.8 +from xen.xend.sv.GenTabbed import * 9.9 +from xen.xend.sv.HTMLBase import HTMLBase 9.10 + 9.11 +class NodeInfo( GenTabbed ): 9.12 + 9.13 + def __init__( self, urlWriter, callback ): 9.14 + 9.15 + def newUrlWriter( url ): 9.16 + return urlWriter( "mod=node%s" % url ) 9.17 + 9.18 + GenTabbed.__init__( self, newUrlWriter, [ 'General', 'Dmesg' ], [ NodeGeneralTab, NodeDmesgTab ], callback ) 9.19 + 9.20 +class NodeGeneralTab( GeneralTab ): 9.21 + 9.22 + def __init__( self ): 9.23 + 9.24 + nodeInfo = XendNode.instance().info() 9.25 + 9.26 + dictNodeInfo = {} 9.27 + 9.28 + for l in nodeInfo: 9.29 + dictNodeInfo[ l[0] ] = l[1] 9.30 + 9.31 + dictTitles = {} 9.32 + dictTitles[ 'System' ] = 'system' 9.33 + dictTitles[ 'Hostname' ] = 'host' 9.34 + dictTitles[ 'Release' ] = 'release' 9.35 + dictTitles[ 'Version' ] ='version' 9.36 + dictTitles[ 'Machine' ] = 'machine' 9.37 + dictTitles[ 'Cores' ] = 'cores' 9.38 + dictTitles[ 'Hyperthreading' ] = ( 'hyperthreads_per_core', hyperthreadFormatter ) 9.39 + dictTitles[ 'CPU Speed' ] = ( 'cpu_mhz', cpuFormatter ) 9.40 + dictTitles[ 'Memory' ] = ( 'memory', memoryFormatter ) 9.41 + dictTitles[ 'Free Memory' ] = ( 'free_memory', memoryFormatter ) 9.42 + 9.43 + GeneralTab.__init__( self, title="General Node Info", dict=dictNodeInfo, titles=dictTitles ) 9.44 + 9.45 +class NodeDmesgTab( PreTab ): 9.46 + 9.47 + def __init__( self ): 9.48 + self.xd = XendDmesg.instance() 9.49 + PreTab.__init__( self, self.xd.info()[0] ) 9.50 + 9.51 \ No newline at end of file
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/tools/python/xen/xend/sv/TabView.py Tue Jul 20 10:14:24 2004 +0000 10.3 @@ -0,0 +1,49 @@ 10.4 +from xen.xend.sv.HTMLBase import HTMLBase 10.5 + 10.6 +class TabView( HTMLBase ): 10.7 + 10.8 + def __init__( self, tab, tabs, urlWriter ): 10.9 + HTMLBase.__init__(self) 10.10 + self.tab = tab # interger - tab id 10.11 + self.tabs = tabs 10.12 + self.urlWriter = urlWriter 10.13 + 10.14 + def write_BODY( self, request ): 10.15 + request.write( "<table style='' border='0' cellspacing='0' cellpadding='0' align='center'>" ) 10.16 + request.write( "<tr height='22'>" ) 10.17 + 10.18 + if self.tab == 0: 10.19 + image = "left-end-highlight.jpg" 10.20 + else: 10.21 + image = "left-end-no-highlight.jpg" 10.22 + 10.23 + request.write( "<td height='22' width='14'><image src='images/%s' width='14' height='22'></td>" % image ) 10.24 + 10.25 + count = len( self.tabs ) 10.26 + 10.27 + for i in range( count ): 10.28 + 10.29 + if i == self.tab: 10.30 + image = "middle-highlight.jpg" 10.31 + else: 10.32 + image = "middle-no-highlight.jpg" 10.33 + 10.34 + request.write( "<td style='background: url(images/%s)'><p align='center'><a href='%s'>%s</a></p></td>" % ( image, self.urlWriter( "&tab=%s" % i ), self.tabs[ i ] ) ) 10.35 + 10.36 + if i < count-1: 10.37 + if i == self.tab: 10.38 + image = "seperator-left-highlight.jpg" 10.39 + elif self.tab == i+1: 10.40 + image = "seperator-right-highlight.jpg" 10.41 + else: 10.42 + image = "seperator.jpg" 10.43 + 10.44 + request.write( "<td height='22' width='23'><image src='images/%s' width='23' height='22'></td>" % image ) 10.45 + 10.46 + if self.tab == count - 1: 10.47 + image = "right-end-highlight.jpg" 10.48 + else: 10.49 + image = "right-end-no-highlight.jpg" 10.50 + 10.51 + request.write( "<td height='22' width='14'><image src='images/%s' width='14' height='22'></td>" % image ) 10.52 + request.write( "</tr></table>" )
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/tools/python/xen/xend/sv/XendClientDeferred.py Tue Jul 20 10:14:24 2004 +0000 11.3 @@ -0,0 +1,363 @@ 11.4 +# Copyright (C) 2004 Tom Wilkie <tw275@cam.ac.uk> 11.5 +# Copyright (C) 2004 Mike Wray 11.6 +"""Client API for the HTTP interface on xend. 11.7 +Callable as a script - see main(). 11.8 + 11.9 +This API is the 'control-plane' for xend. 11.10 +The 'data-plane' is done separately. For example, consoles 11.11 +are accessed via sockets on xend, but the list of consoles 11.12 +is accessible via this API. 11.13 + 11.14 +This one is similar to mikes, but works in an async fashion 11.15 +""" 11.16 +import sys 11.17 +import httplib 11.18 +import types 11.19 +from StringIO import StringIO 11.20 +import urlparse 11.21 + 11.22 +from xen.xend.encode import * 11.23 +from xen.xend.sxp import * 11.24 +from xen.xend.PrettyPrint import prettyprint 11.25 + 11.26 +from twisted.protocols.http import HTTPClient 11.27 +from twisted.internet.protocol import ClientCreator 11.28 +from twisted.internet.defer import Deferred 11.29 +from twisted.internet import reactor 11.30 + 11.31 +DEBUG = 0 11.32 + 11.33 +class XendRequest( HTTPClient ): 11.34 + def __init__(self, deferred, urls): 11.35 + self.urls = urls 11.36 + self.deferred = deferred 11.37 + 11.38 + def connectionMade(self): 11.39 + self.sendCommand('GET', self.urls[2]) 11.40 + self.sendHeader('Host', '%s:%d' % (self.urls[0], self.urls[1]) ) 11.41 + self.endHeaders() 11.42 + 11.43 + def handleResponse(self, data): 11.44 + self.deferred.callback( data ) 11.45 + 11.46 +def process_SXP( sexp ): 11.47 + pin = Parser() 11.48 + pin.input(sexp) 11.49 + pin.input_eof() 11.50 + return pin.get_val() 11.51 + 11.52 +def xend_request(url, method, data=None): 11.53 + """Make a request to xend. 11.54 + 11.55 + url xend request url 11.56 + method http method: POST or GET 11.57 + data request argument data (dict) 11.58 + """ 11.59 + urlinfo = urlparse.urlparse(url) 11.60 + (uproto, ulocation, upath, uparam, uquery, ufrag) = urlinfo 11.61 + (hdr, args) = encode_data(data) 11.62 + if data and method == 'GET': 11.63 + upath += '?' + args 11.64 + args = None 11.65 + if method == "POST" and upath.endswith('/'): 11.66 + upath = upath[:-1] 11.67 + 11.68 + deferred = Deferred() 11.69 + 11.70 + clientCreator = ClientCreator( reactor, XendRequest, deferred, (ulocation, 8000, upath) ) 11.71 + clientCreator.connectTCP( ulocation, 8000 ) 11.72 + 11.73 + deferred.addCallback( process_SXP ) 11.74 + 11.75 + return deferred 11.76 + 11.77 +class XendError(RuntimeError): 11.78 + pass 11.79 + 11.80 +class Foo(httplib.HTTPResponse): 11.81 + 11.82 + def begin(self): 11.83 + fin = self.fp 11.84 + while(1): 11.85 + buf = fin.readline() 11.86 + print "***", buf 11.87 + if buf == '': 11.88 + print 11.89 + sys.exit() 11.90 + 11.91 + 11.92 +def sxprio(sxpr): 11.93 + """Convert an sxpr to a string. 11.94 + """ 11.95 + io = StringIO() 11.96 + sxp.show(sxpr, out=io) 11.97 + print >> io 11.98 + io.seek(0) 11.99 + return io 11.100 + 11.101 +def fileof(val): 11.102 + """Converter for passing configs. 11.103 + Handles lists, files directly. 11.104 + Assumes a string is a file name and passes its contents. 11.105 + """ 11.106 + if isinstance(val, types.ListType): 11.107 + return sxprio(val) 11.108 + if isinstance(val, types.StringType): 11.109 + return file(val) 11.110 + if hasattr(val, 'readlines'): 11.111 + return val 11.112 + 11.113 +# todo: need to sort of what urls/paths are using for objects. 11.114 +# e.g. for domains at the moment return '0'. 11.115 +# should probably return abs path w.r.t. server, e.g. /xend/domain/0. 11.116 +# As an arg, assume abs path is obj uri, otherwise just id. 11.117 + 11.118 +# Function to convert to full url: Xend.uri(path), e.g. 11.119 +# maps /xend/domain/0 to http://wray-m-3.hpl.hp.com:8000/xend/domain/0 11.120 +# And should accept urls for ids? 11.121 + 11.122 +def urljoin(location, root, prefix='', rest=''): 11.123 + prefix = str(prefix) 11.124 + rest = str(rest) 11.125 + base = 'http://' + location + root + prefix 11.126 + url = urlparse.urljoin(base, rest) 11.127 + return url 11.128 + 11.129 +def nodeurl(location, root, id=''): 11.130 + return urljoin(location, root, 'node/', id) 11.131 + 11.132 +def domainurl(location, root, id=''): 11.133 + return urljoin(location, root, 'domain/', id) 11.134 + 11.135 +def consoleurl(location, root, id=''): 11.136 + return urljoin(location, root, 'console/', id) 11.137 + 11.138 +def deviceurl(location, root, id=''): 11.139 + return urljoin(location, root, 'device/', id) 11.140 + 11.141 +def vneturl(location, root, id=''): 11.142 + return urljoin(location, root, 'vnet/', id) 11.143 + 11.144 +def eventurl(location, root, id=''): 11.145 + return urljoin(location, root, 'event/', id) 11.146 + 11.147 +def xend_get(url, args=None): 11.148 + """Make a xend request using GET. 11.149 + Requests using GET are 'safe' and may be repeated without 11.150 + nasty side-effects. 11.151 + """ 11.152 + return xend_request(url, "GET", args) 11.153 + 11.154 +def xend_call(url, data): 11.155 + """Make xend request using POST. 11.156 + Requests using POST potentially cause side-effects and should 11.157 + not be repeated unless it really is wanted to do the side 11.158 + effect again. 11.159 + """ 11.160 + return xend_request(url, "POST", data) 11.161 + 11.162 +class Xend: 11.163 + 11.164 + """Default location of the xend server.""" 11.165 + SRV_DEFAULT = "localhost" 11.166 + 11.167 + """Default path to the xend root on the server.""" 11.168 + ROOT_DEFAULT = "/xend/" 11.169 + 11.170 + def __init__(self, srv=None, root=None): 11.171 + self.bind(srv, root) 11.172 + 11.173 + def bind(self, srv=None, root=None): 11.174 + """Bind to a given server. 11.175 + 11.176 + srv server location (host:port) 11.177 + root server xend root path 11.178 + """ 11.179 + if srv is None: srv = self.SRV_DEFAULT 11.180 + if root is None: root = self.ROOT_DEFAULT 11.181 + if not root.endswith('/'): root += '/' 11.182 + self.location = srv 11.183 + self.root = root 11.184 + 11.185 + def nodeurl(self, id=''): 11.186 + return nodeurl(self.location, self.root, id) 11.187 + 11.188 + def domainurl(self, id=''): 11.189 + return domainurl(self.location, self.root, id) 11.190 + 11.191 + def consoleurl(self, id=''): 11.192 + return consoleurl(self.location, self.root, id) 11.193 + 11.194 + def deviceurl(self, id=''): 11.195 + return deviceurl(self.location, self.root, id) 11.196 + 11.197 + def vneturl(self, id=''): 11.198 + return vneturl(self.location, self.root, id) 11.199 + 11.200 + def eventurl(self, id=''): 11.201 + return eventurl(self.location, self.root, id) 11.202 + 11.203 + def xend(self): 11.204 + return xend_get(urljoin(self.location, self.root)) 11.205 + 11.206 + def xend_node(self): 11.207 + return xend_get(self.nodeurl()) 11.208 + 11.209 + def xend_node_cpu_rrobin_slice_set(self, slice): 11.210 + return xend_call(self.nodeurl(), 11.211 + {'op' : 'cpu_rrobin_slice_set', 11.212 + 'slice' : slice }) 11.213 + 11.214 + def xend_node_cpu_bvt_slice_set(self, ctx_allow): 11.215 + return xend_call(self.nodeurl(), 11.216 + {'op' : 'cpu_bvt_slice_set', 11.217 + 'ctx_allow' : ctx_allow }) 11.218 + 11.219 + def xend_node_cpu_fbvt_slice_set(self, ctx_allow): 11.220 + return xend_call(self.nodeurl(), 11.221 + {'op' : 'cpu_fbvt_slice_set', 11.222 + 'ctx_allow' : ctx_allow }) 11.223 + 11.224 + def xend_domains(self): 11.225 + return xend_get(self.domainurl()) 11.226 + 11.227 + def xend_domain_create(self, conf): 11.228 + return xend_call(self.domainurl(), 11.229 + {'op' : 'create', 11.230 + 'config' : fileof(conf) }) 11.231 + 11.232 + def xend_domain(self, id): 11.233 + return xend_get(self.domainurl(id)) 11.234 + 11.235 + def xend_domain_unpause(self, id): 11.236 + return xend_call(self.domainurl(id), 11.237 + {'op' : 'unpause'}) 11.238 + 11.239 + def xend_domain_pause(self, id): 11.240 + return xend_call(self.domainurl(id), 11.241 + {'op' : 'pause'}) 11.242 + 11.243 + def xend_domain_shutdown(self, id, reason): 11.244 + return xend_call(self.domainurl(id), 11.245 + {'op' : 'shutdown', 11.246 + 'reason' : reason }) 11.247 + 11.248 + def xend_domain_destroy(self, id): 11.249 + return xend_call(self.domainurl(id), 11.250 + {'op' : 'destroy'}) 11.251 + 11.252 + def xend_domain_save(self, id, filename): 11.253 + return xend_call(self.domainurl(id), 11.254 + {'op' : 'save', 11.255 + 'file' : filename}) 11.256 + 11.257 + def xend_domain_restore(self, id, filename): 11.258 + return xend_call(self.domainurl(id), 11.259 + {'op' : 'restore', 11.260 + 'file' : filename }) 11.261 + 11.262 + def xend_domain_migrate(self, id, dst): 11.263 + return xend_call(self.domainurl(id), 11.264 + {'op' : 'migrate', 11.265 + 'destination': dst}) 11.266 + 11.267 + def xend_domain_pincpu(self, id, cpu): 11.268 + return xend_call(self.domainurl(id), 11.269 + {'op' : 'pincpu', 11.270 + 'cpu' : cpu}) 11.271 + 11.272 + def xend_domain_cpu_bvt_set(self, id, mcuadv, warp, warpl, warpu): 11.273 + return xend_call(self.domainurl(id), 11.274 + {'op' : 'cpu_bvt_set', 11.275 + 'mcuadv' : mcuadv, 11.276 + 'warp' : warp, 11.277 + 'warpl' : warpl, 11.278 + 'warpu' : warpu }) 11.279 + 11.280 + def xend_domain_cpu_fbvt_set(self, id, mcuadv, warp, warpl, warpu): 11.281 + return xend_call(self.domainurl(id), 11.282 + {'op' : 'cpu_fbvt_set', 11.283 + 'mcuadv' : mcuadv, 11.284 + 'warp' : warp, 11.285 + 'warpl' : warpl, 11.286 + 'warpu' : warpu }) 11.287 + 11.288 + 11.289 + def xend_domain_cpu_atropos_set(self, id, period, slice, latency, xtratime): 11.290 + return xend_call(self.domainurl(id), 11.291 + {'op' : 'cpu_atropos_set', 11.292 + 'period' : period, 11.293 + 'slice' : slice, 11.294 + 'latency' : latency, 11.295 + 'xtratime': xtratime }) 11.296 + 11.297 + def xend_domain_vifs(self, id): 11.298 + return xend_get(self.domainurl(id), 11.299 + { 'op' : 'vifs' }) 11.300 + 11.301 + def xend_domain_vif_ip_add(self, id, vif, ipaddr): 11.302 + return xend_call(self.domainurl(id), 11.303 + {'op' : 'vif_ip_add', 11.304 + 'vif' : vif, 11.305 + 'ip' : ipaddr }) 11.306 + 11.307 + def xend_domain_vbds(self, id): 11.308 + return xend_get(self.domainurl(id), 11.309 + {'op' : 'vbds'}) 11.310 + 11.311 + def xend_domain_vbd(self, id, vbd): 11.312 + return xend_get(self.domainurl(id), 11.313 + {'op' : 'vbd', 11.314 + 'vbd' : vbd}) 11.315 + 11.316 + def xend_consoles(self): 11.317 + return xend_get(self.consoleurl()) 11.318 + 11.319 + def xend_console(self, id): 11.320 + return xend_get(self.consoleurl(id)) 11.321 + 11.322 + def xend_vnets(self): 11.323 + return xend_get(self.vneturl()) 11.324 + 11.325 + def xend_vnet_create(self, conf): 11.326 + return xend_call(self.vneturl(), 11.327 + {'op': 'create', 'config': fileof(conf) }) 11.328 + 11.329 + def xend_vnet(self, id): 11.330 + return xend_get(self.vneturl(id)) 11.331 + 11.332 + def xend_vnet_delete(self, id): 11.333 + return xend_call(self.vneturl(id), 11.334 + {'op': 'delete'}) 11.335 + 11.336 + def xend_event_inject(self, sxpr): 11.337 + val = xend_call(self.eventurl(), 11.338 + {'op': 'inject', 'event': fileof(sxpr) }) 11.339 + 11.340 +def main(argv): 11.341 + """Call an API function: 11.342 + 11.343 + python XendClient.py fn args... 11.344 + 11.345 + The leading 'xend_' on the function can be omitted. 11.346 + Example: 11.347 + 11.348 + > python XendClient.py domains 11.349 + (domain 0 8) 11.350 + > python XendClient.py domain 0 11.351 + (domain (id 0) (name Domain-0) (memory 128)) 11.352 + """ 11.353 + server = Xend() 11.354 + fn = argv[1] 11.355 + if not fn.startswith('xend'): 11.356 + fn = 'xend_' + fn 11.357 + args = argv[2:] 11.358 + deferred = getattr(server, fn)(*args) 11.359 + deferred.addCallback( prettyprint ) 11.360 + reactor.run() 11.361 + print 11.362 + 11.363 +if __name__ == "__main__": 11.364 + main(sys.argv) 11.365 +else: 11.366 + server = Xend()
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/tools/python/xen/xend/sv/__init__.py Tue Jul 20 10:14:24 2004 +0000 12.3 @@ -0,0 +1,1 @@ 12.4 +
13.1 Binary file tools/python/xen/xend/sv/images/internet copy.jpg has changed
14.1 Binary file tools/python/xen/xend/sv/images/internet.jpg has changed
15.1 Binary file tools/python/xen/xend/sv/images/internet.psd has changed
16.1 Binary file tools/python/xen/xend/sv/images/left-end-highlight.jpg has changed
17.1 Binary file tools/python/xen/xend/sv/images/left-end-no-highlight.jpg has changed
18.1 Binary file tools/python/xen/xend/sv/images/middle-highlight.jpg has changed
19.1 Binary file tools/python/xen/xend/sv/images/middle-no-highlight.jpg has changed
20.1 Binary file tools/python/xen/xend/sv/images/orb_01.jpg has changed
21.1 Binary file tools/python/xen/xend/sv/images/orb_02.jpg has changed
22.1 Binary file tools/python/xen/xend/sv/images/right-end-highlight.jpg has changed
23.1 Binary file tools/python/xen/xend/sv/images/right-end-no-highlight.jpg has changed
24.1 Binary file tools/python/xen/xend/sv/images/seperator-left-highlight.jpg has changed
25.1 Binary file tools/python/xen/xend/sv/images/seperator-right-highlight.jpg has changed
26.1 Binary file tools/python/xen/xend/sv/images/seperator.jpg has changed
27.1 Binary file tools/python/xen/xend/sv/images/xen.png has changed
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 28.2 +++ b/tools/python/xen/xend/sv/inc/bottom.htm Tue Jul 20 10:14:24 2004 +0000 28.3 @@ -0,0 +1,2 @@ 28.4 + </body> 28.5 +</html> 28.6 \ No newline at end of file
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 29.2 +++ b/tools/python/xen/xend/sv/inc/style.css Tue Jul 20 10:14:24 2004 +0000 29.3 @@ -0,0 +1,30 @@ 29.4 + 29.5 +P {font-family: verdana, arial; font-size: 12px; color: black} 29.6 +.small {font-size: 10px} 29.7 + 29.8 +TD.domainInfo {font-family: verdana, arial; font-size: 10px; color: black} 29.9 +TD.domainInfoHead {font-family: verdana, arial; font-size: 10px; color: white; font-face: bold} 29.10 + 29.11 +TD.domainInfoHead {background-color: black} 29.12 +TR.domainInfoOdd {background-color: white} 29.13 +TR.domainInfoEven {background-color: lightgrey} 29.14 + 29.15 +body { 29.16 + width: 670px; 29.17 + margin: 0px; 29.18 + padding: 0px; 29.19 + background-color: #fff; 29.20 + background-image: url(../images/orb_02.jpg); 29.21 + background-repeat: repeat-y; 29.22 + background-position: left top; 29.23 + font-family: Arial, Helvetica, sans-serif; 29.24 + font-weight: bold; 29.25 + color: #333333; 29.26 + letter-spacing: 0px; 29.27 + scrollbar-base-color: #333333; 29.28 + scrollbar-track-color: #666666; 29.29 + scrollbar-face-color: #fff; 29.30 + 29.31 + 29.32 + } 29.33 + 29.34 \ No newline at end of file
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 30.2 +++ b/tools/python/xen/xend/sv/inc/top.htm Tue Jul 20 10:14:24 2004 +0000 30.3 @@ -0,0 +1,8 @@ 30.4 +<html> 30.5 + <head> 30.6 + <title> 30.7 + Xen 30.8 + </title> 30.9 + <link rel="stylesheet" type="text/css" href="inc/style.css" /> 30.10 + </head> 30.11 + <body> 30.12 \ No newline at end of file
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 31.2 +++ b/tools/python/xen/xend/sv/util.py Tue Jul 20 10:14:24 2004 +0000 31.3 @@ -0,0 +1,64 @@ 31.4 +from xen.xend.sv.XendClientDeferred import server 31.5 +from xen.xend import sxp 31.6 + 31.7 +def getDomInfoHash( domain ): 31.8 + deferred = server.xend_domain( int( domain ) ) 31.9 + deferred.addCallback( procDomInfo, domain ) 31.10 + return deferred 31.11 + 31.12 +def procDomInfo( domInfo, domain ): 31.13 + d = {} 31.14 + d['dom'] = int( domain ) 31.15 + d['name'] = sxp.child_value( domInfo, 'name' ) 31.16 + d['mem'] = int( sxp.child_value( domInfo, 'memory' ) ) 31.17 + d['cpu'] = int( sxp.child_value( domInfo, 'cpu' ) ) 31.18 + d['state'] = sxp.child_value( domInfo, 'state' ) 31.19 + d['cpu_time'] = float( sxp.child_value( domInfo, 'cpu_time' ) ) 31.20 + if( sxp.child_value( domInfo, 'up_time' ) ): 31.21 + d['up_time'] = float( sxp.child_value( domInfo, 'up_time' ) ) 31.22 + if( sxp.child_value( domInfo, 'start_time' ) ): 31.23 + d['start_time'] = float( sxp.child_value( domInfo, 'start_time' ) ) 31.24 + return d 31.25 + 31.26 +def bigTimeFormatter( time ): 31.27 + weeks = time // 604800 31.28 + remainder = time % 604800 31.29 + days = remainder // 86400 31.30 + 31.31 + remainder = remainder % 86400 31.32 + 31.33 + hms = smallTimeFormatter( remainder ) 31.34 + 31.35 + return "%d weeks, %d days, %s" % ( weeks, days, hms ) 31.36 + 31.37 +def smallTimeFormatter( time ): 31.38 + hours = time // 3600 31.39 + remainder = time % 3600 31.40 + mins = remainder // 60 31.41 + secs = time % 60 31.42 + return "%02d:%02d:%04.1f (hh:mm:ss.s)" % ( hours, mins, secs ) 31.43 + 31.44 +def stateFormatter( state ): 31.45 + states = [ 'Running', 'Blocked', 'Paused', 'Shutdown', 'Crashed' ] 31.46 + 31.47 + for i in range( len( state ) ): 31.48 + if state[i] != "-": 31.49 + return states[ i ] + " (%s)" % state 31.50 + 31.51 + return state 31.52 + 31.53 +def memoryFormatter( mem ): 31.54 + return "%7dMb" % mem 31.55 + 31.56 +def cpuFormatter( mhz ): 31.57 + if mhz > 1000: 31.58 + ghz = float( mhz ) / 1000.0 31.59 + return "%4.2fGHz" % ghz 31.60 + else: 31.61 + return "%4dMHz" % mhz 31.62 + 31.63 +def hyperthreadFormatter( threads ): 31.64 + if int( threads ) > 1: 31.65 + return "Yes (%d)" % threads 31.66 + else: 31.67 + return "No" 31.68 \ No newline at end of file