Added host.API_version_{major,minor,vendor,vendor_implementation} fields.

Fix missing host.other_config from the record returned by Xend.

Improve the error diagnosis when we catch TypeError.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
This commit is contained in:
Ewan Mellor committed 2007-02-25 17:20:51 +00:00
1 parent b0a0faf30a
commit 5baa3458c5
5 files changed
+301 -14

No files matched your search

+35 -14
View File
@@ -25,6 +25,7 @@ import threading
from xen.xend import XendDomain, XendDomainInfo, XendNode, XendDmesg
from xen.xend import XendLogging, XendTaskManager
from xen.xend.XendAPIVersion import *
from xen.xend.XendAuthSessions import instance as auth_manager
from xen.xend.XendError import *
from xen.xend.XendClient import ERROR_INVALID_DOMAIN
@@ -104,20 +105,22 @@ def catch_typeerror(func):
except TypeError, exn:
#log.exception('catch_typeerror')
if hasattr(func, 'api') and func.api in argcounts:
# Assume that if the exception was thrown inside this
# file, then it is due to an invalid call from the client,
# but if it was thrown elsewhere, then it's an internal
# Assume that if the argument count was wrong and if the
# exception was thrown inside this file, then it is due to an
# invalid call from the client, otherwise it's an internal
# error (which will be handled further up).
tb = sys.exc_info()[2]
try:
sourcefile = traceback.extract_tb(tb)[-1][0]
if sourcefile == inspect.getsourcefile(XendAPI):
return xen_api_error(
['MESSAGE_PARAMETER_COUNT_MISMATCH',
func.api, argcounts[func.api],
len(args) + len(kwargs)])
finally:
del tb
expected = argcounts[func.api]
actual = len(args) + len(kwargs)
if expected != actual:
tb = sys.exc_info()[2]
try:
sourcefile = traceback.extract_tb(tb)[-1][0]
if sourcefile == inspect.getsourcefile(XendAPI):
return xen_api_error(
['MESSAGE_PARAMETER_COUNT_MISMATCH',
func.api, expected, actual])
finally:
del tb
raise
return f
@@ -627,7 +630,11 @@ class XendAPI(object):
'resident_VMs',
'host_CPUs',
'metrics',
'supported_bootloaders']
'supported_bootloaders',
'API_version_major',
'API_version_minor',
'API_version_vendor',
'API_version_vendor_implementation']
host_attr_rw = ['name_label',
'name_description',
@@ -671,6 +678,14 @@ class XendAPI(object):
del node.other_config[key]
node.save()
return xen_api_success_void()
def host_get_API_version_major(self, _, ref):
return xen_api_success(XEN_API_VERSION_MAJOR)
def host_get_API_version_minor(self, _, ref):
return xen_api_success(XEN_API_VERSION_MINOR)
def host_get_API_version_vendor(self, _, ref):
return xen_api_success(XEN_API_VERSION_VENDOR)
def host_get_API_version_vendor_implementation(self, _, ref):
return xen_api_success(XEN_API_VERSION_VENDOR_IMPLEMENTATION)
def host_get_software_version(self, session, host_ref):
return xen_api_success(XendNode.instance().xen_version())
def host_get_resident_VMs(self, session, host_ref):
@@ -707,7 +722,13 @@ class XendAPI(object):
record = {'uuid': node.uuid,
'name_label': node.name,
'name_description': '',
'API_version_major': XEN_API_VERSION_MAJOR,
'API_version_minor': XEN_API_VERSION_MINOR,
'API_version_vendor': XEN_API_VERSION_VENDOR,
'API_version_vendor_implemention':
XEN_API_VERSION_VENDOR_IMPLEMENTATION,
'software_version': node.xen_version(),
'other_config': node.other_config,
'resident_VMs': dom.get_domain_refs(),
'host_CPUs': node.get_host_cpu_refs(),
'metrics': node.host_metrics_uuid,
+22
View File
@@ -0,0 +1,22 @@
#============================================================================
# This library is free software; you can redistribute it and/or
# modify it under the terms of version 2.1 of the GNU Lesser General Public
# License as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#============================================================================
# Copyright (c) 2007 XenSource Inc.
#============================================================================
XEN_API_VERSION_MAJOR = 0
XEN_API_VERSION_MINOR = 5
XEN_API_VERSION_VENDOR = 'xenbits'
XEN_API_VERSION_VENDOR_IMPLEMENTATION = {}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.