ia64/xen-unstable

changeset 12209:f3f492ba8e8d

This patch adds a checking of wrong parameter into xm dmesg command.
If wrong parameter is given, xm dmesg command shows the following
error messages.

Error: No parameter required
Usage: xm dmesg [-c|--clear]

Read and/or clear Xend's message buffer.
-c, --clear Clear dmesg buffer


Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author Ewan Mellor <ewan@xensource.com>
date Wed Nov 01 15:56:55 2006 +0000 (2006-11-01)
parents 55e8f40ef6e4
children 7b5115221dfc
files tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xm/main.py	Wed Nov 01 15:56:22 2006 +0000
     1.2 +++ b/tools/python/xen/xm/main.py	Wed Nov 01 15:56:55 2006 +0000
     1.3 @@ -1071,26 +1071,23 @@ def xm_top(args):
     1.4  def xm_dmesg(args):
     1.5      arg_check(args, "dmesg", 0, 1)
     1.6      
     1.7 -    gopts = Opts(use="""[-c|--clear]
     1.8 -
     1.9 -Read Xen's message buffer (boot output, warning and error messages) or clear
    1.10 -its contents if the [-c|--clear] flag is specified.
    1.11 -""")
    1.12 -
    1.13 -    gopts.opt('clear', short='c',
    1.14 -              fn=set_true, default=0,
    1.15 -              use="Clear the contents of the Xen message buffer.")
    1.16 -    # Work around for gopts
    1.17 -    myargs = args
    1.18 -    myargs.insert(0, 'dmesg')
    1.19 -    gopts.parse(myargs)
    1.20 +    try:
    1.21 +        (options, params) = getopt.gnu_getopt(args, 'c', ['clear'])
    1.22 +    except getopt.GetoptError, opterr:
    1.23 +        err(opterr)
    1.24 +        sys.exit(1)
    1.25      
    1.26 -    if len(myargs) not in (1, 2):
    1.27 -        err('Invalid arguments: ' + str(myargs))
    1.28 +    use_clear = 0
    1.29 +    for (k, v) in options:
    1.30 +        if k in ['-c', '--clear']:
    1.31 +            use_clear = 1
    1.32 +    
    1.33 +    if len(params) :
    1.34 +        err("No parameter required")
    1.35          usage('dmesg')
    1.36          sys.exit(1)
    1.37  
    1.38 -    if not gopts.vals.clear:
    1.39 +    if not use_clear:
    1.40          print server.xend.node.dmesg.info()
    1.41      else:
    1.42          server.xend.node.dmesg.clear()