bitkeeper revision 1.1010.1.5 (40dbfee81bMxq2pSAYIoYZMhqQUEtg)

Fix help message for xm shutdown.
Add long format for xm list.
This commit is contained in:
mjw@wray-m-3.hpl.hp.com committed 2004-06-25 10:31:04 +00:00
1 parent 337d7b4671
commit 1cbe6bfc33
5 files changed
+42 -14

No files matched your search

+1
View File
@@ -364,6 +364,7 @@ class XendDomainInfo:
"""Update with info from xc.domain_getinfo().
"""
self.info = info
self.memory = self.info['mem_kb'] / 1024
def __str__(self):
s = "domain"
+1 -1
View File
@@ -28,7 +28,7 @@ gopts.opt('path', val='PATH',
use="Search path for default scripts.")
gopts.opt('defaults', short='f', val='FILE',
fn=set_value, default='defaults',
fn=set_value, default='xmdefaults',
use="Use the given default script.")
gopts.opt('config', short='F', val='FILE',
+36 -9
View File
@@ -4,6 +4,7 @@
import os
import os.path
import sys
from getopt import getopt
from xenmgr import PrettyPrint
from xenmgr import sxp
@@ -196,20 +197,41 @@ class ProgList(Prog):
name = "list"
info = """List info about domains."""
short_options = 'l'
long_options = ['long']
def help(self, args):
if help:
print args[0], '[DOM...]'
print args[0], '[options] [DOM...]'
print """\nGet information about domains.
Either all domains or the domains given."""
Either all domains or the domains given.
-l, --long Get more detailed information.
"""
return
def main(self, args):
n = len(args)
if n == 1:
doms = server.xend_domains()
use_long = 0
(options, params) = getopt(args[1:],
self.short_options,
self.long_options)
n = len(params)
for (k, v) in options:
if k in ['-l', '--long']:
use_long = 1
if n == 0:
doms = map(int, server.xend_domains())
doms.sort()
else:
doms = map(int, args[1:])
doms.sort()
doms = map(int, params)
if use_long:
self.long_list(doms)
else:
self.brief_list(doms)
def brief_list(self, doms):
print 'Dom Name Mem(MB) CPU State Time(s)'
for dom in doms:
info = server.xend_domain(dom)
@@ -222,6 +244,12 @@ class ProgList(Prog):
d['cpu_time'] = float(sxp.child_value(info, 'cpu_time', '0'))
print ("%(dom)-4d %(name)-16s %(mem)7d %(cpu)3d %(state)5s %(cpu_time)7.1f" % d)
def long_list(self, doms):
for dom in doms:
info = server.xend_domain(dom)
print '\nDomain %d' % dom
PrettyPrint.prettyprint(info)
xm.prog(ProgList)
class ProgDestroy(Prog):
@@ -246,8 +274,7 @@ class ProgShutdown(Prog):
info = """Shutdown a domain."""
def help(self, args):
print args[0], 'DOM'
print '\nSignal domain DOM to shutdown.'
shutdown.main([args[0], '-h'])
def main(self, args):
shutdown.main(args)
+1 -1
View File
@@ -273,7 +273,7 @@ class Opts:
self.load(p)
break
else:
self.err("Cannot open defaults file %s" % self.defaults)
self.err("Cannot open defaults file %s" % self.vals.defaults)
def load(self, defaults, help=0):
"""Load a defaults file. Local variables in the file
+3 -3
View File
@@ -50,7 +50,7 @@ def shutdown(opts, doms, wait):
opts.info("All domains terminated")
def main_all(opts, args):
shutdown(opts, None, opts.wait)
shutdown(opts, None, opts.vals.wait)
def main_dom(opts, args):
if len(args) < 1: opts.err('Missing domain')
@@ -59,7 +59,7 @@ def main_dom(opts, args):
domid = int(dom)
except:
opts.err('Invalid domain: ' + dom)
shutdown(opts, [ domid ], opts.wait)
shutdown(opts, [ domid ], opts.vals.wait)
def main(argv):
opts = gopts
@@ -68,7 +68,7 @@ def main(argv):
opts.usage()
return
print 'shutdown.main>', len(args), args
if opts.all:
if opts.vals.all:
main_all(opts, args)
else:
main_dom(opts, args)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.