ia64/xen-unstable

changeset 12108:dd044380b44d

[XEND] Keep track of attached vbds and vifs for XenAPI

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Fri Oct 06 12:30:46 2006 +0100 (2006-10-06)
parents 18506db37dc2
children 19ab41db7fd2
files tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendConfig.py
line diff
     1.1 --- a/tools/python/xen/xend/XendAPI.py	Fri Oct 06 12:02:29 2006 +0100
     1.2 +++ b/tools/python/xen/xend/XendAPI.py	Fri Oct 06 12:30:46 2006 +0100
     1.3 @@ -833,7 +833,9 @@ class XendAPI:
     1.4      def vm_get_by_label(self, session, label):
     1.5          xendom = XendDomain.instance()
     1.6          dom = xendom.domain_lookup_nr(label)
     1.7 -        return xen_api_success(dom.get_uuid())
     1.8 +        if dom:
     1.9 +            return xen_api_success(dom.get_uuid())
    1.10 +        return xen_api_error(XEND_ERROR_VM_INVALID)
    1.11      def vm_create(self, session, vm_struct):
    1.12          xendom = XendDomain.instance()
    1.13          domuuid = xendom.create_domain(vm_struct)
     2.1 --- a/tools/python/xen/xend/XendConfig.py	Fri Oct 06 12:02:29 2006 +0100
     2.2 +++ b/tools/python/xen/xend/XendConfig.py	Fri Oct 06 12:30:46 2006 +0100
     2.3 @@ -726,7 +726,10 @@ class XendConfig(dict):
     2.4              raise XendConfigError("XendConfig: device_add requires some "
     2.5                                    "config.")
     2.6  
     2.7 -        log.debug("XendConfig.device_add: %s" % str(cfg_sxp))
     2.8 +        if cfg_sxp:
     2.9 +            log.debug("XendConfig.device_add: %s" % str(cfg_sxp))
    2.10 +        if cfg_xenapi:
    2.11 +            log.debug("XendConfig.device_add: %s" % str(cfg_xenapi))
    2.12  
    2.13          if cfg_sxp:
    2.14              config = sxp.child0(cfg_sxp)
    2.15 @@ -743,6 +746,8 @@ class XendConfig(dict):
    2.16              dev_uuid = dev_info.get('uuid', uuid.createString())
    2.17              dev_info['uuid'] = dev_uuid
    2.18              self['device'][dev_uuid] = (dev_type, dev_info)
    2.19 +            if dev_type in ('vif', 'vbd'):
    2.20 +                self['%s_refs' % dev_type].append(dev_uuid)
    2.21              return dev_uuid
    2.22  
    2.23          if cfg_xenapi:
    2.24 @@ -761,6 +766,7 @@ class XendConfig(dict):
    2.25                  dev_uuid = cfg_xenapi.get('uuid', uuid.createString())
    2.26                  dev_info['uuid'] = dev_uuid
    2.27                  self['device'][dev_uuid] = (dev_type, dev_info)
    2.28 +                self['vif_refs'].append(dev_uuid)
    2.29                  return dev_uuid
    2.30              
    2.31              elif dev_type == 'vbd':
    2.32 @@ -774,6 +780,7 @@ class XendConfig(dict):
    2.33                  dev_uuid = cfg_xenapi.get('uuid', uuid.createString())
    2.34                  dev_info['uuid'] = dev_uuid
    2.35                  self['device'][dev_uuid] = (dev_type, dev_info)
    2.36 +                self['vbd_refs'].append(dev_uuid)                
    2.37                  return dev_uuid
    2.38                  
    2.39