|
|
|
|
|
|
|
|
|
|
xen-tools
[Xen-tools] Re: [Xen-devel] [PATCH] rework xen/xm/main.py to be more str
Hi Sean,
I think there are a few ways we can improve this. The key is to make
sure that we don't add additional complexity.
1) Move all of the functions that implement the commands into a separate
file (xmlib.py perhaps?)
2) Have main.py parse the command line and look in xmlib.__dict__ for
the function pointer
3) Have --help be generated based on the contents of
xmlib.__dict__[cmd].__doc__
#3 has the nice side-effect of ensuring that xmlib is completely
documented which makes xmlib the perfect python interface for management
tools. It would be even nicer if the arguments were expanded instead of
passed as a list so the functions could be called in a more natural way.
A short help can be autogenerated by only grabbing the first sentence of
__doc__.
Aliases could be supported with module-level variables assigned to the
function they alias. However, I don't like aliases so I'd just not do
anything.
One thing this would break is abbrevation but I'm quite sure Mark is the
only one using them :-)
Regards,
Anthony Liguori
Sean Dague wrote:
The following patch is a major restructuring of main.py to be more straight
forward, and remove as much code as possible. It does a number of things:
* It implements the standardized options proposed via my RFC for xm
* It restructures the calling of these functions to be function pointers out
of a dictionary, instead of subclasses found through inspection
* It consolidates all help info, making it easier to see that the help
screen looks consistent across commands
* It moves object importing into the functions that require them only,
allowing commands like "xm help" to be runable as non root
* It adds command aliasing to provide backwards compatibility with many
commands (i.e. xm balloon)
* It provides more useful error messages is most fail cases
* It implements a short help by default (which takes < 24 screen lines) as
requested by Mark W at OLS
* It attempts to trap more exceptions than before and provide useful errors
based on them (this requires more testing)
It also has the added benefit of dropping the total size of main.py from
935 lines to 694 lines.
This patch makes no changes to any other elements of xen/xm, and works with
all other objects and libraries as is.
_______________________________________________
Xen-tools mailing list
Xen-tools@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-tools
|
|
|
|
|