ia64/xen-unstable

changeset 14413:30a83a0839bd

Implement xm domid and xm console using the Xen-API, and fix xm domname.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
author Ewan Mellor <ewan@xensource.com>
date Wed Mar 14 23:26:33 2007 +0000 (2007-03-14)
parents b39c0a79d4d5
children e9ef0808c09f
files tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xm/main.py	Wed Mar 14 23:16:59 2007 +0000
     1.2 +++ b/tools/python/xen/xm/main.py	Wed Mar 14 23:26:33 2007 +0000
     1.3 @@ -1140,14 +1140,16 @@ def xm_destroy(args):
     1.4      else:
     1.5          server.xend.domain.destroy(dom)
     1.6  
     1.7 -
     1.8  def xm_domid(args):
     1.9      arg_check(args, "domid", 1)
    1.10  
    1.11      name = args[0]
    1.12  
    1.13 -    dom = server.xend.domain(name)
    1.14 -    print sxp.child_value(dom, 'domid')
    1.15 +    if serverType == SERVER_XEN_API:
    1.16 +        print server.xenapi.VM.get_domid(get_single_vm(name))
    1.17 +    else:
    1.18 +        dom = server.xend.domain(name)
    1.19 +        print sxp.child_value(dom, 'domid')
    1.20      
    1.21  def xm_domname(args):
    1.22      arg_check(args, "domname", 1)
    1.23 @@ -1155,7 +1157,7 @@ def xm_domname(args):
    1.24      name = args[0]
    1.25      
    1.26      if serverType == SERVER_XEN_API:
    1.27 -        print server.xenapi.VM.get_domid(get_single_vm(dom))
    1.28 +        print server.xenapi.VM.get_name_label(get_single_vm(name))
    1.29      else:
    1.30          dom = server.xend.domain(name)
    1.31          print sxp.child_value(dom, 'name')
    1.32 @@ -1384,13 +1386,17 @@ def xm_console(args):
    1.33      dom = params[0]
    1.34  
    1.35      try:
    1.36 -        info = server.xend.domain(dom)
    1.37 +        if serverType == SERVER_XEN_API:
    1.38 +            domid = int(server.xenapi.VM.get_domid(get_single_vm(dom)))
    1.39 +        else:
    1.40 +            info = server.xend.domain(dom)
    1.41 +            domid = int(sxp.child_value(info, 'domid', '-1'))
    1.42      except:
    1.43          if quiet:
    1.44              sys.exit(1)
    1.45          else:
    1.46              raise
    1.47 -    domid = int(sxp.child_value(info, 'domid', '-1'))
    1.48 +        
    1.49      if domid == -1:
    1.50          if quiet:
    1.51              sys.exit(1)