[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [XENAPI] Add missing function names. Proper sub command help messages.



# HG changeset patch
# User Alastair Tse <atse@xxxxxxxxxxxxx>
# Node ID c0d9f8b9c0e592c58b36762a5cae8a4a54fe8ad5
# Parent  19ab41db7fd27e93954ff374eb6e798df4523aa7
[XENAPI] Add missing function names. Proper sub command help messages.

Signed-off-by: Alastair Tse <atse@xxxxxxxxxxxxx>
---
 tools/python/scripts/xapi.py |   42 +++++++++++++++++++++++++++++++++---------
 1 files changed, 33 insertions(+), 9 deletions(-)

diff -r 19ab41db7fd2 -r c0d9f8b9c0e5 tools/python/scripts/xapi.py
--- a/tools/python/scripts/xapi.py      Fri Oct 06 12:31:24 2006 +0100
+++ b/tools/python/scripts/xapi.py      Fri Oct 06 12:46:46 2006 +0100
@@ -29,16 +29,18 @@ LOGIN = ('atse', 'passwd')
 
 COMMANDS = {
     'host-info': ('', 'Get Xen Host Info'),
-    'vm-list':   ('', 'List all domains.'),
-    'vm-uuid':   ('<name>', 'UUID of a domain by name.'),
-    'vm-name':   ('<uuid>', 'Name of UUID.'),
-    'vm-start':  ('<name>', 'Start VM with name'),
-    'vm-shutdown': ('<name>', 'Shutdown VM with name'),
-    'vm-create': ('<pycfg>', 'Create VM with python config'),
     'vbd-create': ('<domname> <pycfg>', 'Create VBD attached to domname'),
     'vif-create': ('<domname> <pycfg>', 'Create VIF attached to domname'),
+
+    'vm-create': ('<pycfg>', 'Create VM with python config'),
     'vm-delete': ('<domname>', 'Delete VM'),
+    
     'vm-destroy': ('<name>', 'Hard shutdown a VM with name'),
+    'vm-list':   ('', 'List all domains.'),
+    'vm-name':   ('<uuid>', 'Name of UUID.'),
+    'vm-shutdown': ('<name>', 'Shutdown VM with name'),
+    'vm-start':  ('<name>', 'Start VM with name'),
+    'vm-uuid':   ('<name>', 'UUID of a domain by name.'),    
 }
 
 OPTIONS = {
@@ -107,6 +109,22 @@ def xapi_host_info(*args):
         print HOST_INFO_FORMAT % ('VMs', len(hostinfo['resident_VMs']))
         print HOST_INFO_FORMAT % ('UUID', host)        
 
+def xapi_vm_uuid(*args):
+    if len(args) < 1:
+        raise OptionError("No domain name specified")
+    
+    server, session = _connect()
+    vm_uuid = execute(server.VM.get_by_label, session, args[0])
+    print vm_uuid
+
+def xapi_vm_name(*args):
+    if len(args) < 1:
+        raise OptionError("No UUID specified")
+    
+    server, session = _connect()
+    vm_name = execute(server.VM.get_name_label, session, args[0])
+    print vm_name
+
 def xapi_vm_list(*args):
     opts, args = parse_args('vm-list', args)
     is_long = opts and opts.long
@@ -209,6 +227,8 @@ def xapi_vif_create(*args):
     vif_uuid = execute(server.VIF.create, session, cfg)
     print 'Done. (%s)' % vif_uuid
 
+    
+
 #
 # Command Line Utils
 #
@@ -237,13 +257,17 @@ def main(args):
     if not subcmd_func or not callable(subcmd_func):
         print 'Error: Unable to find subcommand \'%s\'' % subcmd
         usage()
-        sys.exit(-1)
-                  
+        sys.exit(1)
+
+    if '-h' in args[1:] or '--help' in args[1:]:
+        usage(subcmd)
+        sys.exit(1)
+        
     try:
         subcmd_func(*args[1:])
     except XenAPIError, e:
         print 'Error: %s' % str(e.args[1])
-        sys.exit(-1)
+        sys.exit(1)
 
     sys.exit(0)
     

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.