ia64/xen-unstable

changeset 12531:6661355c450e

Added an xm console -q flag.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Tue Nov 21 11:21:20 2006 +0000 (2006-11-21)
parents 00ed59a6f043
children 0747d0b11232
files tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xm/main.py	Tue Nov 21 10:22:19 2006 +0000
     1.2 +++ b/tools/python/xen/xm/main.py	Tue Nov 21 11:21:20 2006 +0000
     1.3 @@ -67,7 +67,7 @@ USAGE_FOOTER = '<Domain> can either be t
     1.4  SUBCOMMAND_HELP = {
     1.5      # common commands
     1.6      
     1.7 -    'console'     : ('<Domain>',
     1.8 +    'console'     : ('[-q|--quiet] <Domain>',
     1.9                       'Attach to <Domain>\'s console.'),
    1.10      'create'      : ('<ConfigFile> [options] [vars]',
    1.11                       'Create a domain based on <ConfigFile>.'),
    1.12 @@ -190,6 +190,9 @@ SUBCOMMAND_OPTIONS = {
    1.13         ('-l', '--long', 'Output all VM details in SXP'),
    1.14         ('', '--label',  'Include security labels'),
    1.15      ),
    1.16 +    'console': (
    1.17 +       ('-q', '--quiet', 'Do not print an error message if the domain does not exist'),
    1.18 +    ),
    1.19      'dmesg': (
    1.20         ('-c', '--clear', 'Clear dmesg buffer'),
    1.21      ),
    1.22 @@ -1002,15 +1005,46 @@ def xm_info(args):
    1.23              print "%-23s:" % x[0], x[1]
    1.24  
    1.25  def xm_console(args):
    1.26 -    arg_check(args, "console", 1)
    1.27 +    arg_check(args, "console", 1, 2)
    1.28 +
    1.29 +    quiet = False;
    1.30 +
    1.31 +    try:
    1.32 +        (options, params) = getopt.gnu_getopt(args, 'q', ['quiet'])
    1.33 +    except getopt.GetoptError, opterr:
    1.34 +        err(opterr)
    1.35 +        sys.exit(1)
    1.36  
    1.37 -    dom = args[0]
    1.38 -    info = server.xend.domain(dom)
    1.39 +    for (k, v) in options:
    1.40 +        if k in ['-q', '--quiet']:
    1.41 +            quiet = True
    1.42 +        else:
    1.43 +            assert False
    1.44 +
    1.45 +    if len(params) != 1:
    1.46 +        err('No domain given')
    1.47 +        usage('console')
    1.48 +        sys.exit(1)
    1.49 +
    1.50 +    dom = params[0]
    1.51 +
    1.52 +    try:
    1.53 +        info = server.xend.domain(dom)
    1.54 +    except:
    1.55 +        if quiet:
    1.56 +            sys.exit(1)
    1.57 +        else:
    1.58 +            raise
    1.59      domid = int(sxp.child_value(info, 'domid', '-1'))
    1.60      if domid == -1:
    1.61 -        raise Exception("Domain is not started")
    1.62 +        if quiet:
    1.63 +            sys.exit(1)
    1.64 +        else:
    1.65 +            raise Exception("Domain is not started")
    1.66 +
    1.67      console.execConsole(domid)
    1.68  
    1.69 +
    1.70  def xm_uptime(args):
    1.71      short_mode = 0
    1.72