annotate tools/python/xen/xm/ @ 11572:ad22c711ccb7

[XM] Error handling cleanup

Introducing an OptionError exception to be used by all xm subcommands
to signal an error in the arguments. "xm" will catch these and output
the appropriate error and usage message.

Detailed Changes:
* Cleaned up imports and moved warning filter outside of
import block.
* Converted usage parameters and description to a python
dict rather than strings to enable better usage help
* Removed unused list_label domain command.
* Added cmdHelp() prints out usage message for any command
* Added shortHelp() prints out the default help message when
xm is invoked with no arguments.
* Added longHelp() prints out long help message when invoked
with xm --help or xm help.
* Added extra optional paramter to getDomains() so we can
tell Xend not to poll devices. This will speed up xm list.
(PENDING changes to Xend itself.)
* Changed all references where 'dom' actually means 'domid'
to use the correct name.
* Changed 'xm list' header format to use printf formatting style.
* Renamed xm_subcommand to xm_importcommand so it is more
clear what it is doing (all xm commands are subcommands!)
* Moved cpu_make_map() inside xm_vcpu_pin as an anonymous func.
* Use OptionError whenever an invalid option is detected in xm.
* Added proper catch and error printing for XendError and
OptionErrors in main().
* Replaced usage() with help() that is called from
* Replaced usage() invokation with raising OptionError
* Added very simple wrap() function that behaves differently
to textwrap.wrap()
* Added OptionError()
* Replaced the string representation of Opt, Opts to output
a nicely formatted usage message.
* Changed class Opts itself will throw approriate OptionErrors.
* Changed set_bool to recognise 'y' and 'n' as valid input
* Some whitespace and column width cleanup.
* throws OptionError if encounters option error.
* Replace usage() message with the string representation of
* Replace usage message with throwing OptionErrors

Signed-off-by: Alastair Tse <>
date Fri Sep 22 11:37:31 2006 +0100 (2006-09-22)
parents 713328270fb3
rev   line source
emellor@7312 1 #============================================================================
emellor@7312 2 # This library is free software; you can redistribute it and/or
emellor@7312 3 # modify it under the terms of version 2.1 of the GNU Lesser General Public
emellor@7312 4 # License as published by the Free Software Foundation.
emellor@7312 5 #
emellor@7312 6 # This library is distributed in the hope that it will be useful,
emellor@7312 7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
emellor@7312 9 # Lesser General Public License for more details.
emellor@7312 10 #
emellor@7312 11 # You should have received a copy of the GNU Lesser General Public
emellor@7312 12 # License along with this library; if not, write to the Free Software
emellor@7312 13 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
emellor@7312 14 #============================================================================
emellor@7312 15 # Copyright (C) 2005 XenSource Ltd
emellor@7312 16 #============================================================================
emellor@7312 17
emellor@7312 18
emellor@7312 19 XENCONSOLE = "xenconsole"
emellor@7312 20
emellor@7312 21 import xen.util.auxbin
emellor@7312 22
emellor@7312 23 def execConsole(domid):
emellor@7312 24 xen.util.auxbin.execute(XENCONSOLE, [str(domid)])