WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [TOOLS] Fix cm argument processing some m

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [TOOLS] Fix cm argument processing some more:
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 27 Jun 2006 12:50:16 +0000
Delivery-date: Tue, 27 Jun 2006 05:52:25 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [TOOLS] Fix cm argument processing some more:, Xen patchbot-unstable <=