# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID e236794915cc152a949691ca5613cac63375c314
# Parent 6604238412bec090ceaf08bf139ca95403a62504
[TOOLS] Fix cm argument processing some more:
1. Remove has_long_option() and add arg_check_for_resource_list()
instead.
2. 'args' tells 'options' from 'params' by using gnu_getopt().
3. 'options' checks whether -l/--long option is specified.
4. If 'params' not given, print out 'No domain parameter given'
and usage.
5. If 'params' given multiple domains, print out
'No multiple domain parameters allowed' and usage.
6. Then it displays the resources as usual.
Signed-off-by: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
---
tools/python/xen/xm/main.py | 37 +++++++++++++++----------------------
1 files changed, 15 insertions(+), 22 deletions(-)
diff -r 6604238412be -r e236794915cc tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Tue Jun 27 10:44:33 2006 +0100
+++ b/tools/python/xen/xm/main.py Tue Jun 27 11:05:39 2006 +0100
@@ -887,7 +887,7 @@ def parse_dev_info(info):
'ring-ref' : get_info('ring-ref', int, -1),
}
-def has_long_option(args):
+def arg_check_for_resource_list(args, name):
use_long = 0
try:
(options, params) = getopt.gnu_getopt(args, 'l', ['long'])
@@ -898,16 +898,19 @@ def has_long_option(args):
for (k, v) in options:
if k in ['-l', '--long']:
use_long = 1
- return (use_long, params)
-
-def xm_network_list(args):
- arg_check(args, "network-list", 1, 2)
-
- (use_long, params) = has_long_option(args)
if len(params) == 0:
print 'No domain parameter given'
- sys.exit(1)
+ usage(name)
+ if len(params) > 1:
+ print 'No multiple domain parameters allowed'
+ usage(name)
+
+ return (use_long, params)
+
+def xm_network_list(args):
+ (use_long, params) = arg_check_for_resource_list(args, "network-list")
+
dom = params[0]
if use_long:
devs = server.xend.domain.getDeviceSxprs(dom, 'vif')
@@ -931,13 +934,8 @@ def xm_network_list(args):
% ni)
def xm_block_list(args):
- arg_check(args, "block-list", 1, 2)
-
- (use_long, params) = has_long_option(args)
-
- if len(params) == 0:
- print 'No domain parameter given'
- sys.exit(1)
+ (use_long, params) = arg_check_for_resource_list(args, "block-list")
+
dom = params[0]
if use_long:
devs = server.xend.domain.getDeviceSxprs(dom, 'vbd')
@@ -960,13 +958,8 @@ def xm_block_list(args):
% ni)
def xm_vtpm_list(args):
- arg_check(args, "vtpm-list", 1, 2)
-
- (use_long, params) = has_long_option(args)
-
- if len(params) == 0:
- print 'No domain parameter given'
- sys.exit(1)
+ (use_long, params) = arg_check_for_resource_list(args, "vtpm-list")
+
dom = params[0]
if use_long:
devs = server.xend.domain.getDeviceSxprs(dom, 'vtpm')
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|