ia64/xen-unstable

changeset 16016:5c7afb32df99

xm: Print xend config via 'xm info --config'.
Signed-off-by: Akio Takebe <takebe_akio@jp.fujitsu.com>
author Keir Fraser <keir@xensource.com>
date Mon Oct 01 06:39:00 2007 +0100 (2007-10-01)
parents 0416abdd0efd
children f71b7d6ad5d8 96895c637d27
files tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xm/main.py	Mon Oct 01 06:36:25 2007 +0100
     1.2 +++ b/tools/python/xen/xm/main.py	Mon Oct 01 06:39:00 2007 +0100
     1.3 @@ -55,6 +55,9 @@ from xen.util.acmpolicy import ACM_LABEL
     1.4  
     1.5  import XenAPI
     1.6  
     1.7 +import inspect
     1.8 +from xen.xend import XendOptions
     1.9 +xoptions = XendOptions.instance()
    1.10  
    1.11  # getopt.gnu_getopt is better, but only exists in Python 2.3+.  Use
    1.12  # getopt.getopt if gnu_getopt is not available.  This will mean that options
    1.13 @@ -1595,7 +1598,31 @@ def xm_sched_credit(args):
    1.14                  err(str(result))
    1.15  
    1.16  def xm_info(args):
    1.17 -    arg_check(args, "info", 0)
    1.18 +    arg_check(args, "info", 0, 1)
    1.19 +    
    1.20 +    try:
    1.21 +        (options, params) = getopt.gnu_getopt(args, 'c', ['config'])
    1.22 +    except getopt.GetoptError, opterr:
    1.23 +        err(opterr)
    1.24 +        usage('info')
    1.25 +    
    1.26 +    show_xend_config = 0
    1.27 +    for (k, v) in options:
    1.28 +        if k in ['-c', '--config']:
    1.29 +            show_xend_config = 1
    1.30 +
    1.31 +    if show_xend_config:
    1.32 +        for name, obj in inspect.getmembers(xoptions):
    1.33 +            if not inspect.ismethod(obj):
    1.34 +                if name == "config":
    1.35 +                    for x in obj[1:]:
    1.36 +                        if len(x) < 2: 
    1.37 +                            print "%-38s: (none)" % x[0]
    1.38 +                        else: 
    1.39 +                            print "%-38s:" % x[0], x[1]
    1.40 +                else:
    1.41 +                    print "%-38s:" % name, obj
    1.42 +        return
    1.43  
    1.44      if serverType == SERVER_XEN_API:
    1.45