ia64/xen-unstable

changeset 7897:7d75f5a88f06

From Ken Grant: Add per command help / make help match new man pages.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Fri Nov 18 14:04:53 2005 +0100 (2005-11-18)
parents 7209244ea3d1
children ad2720178268
files tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xm/main.py	Fri Nov 18 13:02:33 2005 +0100
     1.2 +++ b/tools/python/xen/xm/main.py	Fri Nov 18 14:04:53 2005 +0100
     1.3 @@ -40,26 +40,81 @@ from xen.xm.opts import *
     1.4  
     1.5  import console
     1.6  
     1.7 +# Strings for shorthelp
     1.8 +console_help = "console <DomId>                  Attach to domain DomId's console."
     1.9 +create_help =  """create [-c] <ConfigFile>
    1.10 +               [Name=Value]..       Create a domain based on Config File"""
    1.11 +destroy_help = "destroy <DomId>                  Terminate a domain immediately"
    1.12 +help_help =    "help                             Display this message"
    1.13 +list_help =    "list [--long] [DomId, ...]       List information about domains"
    1.14 +mem_max_help = "mem-max <DomId> <Mem>            Set maximum memory reservation for a domain"
    1.15 +mem_set_help = "mem-set <DomId> <Mem>            Adjust the current memory usage for a domain"
    1.16 +migrate_help = "migrate <DomId> <Host>           Migrate a domain to another machine"
    1.17 +pause_help =   "pause <DomId>                    Pause execution of a domain"
    1.18 +reboot_help =  "reboot <DomId> [-w][-a]          Reboot a domain"
    1.19 +restore_help = "restore <File>                   Create a domain from a saved state file"
    1.20 +save_help =    "save <DomId> <File>              Save domain state (and config) to file"
    1.21 +shutdown_help ="shutdown <DomId> [-w][-a][-R|-H] Shutdown a domain"
    1.22 +top_help =     "top                              Monitor system and domains in real-time"
    1.23 +unpause_help = "unpause <DomId>                  Unpause a paused domain"
    1.24 +
    1.25 +help_spacer = """
    1.26 +   """
    1.27 +
    1.28 +# Strings for longhelp
    1.29 +sysrq_help =   "sysrq   <DomId> <letter>         Send a sysrq to a domain"
    1.30 +domid_help =   "domid <DomName>                  Converts a domain name to a domain id"
    1.31 +domname_help = "domname <DomId>                  Convert a domain id to a domain name"
    1.32 +set_vcpus_help = """set-vcpus <DomId> <VCPUs>        Enable the specified number of VCPUs in a
    1.33 +                                    domain"""
    1.34 +vcpu_list_help = "vcpu-list <DomId>                List the VCPUs for a domain (or all domains)"
    1.35 +vcpu_pin_help = "vcpu-pin <DomId> <VCPU> <CPUs>   Set which cpus a VCPU can use" 
    1.36 +dmesg_help =   "dmesg [--clear]                  Read or clear Xen's message buffer"
    1.37 +info_help =    "info                             Get information about the xen host"
    1.38 +log_help = "log      Print the xend log"
    1.39 +sched_bvt_help = """sched-bvt <Parameters>           Set Borrowed Virtual Time scheduler
    1.40 +                                    parameters"""
    1.41 +sched_bvt_ctxallow_help = """sched-bvt-ctxallow <Allow>       Set the BVT scheduler context switch
    1.42 +                                    allowance"""
    1.43 +sched_sedf_help = "sched-sedf <Parameters>          Set simple EDF parameters"
    1.44 +block_attach_help = """block-attach <DomId> <BackDev> <FrontDev> <Mode>
    1.45 +                [BackDomId]         Create a new virtual block device"""
    1.46 +block_detach_help = """block-detach  <DomId> <DevId>    Destroy a domain's virtual block device,
    1.47 +                                    where <DevId> may either be the device ID
    1.48 +                                    or the device name as mounted in the guest"""
    1.49 +
    1.50 +block_list_help = "block-list <DomId>               List virtual block devices for a domain"
    1.51 +network_attach_help = """network-attach  <DomID> [script=<script>] [ip=<ip>] [mac=<mac>]
    1.52 +                           [bridge=<bridge>] [backend=<backDomID>]
    1.53 +                                    Create a new virtual network device """
    1.54 +network_detach_help = """network-detach  <DomId> <DevId>  Destroy a domain's virtual network
    1.55 +                                    device, where <DevId> is the device ID."""
    1.56 +
    1.57 +network_list_help = "network-list <DomId>             List virtual network interfaces for a domain"
    1.58 +vnet_list_help = "vnet-list [-l|--long]            list vnets"
    1.59 +vnet_create_help = "vnet-create <config>             create a vnet from a config file"
    1.60 +vnet_delete_help = "vnet-delete <vnetid>             delete a vnet"
    1.61 +
    1.62  
    1.63  shorthelp = """Usage: xm <subcommand> [args]
    1.64      Control, list, and manipulate Xen guest instances
    1.65  
    1.66 -xm common subcommands:
    1.67 -    console <DomId>         attach to console of DomId
    1.68 -    create <CfgFile>        create a domain based on Config File
    1.69 -    destroy <DomId>         terminate a domain immediately
    1.70 -    help                    display this message
    1.71 -    list [DomId, ...]       list information about domains
    1.72 -    mem-max <DomId> <Mem>   set the maximum memory reservation for a domain
    1.73 -    mem-set <DomId> <Mem>   adjust the current memory usage for a domain
    1.74 -    migrate <DomId> <Host>  migrate a domain to another machine
    1.75 -    pause <DomId>           pause execution of a domain
    1.76 -    reboot <DomId>          reboot a domain
    1.77 -    restore <File>          create a domain from a saved state file
    1.78 -    save <DomId> <File>     save domain state (and config) to file
    1.79 -    shutdown <DomId>        shutdown a domain
    1.80 -    top                     monitor system and domains in real-time
    1.81 -    unpause <DomId>         unpause a paused domain
    1.82 +xm common subcommands:"""  + help_spacer \
    1.83 ++ console_help + help_spacer \
    1.84 ++ create_help + help_spacer \
    1.85 ++ destroy_help + help_spacer \
    1.86 ++ help_help    + help_spacer \
    1.87 ++ list_help    + help_spacer \
    1.88 ++ mem_max_help + help_spacer \
    1.89 ++ mem_set_help + help_spacer \
    1.90 ++ migrate_help + help_spacer \
    1.91 ++ pause_help   + help_spacer \
    1.92 ++ reboot_help  + help_spacer \
    1.93 ++ restore_help + help_spacer \
    1.94 ++ save_help    + help_spacer \
    1.95 ++ shutdown_help + help_spacer \
    1.96 ++ top_help     + help_spacer \
    1.97 ++ unpause_help + """
    1.98  
    1.99  <DomName> can be substituted for <DomId> in xm subcommands.
   1.100  
   1.101 @@ -72,58 +127,51 @@ longhelp = """Usage: xm <subcommand> [ar
   1.102  
   1.103  xm full list of subcommands:
   1.104  
   1.105 -  Domain Commands:
   1.106 -    console <DomId>           attach to console of DomId
   1.107 -    create  <ConfigFile>      create a domain
   1.108 -    destroy <DomId>           terminate a domain immediately
   1.109 -    domid   <DomName>         convert a domain name to a domain id
   1.110 -    domname <DomId>           convert a domain id to a domain name
   1.111 -    list                      list information about domains
   1.112 -    mem-max <DomId> <Mem>     set domain maximum memory limit
   1.113 -    mem-set <DomId> <Mem>     set the domain's memory dynamically
   1.114 -    migrate <DomId> <Host>    migrate a domain to another machine
   1.115 -    pause   <DomId>           pause execution of a domain
   1.116 -    reboot   [-w|-a] <DomId>  reboot a domain
   1.117 -    restore <File>            create a domain from a saved state file
   1.118 -    save    <DomId> <File>    save domain state (and config) to file
   1.119 -    shutdown [-w|-a] <DomId>  shutdown a domain
   1.120 -    sysrq   <DomId> <letter>  send a sysrq to a domain
   1.121 -    unpause <DomId>           unpause a paused domain
   1.122 -    set-vcpus <DomId> <VCPUs> enable the specified number of VCPUs in a domain
   1.123 -    vcpu-list <DomId>         list the VCPUs for a domain
   1.124 -    vcpu-pin <DomId> <VCPU> <CPUs>    set which cpus a VCPU can use. 
   1.125 +  Domain Commands: """ + help_spacer \
   1.126 ++ console_help + help_spacer \
   1.127 ++ create_help + help_spacer \
   1.128 ++ destroy_help + help_spacer \
   1.129 ++ domid_help   + help_spacer \
   1.130 ++ domname_help   + help_spacer \
   1.131 ++ list_help    + help_spacer \
   1.132 ++ mem_max_help + help_spacer \
   1.133 ++ mem_set_help + help_spacer \
   1.134 ++ migrate_help + help_spacer \
   1.135 ++ pause_help   + help_spacer \
   1.136 ++ reboot_help  + help_spacer \
   1.137 ++ restore_help + help_spacer \
   1.138 ++ save_help    + help_spacer \
   1.139 ++ shutdown_help + help_spacer \
   1.140 ++ sysrq_help + help_spacer \
   1.141 ++ top_help     + help_spacer \
   1.142 ++ unpause_help + help_spacer \
   1.143 ++ set_vcpus_help + help_spacer \
   1.144 ++ vcpu_pin_help + """
   1.145  
   1.146 -  Xen Host Commands:
   1.147 -    dmesg   [--clear]         read or clear Xen's message buffer
   1.148 -    info                      get information about the xen host
   1.149 -    log                       print the xend log
   1.150 -    top                       monitor system and domains in real-time
   1.151 -
   1.152 -  Scheduler Commands:
   1.153 -    sched-bvt <options>       set BVT scheduler parameters
   1.154 -    sched-bvt-ctxallow <Allow>
   1.155 -        Set the BVT scheduler context switch allowance
   1.156 -    sched-sedf <options>      set simple EDF parameters
   1.157 +   Xen Host Commands: """ + help_spacer \
   1.158 ++ dmesg_help + help_spacer \
   1.159 ++ info_help + help_spacer \
   1.160 ++ log_help  + help_spacer \
   1.161 ++ top_help  + """
   1.162  
   1.163 -  Virtual Device Commands:
   1.164 -    block-attach  <DomId> <BackDev> <FrontDev> <Mode> [BackDomId]
   1.165 -        Create a new virtual block device 
   1.166 -    block-detach  <DomId> <DevId>  Destroy a domain's virtual block device,
   1.167 -                                   where <DevId> may either be the device ID
   1.168 -                                   or the device name as mounted in the guest.
   1.169 -    block-list    <DomId>          List virtual block devices for a domain
   1.170 +  Scheduler Commands: """ + help_spacer \
   1.171 ++ sched_bvt_help + help_spacer \
   1.172 ++ sched_bvt_ctxallow_help + help_spacer \
   1.173 ++ sched_sedf_help + """
   1.174  
   1.175 -    network-attach  <DomID> [script=<script>] [ip=<ip>] [mac=<mac>]
   1.176 -                            [bridge=<bridge>] [backend=<backDomID>]
   1.177 -        Create a new virtual network device 
   1.178 -    network-detach  <DomId> <DevId>  Destroy a domain's virtual network
   1.179 -                                     device, where <DevId> is the device ID.
   1.180 -    network-list    <DomId>        List virtual network interfaces for a domain
   1.181 +  Virtual Device Commands:"""  + help_spacer \
   1.182 ++ block_attach_help + help_spacer \
   1.183 ++ block_detach_help + help_spacer \
   1.184 ++ block_list_help + help_spacer \
   1.185 ++ network_attach_help + help_spacer \
   1.186 ++ network_detach_help + help_spacer \
   1.187 ++ network_limit_help + help_spacer \
   1.188 ++ network_list_help + """
   1.189  
   1.190 -  Vnet commands:
   1.191 -    vnet-list   [-l|--long]    list vnets
   1.192 -    vnet-create <config>       create a vnet from a config file
   1.193 -    vnet-delete <vnetid>       delete a vnet
   1.194 +  Vnet commands: """ + help_spacer \
   1.195 ++ vnet_list_help + help_spacer \
   1.196 ++ vnet_create_help + help_spacer \
   1.197 ++ vnet_delete_help + """
   1.198  
   1.199  <DomName> can be substituted for <DomId> in xm subcommands.
   1.200  
   1.201 @@ -131,6 +179,51 @@ For a short list of subcommands run 'xm 
   1.202  For more help on xm see the xm(1) man page
   1.203  For more help on xm create, see the xmdomain.cfg(5) man page"""
   1.204  
   1.205 +# array for xm help <command>
   1.206 +help = {
   1.207 +    "--long": longhelp,
   1.208 +    "console": console_help,
   1.209 +    "create": create_help,
   1.210 +    "destroy": destroy_help,
   1.211 +    "domid ": domid_help,
   1.212 +    "domname": domname_help,
   1.213 +    "list": list_help,
   1.214 +    "mem-max": mem_max_help,
   1.215 +    "mem-set": mem_set_help,
   1.216 +    "migrate": migrate_help,
   1.217 +    "pause": pause_help,
   1.218 +    "reboot": reboot_help,
   1.219 +    "restore": restore_help,
   1.220 +    "save":  save_help,
   1.221 +    "shutdown": shutdown_help,
   1.222 +    "sysrq": sysrq_help,
   1.223 +    "unpause": unpause_help,
   1.224 +    "set-vcpus": set_vcpus_help,
   1.225 +    "vcpu-list": vcpu_list_help,
   1.226 +    "vcpu-pin": vcpu_pin_help,
   1.227 +#  Xen Host Commands:
   1.228 +    "dmesg": dmesg_help,
   1.229 +    "info":  info_help,
   1.230 +    "log":   log_help,
   1.231 +    "top":  top_help,
   1.232 +#  Scheduler Commands:
   1.233 +    "sched-bvt": sched_bvt_help,
   1.234 +    "sched-bvt-ctxallow": sched_bvt_ctxallow_help,
   1.235 +    "sched-sedf":  sched_sedf_help,
   1.236 +
   1.237 +#  Virtual Device Commands:
   1.238 +    "block-attach": block_attach_help,
   1.239 +    "block-detach": block_detach_help,
   1.240 +    "block-list": block_list_help,
   1.241 +    "network-attach": network_attach_help,
   1.242 +    "network-detach": network_detach_help,
   1.243 +    "network-list":  network_list_help,
   1.244 +# Vnet commands:
   1.245 +    "vnet-list": vnet_list_help,
   1.246 +    "vnet-create": vnet_create_help,
   1.247 +    "vnet-delete": vnet_delete_help
   1.248 +   }
   1.249 +
   1.250  ####################################################################
   1.251  #
   1.252  #  Utility functions
   1.253 @@ -734,10 +827,6 @@ aliases = {
   1.254      "vbd-list": "block-list",
   1.255      }
   1.256  
   1.257 -help = {
   1.258 -    "--long": longhelp
   1.259 -   }
   1.260 -
   1.261  
   1.262  def xm_lookup_cmd(cmd):
   1.263      if commands.has_key(cmd):
   1.264 @@ -759,7 +848,7 @@ def deprecated(old,new):
   1.265  
   1.266  def usage(cmd=None):
   1.267      if help.has_key(cmd):
   1.268 -        print help[cmd]
   1.269 +        print "   " + help[cmd]
   1.270      else:
   1.271          print shorthelp
   1.272      sys.exit(1)