direct-io.hg

changeset 11591:dfbadf4696fd

[XM] Fix argument parsing for dump-core subcommand

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Signed-off-by: Alastair Tse <atse@xensource.com>
author atse@norwich.uk.xensource.com
date Sat Sep 23 13:39:32 2006 +0100 (2006-09-23)
parents 047669f57e5c
children 5c58df8c7885
files tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xm/main.py	Sat Sep 23 12:39:18 2006 +0100
     1.2 +++ b/tools/python/xen/xm/main.py	Sat Sep 23 13:39:32 2006 +0100
     1.3 @@ -701,22 +701,21 @@ def xm_unpause(args):
     1.4      server.xend.domain.unpause(dom)
     1.5  
     1.6  def xm_dump_core(args):
     1.7 -    arg_check(args, "dump-core",1,3)
     1.8      live = False
     1.9      crash = False
    1.10 -    import getopt
    1.11 -    (options, params) = getopt.gnu_getopt(args, 'LC', ['live','crash'])
    1.12 +    try:
    1.13 +        (options, params) = getopt.gnu_getopt(args, 'LC', ['live','crash'])
    1.14 +        for (k, v) in options:
    1.15 +            if k in ('-L', '--live'):
    1.16 +                live = True
    1.17 +            if k in ('-C', '--crash'):
    1.18 +                crash = True
    1.19  
    1.20 -    for (k, v) in options:
    1.21 -        if k in ['-L', '--live']:
    1.22 -            live = True
    1.23 -        if k in ['-C', '--crash']:
    1.24 -            crash = True
    1.25 -
    1.26 -    if len(params) == 0 or len(params) > 2:
    1.27 -        err("invalid number of parameters")
    1.28 -        usage("dump-core")
    1.29 -
    1.30 +        if len(params) not in (1, 2):
    1.31 +            raise OptionError("Expects 1 or 2 argument(s)")
    1.32 +    except getopt.GetoptError, e:
    1.33 +        raise OptionError(str(e))
    1.34 +    
    1.35      dom = params[0]
    1.36      if len(params) == 2:
    1.37          filename = os.path.abspath(params[1])
    1.38 @@ -727,14 +726,14 @@ def xm_dump_core(args):
    1.39          server.xend.domain.pause(dom)
    1.40  
    1.41      try:
    1.42 -        print "dumping core of domain:%s ..." % str(dom)
    1.43 +        print "Dumping core of domain: %s ..." % str(dom)
    1.44          server.xend.domain.dump(dom, filename, live, crash)
    1.45      finally:
    1.46          if not live:
    1.47              server.xend.domain.unpause(dom)
    1.48  
    1.49      if crash:
    1.50 -        print "destroying domain:%s ..." % str(dom)
    1.51 +        print "Destroying domain: %s ..." % str(dom)
    1.52          server.xend.domain.destroy(dom)
    1.53  
    1.54  def xm_rename(args):