aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/python/xen/sv/CreateDomain.py21
-rwxr-xr-xtools/python/xen/sv/DomInfo.py61
-rwxr-xr-xtools/python/xen/sv/DomList.py49
-rwxr-xr-xtools/python/xen/sv/HTMLBase.py2
-rwxr-xr-xtools/python/xen/sv/Main.py25
-rwxr-xr-xtools/python/xen/sv/NodeInfo.py15
-rwxr-xr-xtools/python/xen/sv/util.py8
-rwxr-xr-xtools/sv/Makefile5
-rw-r--r--tools/sv/images/destroy.pngbin0 -> 2408 bytes
-rw-r--r--tools/sv/images/small-destroy.pngbin0 -> 483 bytes
-rw-r--r--tools/sv/images/small-pause.pngbin0 -> 434 bytes
-rw-r--r--tools/sv/images/small-unpause.pngbin0 -> 500 bytes
-rwxr-xr-xtools/sv/inc/script.js7
13 files changed, 149 insertions, 44 deletions
diff --git a/tools/python/xen/sv/CreateDomain.py b/tools/python/xen/sv/CreateDomain.py
index b4fd52f0e8..77237a3a47 100644
--- a/tools/python/xen/sv/CreateDomain.py
+++ b/tools/python/xen/sv/CreateDomain.py
@@ -25,6 +25,7 @@ class CreatePage0( Sheet ):
self.addControl( InputControl( 'name', 'VM Name', 'VM Name:', "[\\w|\\S]+", "You must enter a name in this field" ) )
self.addControl( InputControl( 'memory', '64', 'Memory (Mb):', "[\\d]+", "You must enter a number in this field" ) )
self.addControl( InputControl( 'cpu', '0', 'CPU:', "[\\d]+", "You must enter a number in this feild" ) )
+ self.addControl( InputControl( 'cpu_weight', '1', 'CPU Weight:', "[\\d]+", "You must enter a number in this feild" ) )
class CreatePage1( Sheet ):
@@ -83,9 +84,16 @@ class CreateFinish( Sheet ):
xend_sxp = self.translate_sxp( string2sxp( self.passback ) )
- dom_sxp = server.xend_domain_create( xend_sxp )
+ try:
+ dom_sxp = server.xend_domain_create( xend_sxp )
+ success = "Your domain was successfully created.\n"
+ except:
+ success = "There was an error creating your domain.\nThe configuration used is as follows:\n"
+ dom_sxp = xend_sxp
+
+
- pt = PreTab( sxp2prettystring( dom_sxp ) )
+ pt = PreTab( success + sxp2prettystring( dom_sxp ) )
pt.write_BODY( request )
request.write( "<input type='hidden' name='passback' value=\"%s\"></p>" % self.passback )
@@ -106,6 +114,7 @@ class CreateFinish( Sheet ):
vals.name = get( 'name' )
vals.memory = get( 'memory' )
vals.cpu = get( 'cpu' )
+ vals.cpu_weight = get( 'cpu_weight' )
vals.builder = get( 'builder' )
vals.kernel = get( 'kernel' )
@@ -121,7 +130,7 @@ class CreateFinish( Sheet ):
vals.disk = vbds
- #misc crap
+ #misc
vals.pci = []
@@ -145,4 +154,8 @@ class CreateFinish( Sheet ):
vals.cmdline_ip = "%s:%s:%s:%s:%s:eth0:%s" % (ip, nfs, gate, mask, host, dhcp)
- return make_config( vals )
+ try:
+ return make_config( vals )
+ except:
+ return [["Error creating domain config."]]
+
diff --git a/tools/python/xen/sv/DomInfo.py b/tools/python/xen/sv/DomInfo.py
index 6f8ac1ab5b..3e4fb70b13 100755
--- a/tools/python/xen/sv/DomInfo.py
+++ b/tools/python/xen/sv/DomInfo.py
@@ -5,6 +5,8 @@ from xen.sv.HTMLBase import HTMLBase
from xen.sv.util import *
from xen.sv.GenTabbed import *
+DEBUG=1
+
class DomInfo( GenTabbed ):
def __init__( self, urlWriter ):
@@ -76,8 +78,11 @@ class DomSXPTab( PreTab ):
request.write( "<p>Please Select a Domain</p>" )
return None
- domInfo = server.xend_domain( self.dom )
-
+ try:
+ domInfo = server.xend_domain( self.dom )
+ except:
+ domInfo = [["Error getting domain details."]]
+
self.source = sxp2prettystring( domInfo )
PreTab.write_BODY( self, request )
@@ -88,32 +93,54 @@ class DomActionTab( ActionTab ):
actions = { "shutdown" : ( "Shutdown the Domain", "shutdown.png" ),
"reboot" : ( "Reboot the Domain", "reboot.png" ),
"pause" : ( "Pause the Domain", "pause.png" ),
- "unpause" : ( "Unpause the Domain", "unpause.png" ) }
+ "unpause" : ( "Unpause the Domain", "unpause.png" ),
+ "destroy" : ( "Destroy the Domain", "destroy.png" ) }
ActionTab.__init__( self, actions )
def op_shutdown( self, request ):
dom = getVar( 'dom', request )
- if not dom is None:
- print ">DomShutDown %s" % dom
- #server.xend_node_shutdown()
+ if not dom is None and dom != '0':
+ if DEBUG: print ">DomShutDown %s" % dom
+ try:
+ server.xend_domain_shutdown( int( dom ), "halt" )
+ except:
+ pass
def op_reboot( self, request ):
dom = getVar( 'dom', request )
- if not dom is None:
- print ">DomReboot %s" % dom
- #server.xend_node_reboot()
-
+ if not dom is None and dom != '0':
+ if DEBUG: print ">DomReboot %s" % dom
+ try:
+ server.xend_domain_shutdown( int( dom ), "reboot" )
+ except:
+ pass
+
def op_pause( self, request ):
dom = getVar( 'dom', request )
- if not dom is None:
- print ">DomPause %s" % dom
- server.xend_domain_pause( int( dom ) )
-
+ if not dom is None and dom != '0':
+ if DEBUG: print ">DomPause %s" % dom
+ try:
+ server.xend_domain_pause( int( dom ) )
+ except:
+ pass
+
def op_unpause( self, request ):
dom = getVar( 'dom', request )
- if not dom is None:
- print ">DomUnpause %s" % dom
- server.xend_domain_unpause( int( dom ) )
+ if not dom is None and dom != '0':
+ if DEBUG: print ">DomUnpause %s" % dom
+ try:
+ server.xend_domain_unpause( int( dom ) )
+ except:
+ pass
+
+ def op_destroy( self, request ):
+ dom = getVar( 'dom', request )
+ if not dom is None and dom != '0':
+ if DEBUG: print ">DomDestroy %s" % dom
+ try:
+ server.xend_domain_destroy( int( dom ), "halt" )
+ except:
+ pass
diff --git a/tools/python/xen/sv/DomList.py b/tools/python/xen/sv/DomList.py
index faed020b05..d6e123143e 100755
--- a/tools/python/xen/sv/DomList.py
+++ b/tools/python/xen/sv/DomList.py
@@ -17,9 +17,14 @@ class DomList( HTMLBase ):
def write_BODY( self, request, head=True, long=True ):
- domains = map(int, server.xend_domains())
- domains.sort()
+ domains = None
+ try:
+ domains = server.xend_domains()
+ domains.sort()
+ except:
+ pass
+
request.write( "\n<table style='border:0px solid white' cellspacing='0' cellpadding='0' border='0' width='100%'>\n" )
if head:
@@ -29,28 +34,42 @@ class DomList( HTMLBase ):
odd = True
- for domain in domains:
- if odd:
- request.write( "<tr class='domainInfoOdd'>\n" )
- odd = False
- else:
- request.write( "<tr class='domainInfoEven'>\n" )
- odd = True
- self.write_DOMAIN( request, getDomInfoHash( domain ), long )
- request.write( "</tr>\n" )
-
+ if not domains is None:
+ for domain in domains:
+ if odd:
+ request.write( "<tr class='domainInfoOdd'>\n" )
+ odd = False
+ else:
+ request.write( "<tr class='domainInfoEven'>\n" )
+ odd = True
+ self.write_DOMAIN( request, getDomInfoHash( domain ), long )
+ request.write( "</tr>\n" )
+ else:
+ request.write( "<tr colspan='10'><p class='small'>Error getting domain list<br/>Perhaps XenD not running?</p></tr>")
+
request.write( "</table>\n" )
def write_DOMAIN( self, request, domInfoHash, long=True ):
- request.write( "<td class='domainInfo' align='center'>%(dom)-4d</td>\n" % domInfoHash )
+ request.write( "<td class='domainInfo' align='center'>%(id)s</td>\n" % domInfoHash )
- url = self.urlWriter( "&mod=info&dom=%(dom)-4d" % domInfoHash )
+ url = self.urlWriter( "&mod=info&dom=%(id)s" % domInfoHash )
request.write( "<td class='domainInfo' align='center'><a href='%s'>%s</a></td>\n" % ( url, domInfoHash['name'] ) )
if long:
request.write( "<td class='domainInfo' align='center'>%(memory)5s</td>\n" % domInfoHash )
request.write( "<td class='domainInfo' align='center'>%(cpu)2s</td>\n" % domInfoHash )
request.write( "<td class='domainInfo' align='center'>%(state)5s</td>\n" % domInfoHash )
+ if domInfoHash[ 'id' ] != "0":
+ request.write( "<td class='domainInfo' align='center'>" )
+
+ if domInfoHash[ 'state' ][ 2 ] == "-":
+ request.write( "<img src='images/small-pause.png' onclick='doOp2( \"pause\", \"%(dom)-4d\" )'>" % domInfoHash )
+ else:
+ request.write( "<img src='images/small-unpause.png' onclick='doOp2( \"unpause\", \"%(dom)-4d\" )'>" % domInfoHash )
+
+ request.write( "<img src='images/small-destroy.png' onclick='doOp2( \"destroy\", \"%(dom)-4d\" )'></td>" % domInfoHash)
+ else:
+ request.write( "<td>&nbsp;</td>" )
def write_DOMAIN_HEAD( self, request, long=True ):
request.write( "<td class='domainInfoHead' align='center'>Domain</td>\n" )
@@ -59,4 +78,4 @@ class DomList( HTMLBase ):
request.write( "<td class='domainInfoHead' align='center'>Memory / Mb</td>\n" )
request.write( "<td class='domainInfoHead' align='center'>CPU</td>\n" )
request.write( "<td class='domainInfoHead' align='center'>State</td>\n" )
-
+ request.write( "<td class='domainInfoHead' align='center'></td>\n" )
diff --git a/tools/python/xen/sv/HTMLBase.py b/tools/python/xen/sv/HTMLBase.py
index 10d860e0c4..e67784d558 100755
--- a/tools/python/xen/sv/HTMLBase.py
+++ b/tools/python/xen/sv/HTMLBase.py
@@ -1,4 +1,5 @@
from twisted.web.resource import Resource
+from xen.sv.util import *
class HTMLBase( Resource ):
@@ -28,6 +29,7 @@ class HTMLBase( Resource ):
def write_BOTTOM( self, request ):
request.write('<input type="hidden" name="op" value="">')
+ request.write('<input type="hidden" name="args" value="">')
request.write('</form>')
request.write( "</body></html>" )
diff --git a/tools/python/xen/sv/Main.py b/tools/python/xen/sv/Main.py
index bf6119c600..2362287c50 100755
--- a/tools/python/xen/sv/Main.py
+++ b/tools/python/xen/sv/Main.py
@@ -4,6 +4,8 @@ from xen.sv.NodeInfo import NodeInfo
from xen.sv.DomInfo import DomInfo
from xen.sv.CreateDomain import CreateDomain
+from xen.xend.XendClient import server
+
from xen.sv.util import getVar
class Main( HTMLBase ):
@@ -20,14 +22,18 @@ class Main( HTMLBase ):
def render_POST( self, request ):
#decide what module post'd the action
+
+ args = getVar( 'args', request )
mod = getVar( 'mod', request )
- if not mod is None:
+ if not mod is None and args is None:
module = self.modules[ mod ]
#check module exists
if module:
- module( self.mainUrlWriter ).perform( request )
+ module( self.mainUrlWriter ).perform( request )
+ else:
+ self.perform( request )
return self.render_GET( request )
@@ -80,3 +86,18 @@ class Main( HTMLBase ):
request.write( "</table>\n" )
+
+ def op_destroy( self, request ):
+ dom = getVar( 'args', request )
+ if not dom is None and dom != "0":
+ server.xend_domain_destroy( int( dom ), "halt" )
+
+ def op_pause( self, request ):
+ dom = getVar( 'args', request )
+ if not dom is None and dom != "0":
+ server.xend_domain_pause( int( dom ) )
+
+ def op_unpause( self, request ):
+ dom = getVar( 'args', request )
+ if not dom is None and dom != "0":
+ server.xend_domain_unpause( int( dom ) ) \ No newline at end of file
diff --git a/tools/python/xen/sv/NodeInfo.py b/tools/python/xen/sv/NodeInfo.py
index 948acef4b6..8afc41d491 100755
--- a/tools/python/xen/sv/NodeInfo.py
+++ b/tools/python/xen/sv/NodeInfo.py
@@ -20,8 +20,12 @@ class NodeInfoTab( GeneralTab ):
def __init__( self ):
- nodeInfo = sxp2hash( server.xend_node() )
-
+ nodeInfo = {}
+ try:
+ nodeInfo = sxp2hash( server.xend_node() )
+ except:
+ nodeInfo[ 'system' ] = 'Error getting node info'
+
dictTitles = {}
dictTitles[ 'System' ] = 'system'
dictTitles[ 'Hostname' ] = 'host'
@@ -39,8 +43,11 @@ class NodeInfoTab( GeneralTab ):
class NodeDmesgTab( PreTab ):
def __init__( self ):
- dmesg = server.xend_node_dmesg()
- PreTab.__init__( self, dmesg[ 1 ] )
+ try:
+ dmesg = server.xend_node_dmesg()
+ except:
+ dmesg = "Error getting node information: XenD not running?"
+ PreTab.__init__( self, dmesg )
class NodeActionTab( ActionTab ):
diff --git a/tools/python/xen/sv/util.py b/tools/python/xen/sv/util.py
index b332b60482..3207b8f0cc 100755
--- a/tools/python/xen/sv/util.py
+++ b/tools/python/xen/sv/util.py
@@ -5,8 +5,12 @@ from xen.xend import PrettyPrint
import types
def getDomInfoHash( domain ):
- domInfoHash = sxp2hash( server.xend_domain( int( domain ) ) )
- domInfoHash['dom'] = int( domain )
+ domInfoHash = {}
+ try:
+ domInfoHash = sxp2hash( server.xend_domain( domain ) )
+ domInfoHash['dom'] = domain
+ except:
+ domInfoHash['name'] = "Error getting domain details"
return domInfoHash
def sxp2hash( s ):
diff --git a/tools/sv/Makefile b/tools/sv/Makefile
index c7bd3d5880..dcc298826a 100755
--- a/tools/sv/Makefile
+++ b/tools/sv/Makefile
@@ -33,7 +33,12 @@ 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/destroy.png $(sv_insdir)/images
+ install -m0644 images/small-destroy.png $(sv_insdir)/images
+ install -m0644 images/small-pause.png $(sv_insdir)/images
+ install -m0644 images/small-unpause.png $(sv_insdir)/images
+
install -m0644 images/next.png $(sv_insdir)/images
install -m0644 images/previous.png $(sv_insdir)/images
install -m0644 images/finish.png $(sv_insdir)/images
diff --git a/tools/sv/images/destroy.png b/tools/sv/images/destroy.png
new file mode 100644
index 0000000000..9545fc4837
--- /dev/null
+++ b/tools/sv/images/destroy.png
Binary files differ
diff --git a/tools/sv/images/small-destroy.png b/tools/sv/images/small-destroy.png
new file mode 100644
index 0000000000..f800bd7685
--- /dev/null
+++ b/tools/sv/images/small-destroy.png
Binary files differ
diff --git a/tools/sv/images/small-pause.png b/tools/sv/images/small-pause.png
new file mode 100644
index 0000000000..7bbdbfaafe
--- /dev/null
+++ b/tools/sv/images/small-pause.png
Binary files differ
diff --git a/tools/sv/images/small-unpause.png b/tools/sv/images/small-unpause.png
new file mode 100644
index 0000000000..6ae5687a0c
--- /dev/null
+++ b/tools/sv/images/small-unpause.png
Binary files differ
diff --git a/tools/sv/inc/script.js b/tools/sv/inc/script.js
index fca5a972ab..47cd10399c 100755
--- a/tools/sv/inc/script.js
+++ b/tools/sv/inc/script.js
@@ -13,3 +13,10 @@ function doOp( op )
document.forms[0].op.value = op
document.forms[0].submit()
}
+
+function doOp2( op, args )
+{
+ document.forms[0].op.value = op
+ document.forms[0].args.value = args
+ document.forms[0].submit()
+}