ia64/xen-unstable

changeset 14870:4538426ae5fd

Added event dispatch when a VM's power state changes. Fix the host.enabled and
host.software_version definitions.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author ewan@localhost.localdomain
date Mon Apr 16 17:02:52 2007 -0400 (2007-04-16)
parents 66242baf79b1
children 338820b7ea45
files tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendAPI.py	Mon Apr 16 21:21:42 2007 +0100
     1.2 +++ b/tools/python/xen/xend/XendAPI.py	Mon Apr 16 17:02:52 2007 -0400
     1.3 @@ -152,14 +152,14 @@ def _ctor_event_dispatch(xenapi, ctor, a
     1.4      result = ctor(xenapi, session, *args)
     1.5      if result['Status'] == 'Success':
     1.6          ref = result['Value']
     1.7 -        _event_dispatch('add', api_cls, ref, '')
     1.8 +        event_dispatch('add', api_cls, ref, '')
     1.9      return result
    1.10  
    1.11  
    1.12  def _dtor_event_dispatch(xenapi, dtor, api_cls, session, ref, args):
    1.13      result = dtor(xenapi, session, ref, *args)
    1.14      if result['Status'] == 'Success':
    1.15 -        _event_dispatch('del', api_cls, ref, '')
    1.16 +        event_dispatch('del', api_cls, ref, '')
    1.17      return result
    1.18  
    1.19  
    1.20 @@ -167,11 +167,12 @@ def _setter_event_dispatch(xenapi, sette
    1.21                             args):
    1.22      result = setter(xenapi, session, ref, *args)
    1.23      if result['Status'] == 'Success':
    1.24 -        _event_dispatch('mod', api_cls, ref, attr_name)
    1.25 +        event_dispatch('mod', api_cls, ref, attr_name)
    1.26      return result
    1.27  
    1.28  
    1.29 -def _event_dispatch(operation, api_cls, ref, attr_name):
    1.30 +def event_dispatch(operation, api_cls, ref, attr_name):
    1.31 +    assert operation in ['add', 'del', 'mod']
    1.32      event = {
    1.33          'timestamp' : now(),
    1.34          'class'     : api_cls,
    1.35 @@ -934,7 +935,9 @@ class XendAPI(object):
    1.36          return xen_api_success(XEN_API_VERSION_VENDOR)
    1.37      def host_get_API_version_vendor_implementation(self, _, ref):
    1.38          return xen_api_success(XEN_API_VERSION_VENDOR_IMPLEMENTATION)
    1.39 -    def host_get_enabled(self, _, _):
    1.40 +    def host_get_software_version(self, session, host_ref):
    1.41 +        return xen_api_success(XendNode.instance().xen_version())
    1.42 +    def host_get_enabled(self, _1, _2):
    1.43          return xen_api_success(XendDomain.instance().allow_new_domains())
    1.44      def host_get_resident_VMs(self, session, host_ref):
    1.45          return xen_api_success(XendDomain.instance().get_domain_refs())
    1.46 @@ -999,6 +1002,7 @@ class XendAPI(object):
    1.47                    'API_version_vendor_implementation':
    1.48                    XEN_API_VERSION_VENDOR_IMPLEMENTATION,
    1.49                    'software_version': node.xen_version(),
    1.50 +                  'enabled': XendDomain.instance().allow_new_domains(),
    1.51                    'other_config': node.other_config,
    1.52                    'resident_VMs': dom.get_domain_refs(),
    1.53                    'host_CPUs': node.get_host_cpu_refs(),
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Mon Apr 16 21:21:42 2007 +0100
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Mon Apr 16 17:02:52 2007 -0400
     2.3 @@ -1986,6 +1986,9 @@ class XendDomainInfo:
     2.4              if self.state != state:
     2.5                  self.state = state
     2.6                  self.state_updated.notifyAll()
     2.7 +                import XendAPI
     2.8 +                XendAPI.event_dispatch('mod', 'VM', self.info['uuid'],
     2.9 +                                       'power_state')
    2.10          finally:
    2.11              self.state_updated.release()
    2.12