ia64/xen-unstable

changeset 14658:d93a48816328

Let xm commands use domids with XenAPI

signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
author Tom Wilkie <tom.wilkie@gmail.com>
date Thu Mar 29 17:09:49 2007 +0100 (2007-03-29)
parents b7ae31726aa6
children 3681f91a91e8
files tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xm/main.py	Thu Mar 29 16:52:40 2007 +0100
     1.2 +++ b/tools/python/xen/xm/main.py	Thu Mar 29 17:09:49 2007 +0100
     1.3 @@ -560,11 +560,21 @@ def err(msg):
     1.4  def get_single_vm(dom):
     1.5      if serverType == SERVER_XEN_API:
     1.6          uuids = server.xenapi.VM.get_by_name_label(dom)
     1.7 -        n = len(uuids)
     1.8 -        if n > 0:
     1.9 +        if len(uuids) > 0:
    1.10              return uuids[0]
    1.11 -        else:
    1.12 -            raise OptionError("Domain '%s' not found." % dom)
    1.13 +
    1.14 +        try:
    1.15 +            domid = int(dom)
    1.16 +            uuids = [server.xenapi.VM.get_domid(vm_ref)
    1.17 +                     for vm_ref in server.xenapi.VM.get_all()
    1.18 +                     if int(server.xenapi.VM.get_domid(vm_ref)) == domid]
    1.19 +        except:
    1.20 +            pass
    1.21 +            
    1.22 +        if len(uuids) > 0:
    1.23 +            return uuids[0]
    1.24 +
    1.25 +        raise OptionError("Domain '%s' not found." % dom)
    1.26      else:
    1.27          dominfo = server.xend.domain(dom, False)
    1.28          return dominfo['uuid']