mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
Programmatically generate the xm help strings from the snippets, rather than
splicing the strings together manually. Replace the word "bogus" with the command in question where it appears, as this shows up in the Usage statements. Signed-off-by: Ewan Mellor <ewan@xensource.com>
This commit is contained in:
1 parent
c039c43deb
commit
114f16d3fb
1 file changed
+99
-104
+99
-104
@@ -24,7 +24,6 @@
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import commands
|
||||
import re
|
||||
from getopt import getopt
|
||||
import socket
|
||||
@@ -71,7 +70,7 @@ vcpu_list_help = "vcpu-list <DomId> List the VCPUs for a domain (
|
||||
vcpu_pin_help = "vcpu-pin <DomId> <VCPU> <CPUs> Set which cpus a VCPU can use"
|
||||
dmesg_help = "dmesg [--clear] Read or clear Xen's message buffer"
|
||||
info_help = "info Get information about the xen host"
|
||||
log_help = "log Print the xend log"
|
||||
log_help = "log Print the xend log"
|
||||
sched_bvt_help = """sched-bvt <Parameters> Set Borrowed Virtual Time scheduler
|
||||
parameters"""
|
||||
sched_bvt_ctxallow_help = """sched-bvt-ctxallow <Allow> Set the BVT scheduler context switch
|
||||
@@ -96,25 +95,87 @@ vnet_create_help = "vnet-create <config> create a vnet from a config
|
||||
vnet_delete_help = "vnet-delete <vnetid> delete a vnet"
|
||||
|
||||
|
||||
short_command_list = [
|
||||
"console",
|
||||
"create",
|
||||
"destroy",
|
||||
"help",
|
||||
"list",
|
||||
"mem-max",
|
||||
"mem-set",
|
||||
"migrate",
|
||||
"pause",
|
||||
"reboot",
|
||||
"restore",
|
||||
"save",
|
||||
"shutdown",
|
||||
"top",
|
||||
"unpause",
|
||||
]
|
||||
|
||||
domain_commands = [
|
||||
"console",
|
||||
"create",
|
||||
"destroy",
|
||||
"domid",
|
||||
"domname",
|
||||
"list",
|
||||
"mem-max",
|
||||
"mem-set",
|
||||
"migrate",
|
||||
"pause",
|
||||
"reboot",
|
||||
"restore",
|
||||
"save",
|
||||
"shutdown",
|
||||
"sysrq",
|
||||
"top",
|
||||
"unpause",
|
||||
"set-vcpus",
|
||||
"vcpu-pin",
|
||||
]
|
||||
|
||||
host_commands = [
|
||||
"dmesg",
|
||||
"info",
|
||||
"log",
|
||||
"top",
|
||||
]
|
||||
|
||||
scheduler_commands = [
|
||||
"sched-bvt",
|
||||
"sched-bvt-ctxallow",
|
||||
"sched-sedf",
|
||||
]
|
||||
|
||||
device_commands = [
|
||||
"block-attach",
|
||||
"block-detach",
|
||||
"block-list",
|
||||
"network-attach",
|
||||
"network-detach",
|
||||
"network-list",
|
||||
]
|
||||
|
||||
vnet_commands = [
|
||||
"vnet-list",
|
||||
"vnet-create",
|
||||
"vnet-delete",
|
||||
]
|
||||
|
||||
all_commands = (domain_commands + host_commands + scheduler_commands +
|
||||
device_commands + vnet_commands)
|
||||
|
||||
|
||||
def commandToHelp(cmd):
|
||||
return eval(cmd.replace("-", "_") + "_help")
|
||||
|
||||
|
||||
shorthelp = """Usage: xm <subcommand> [args]
|
||||
Control, list, and manipulate Xen guest instances
|
||||
|
||||
xm common subcommands:""" + help_spacer \
|
||||
+ console_help + help_spacer \
|
||||
+ create_help + help_spacer \
|
||||
+ destroy_help + help_spacer \
|
||||
+ help_help + help_spacer \
|
||||
+ list_help + help_spacer \
|
||||
+ mem_max_help + help_spacer \
|
||||
+ mem_set_help + help_spacer \
|
||||
+ migrate_help + help_spacer \
|
||||
+ pause_help + help_spacer \
|
||||
+ reboot_help + help_spacer \
|
||||
+ restore_help + help_spacer \
|
||||
+ save_help + help_spacer \
|
||||
+ shutdown_help + help_spacer \
|
||||
+ top_help + help_spacer \
|
||||
+ unpause_help + """
|
||||
xm common subcommands:
|
||||
""" + help_spacer.join(map(commandToHelp, short_command_list)) + """
|
||||
|
||||
<DomName> can be substituted for <DomId> in xm subcommands.
|
||||
|
||||
@@ -127,50 +188,20 @@ longhelp = """Usage: xm <subcommand> [args]
|
||||
|
||||
xm full list of subcommands:
|
||||
|
||||
Domain Commands: """ + help_spacer \
|
||||
+ console_help + help_spacer \
|
||||
+ create_help + help_spacer \
|
||||
+ destroy_help + help_spacer \
|
||||
+ domid_help + help_spacer \
|
||||
+ domname_help + help_spacer \
|
||||
+ list_help + help_spacer \
|
||||
+ mem_max_help + help_spacer \
|
||||
+ mem_set_help + help_spacer \
|
||||
+ migrate_help + help_spacer \
|
||||
+ pause_help + help_spacer \
|
||||
+ reboot_help + help_spacer \
|
||||
+ restore_help + help_spacer \
|
||||
+ save_help + help_spacer \
|
||||
+ shutdown_help + help_spacer \
|
||||
+ sysrq_help + help_spacer \
|
||||
+ top_help + help_spacer \
|
||||
+ unpause_help + help_spacer \
|
||||
+ set_vcpus_help + help_spacer \
|
||||
+ vcpu_pin_help + """
|
||||
Domain Commands:
|
||||
""" + help_spacer.join(map(commandToHelp, domain_commands)) + """
|
||||
|
||||
Xen Host Commands: """ + help_spacer \
|
||||
+ dmesg_help + help_spacer \
|
||||
+ info_help + help_spacer \
|
||||
+ log_help + help_spacer \
|
||||
+ top_help + """
|
||||
Xen Host Commands:
|
||||
""" + help_spacer.join(map(commandToHelp, host_commands)) + """
|
||||
|
||||
Scheduler Commands: """ + help_spacer \
|
||||
+ sched_bvt_help + help_spacer \
|
||||
+ sched_bvt_ctxallow_help + help_spacer \
|
||||
+ sched_sedf_help + """
|
||||
Scheduler Commands:
|
||||
""" + help_spacer.join(map(commandToHelp, scheduler_commands)) + """
|
||||
|
||||
Virtual Device Commands:""" + help_spacer \
|
||||
+ block_attach_help + help_spacer \
|
||||
+ block_detach_help + help_spacer \
|
||||
+ block_list_help + help_spacer \
|
||||
+ network_attach_help + help_spacer \
|
||||
+ network_detach_help + help_spacer \
|
||||
+ network_list_help + """
|
||||
Virtual Device Commands:
|
||||
""" + help_spacer.join(map(commandToHelp, device_commands)) + """
|
||||
|
||||
Vnet commands: """ + help_spacer \
|
||||
+ vnet_list_help + help_spacer \
|
||||
+ vnet_create_help + help_spacer \
|
||||
+ vnet_delete_help + """
|
||||
Vnet commands:
|
||||
""" + help_spacer.join(map(commandToHelp, vnet_commands)) + """
|
||||
|
||||
<DomName> can be substituted for <DomId> in xm subcommands.
|
||||
|
||||
@@ -180,48 +211,14 @@ For more help on xm create, see the xmdomain.cfg(5) man page"""
|
||||
|
||||
# array for xm help <command>
|
||||
help = {
|
||||
"--long": longhelp,
|
||||
"console": console_help,
|
||||
# create is handled specially
|
||||
"destroy": destroy_help,
|
||||
"domid ": domid_help,
|
||||
"domname": domname_help,
|
||||
"list": list_help,
|
||||
"mem-max": mem_max_help,
|
||||
"mem-set": mem_set_help,
|
||||
"migrate": migrate_help,
|
||||
"pause": pause_help,
|
||||
"reboot": reboot_help,
|
||||
"restore": restore_help,
|
||||
"save": save_help,
|
||||
"shutdown": shutdown_help,
|
||||
"sysrq": sysrq_help,
|
||||
"unpause": unpause_help,
|
||||
"set-vcpus": set_vcpus_help,
|
||||
"vcpu-list": vcpu_list_help,
|
||||
"vcpu-pin": vcpu_pin_help,
|
||||
# Xen Host Commands:
|
||||
"dmesg": dmesg_help,
|
||||
"info": info_help,
|
||||
"log": log_help,
|
||||
"top": top_help,
|
||||
# Scheduler Commands:
|
||||
"sched-bvt": sched_bvt_help,
|
||||
"sched-bvt-ctxallow": sched_bvt_ctxallow_help,
|
||||
"sched-sedf": sched_sedf_help,
|
||||
"--long": longhelp
|
||||
}
|
||||
|
||||
for command in all_commands:
|
||||
# create is handled specially
|
||||
if (command != 'create'):
|
||||
help[command] = commandToHelp(command)
|
||||
|
||||
# Virtual Device Commands:
|
||||
"block-attach": block_attach_help,
|
||||
"block-detach": block_detach_help,
|
||||
"block-list": block_list_help,
|
||||
"network-attach": network_attach_help,
|
||||
"network-detach": network_detach_help,
|
||||
"network-list": network_list_help,
|
||||
# Vnet commands:
|
||||
"vnet-list": vnet_list_help,
|
||||
"vnet-create": vnet_create_help,
|
||||
"vnet-delete": vnet_delete_help
|
||||
}
|
||||
|
||||
####################################################################
|
||||
#
|
||||
@@ -484,9 +481,7 @@ def xm_vcpu_list(args):
|
||||
def xm_reboot(args):
|
||||
arg_check(args,1,"reboot")
|
||||
from xen.xm import shutdown
|
||||
# ugly hack because the opt parser apparently wants
|
||||
# the subcommand name just to throw it away!
|
||||
shutdown.main(["bogus", "-R"] + args)
|
||||
shutdown.main(["shutdown", "-R"] + args)
|
||||
|
||||
def xm_pause(args):
|
||||
arg_check(args, 1, "pause")
|
||||
@@ -504,7 +499,7 @@ def xm_unpause(args):
|
||||
|
||||
def xm_subcommand(command, args):
|
||||
cmd = __import__(command, globals(), locals(), 'xen.xm')
|
||||
cmd.main(["bogus"] + args)
|
||||
cmd.main([command] + args)
|
||||
|
||||
|
||||
#############################################################
|
||||
@@ -632,7 +627,7 @@ its contents if the [-c|--clear] flag is specified.
|
||||
use="Clear the contents of the Xen message buffer.")
|
||||
# Work around for gopts
|
||||
myargs = args
|
||||
myargs.insert(0, "bogus")
|
||||
myargs.insert(0, 'dmesg')
|
||||
gopts.parse(myargs)
|
||||
if not (1 <= len(myargs) <= 2):
|
||||
err('Invalid arguments: ' + str(myargs))
|
||||
|
||||