diff --git a/virtualization/univention-virtual-machine-manager-daemon/umc/python/uvmm/__init__.py b/virtualization/univention-virtual-machine-manager-daemon/umc/python/uvmm/__init__.py index 0bc0b5a..785df1b 100644 --- a/virtualization/univention-virtual-machine-manager-daemon/umc/python/uvmm/__init__.py +++ b/virtualization/univention-virtual-machine-manager-daemon/umc/python/uvmm/__init__.py @@ -73,10 +73,7 @@ def _check_thread_error(self, thread, result, request): if not isinstance(result, BaseException): return False - def fake_func(self, request): - raise thread.exc_info[0], thread.exc_info[1], thread.exc_info[2] - fake_func.__name__ = 'thread %s' % (request.arguments[0],) - error_handling(fake_func)(self, request) + self.thread_finished_callback(thread, result, request) return True def _thread_finish(self, thread, result, request): diff --git a/virtualization/univention-virtual-machine-manager-daemon/umc/python/uvmm/nodes.py b/virtualization/univention-virtual-machine-manager-daemon/umc/python/uvmm/nodes.py index 6f9e2ef..4d76f2e 100644 --- a/virtualization/univention-virtual-machine-manager-daemon/umc/python/uvmm/nodes.py +++ b/virtualization/univention-virtual-machine-manager-daemon/umc/python/uvmm/nodes.py @@ -46,16 +46,6 @@ class Nodes(object): UMC functions for UVMM node handling. """ - def _node_thread_finished(self, thread, result, request, parent): - """ - This method is invoked when a threaded request for the - navigation is finished. The result is send back to the - client. If the result is an instance of BaseException an error - is returned. - """ - if self._check_thread_error(thread, result, request): - return - @sanitize(nodePattern=SearchSanitizer(default='*')) def node_query(self, request): """ diff --git a/virtualization/univention-virtual-machine-manager-daemon/umc/python/uvmm/profiles.py b/virtualization/univention-virtual-machine-manager-daemon/umc/python/uvmm/profiles.py index dd34540..4bfdf74 100644 --- a/virtualization/univention-virtual-machine-manager-daemon/umc/python/uvmm/profiles.py +++ b/virtualization/univention-virtual-machine-manager-daemon/umc/python/uvmm/profiles.py @@ -38,11 +38,11 @@ from univention.management.console.log import MODULE from univention.management.console.protocol.definitions import MODULE_ERR_COMMAND_FAILED +from univention.management.console.ldap import machine_connection from urlparse import urlsplit from notifier import Callback -from .udm import LDAP_Connection from .tools import object2dict _ = Translation('univention-management-console-modules-uvmm').translate @@ -72,25 +72,26 @@ class Profiles(object): 'kvm-hvm': _('Full virtualization (KVM)'), } - @LDAP_Connection + @machine_connection(write=False) def read_profiles(self, ldap_connection=None, ldap_position=None): """ Read all profiles from LDAP. """ base = "%s,%s" % (Profiles.PROFILE_RDN, ldap_position.getDn()) - try: - res = uvmm_profile.lookup( - None, - ldap_connection, - '', - base=base, - scope='sub', - required=False, - unique=False - ) - except udm_error as ex: - MODULE.error("Failed to read profiles: %s" % (ex,)) - res = () + res = () + if ldap_connection is not None: + try: + res = uvmm_profile.lookup( + None, + ldap_connection, + '', + base=base, + scope='sub', + required=False, + unique=False + ) + except udm_error as exc: + MODULE.error("Failed to read profiles: %s" % (exc,)) self.profiles = [(obj.dn, Profile(obj.info)) for obj in res] def _filter_profiles(self, node_pd): diff --git a/virtualization/univention-virtual-machine-manager-daemon/umc/python/uvmm/udm.py b/virtualization/univention-virtual-machine-manager-daemon/umc/python/uvmm/udm.py deleted file mode 100644 index 72ebae3..0000000 --- a/virtualization/univention-virtual-machine-manager-daemon/umc/python/uvmm/udm.py +++ /dev/null @@ -1,93 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Univention Management Console -# module: management of virtualization servers -# -# Copyright 2010-2015 Univention GmbH -# -# http://www.univention.de/ -# -# All rights reserved. -# -# The source code of this program is made available -# under the terms of the GNU Affero General Public License version 3 -# (GNU AGPL V3) as published by the Free Software Foundation. -# -# Binary versions of this program provided by Univention to you as -# well as other copyrighted, protected or trademarked materials like -# Logos, graphics, fonts, specific documentations and configurations, -# cryptographic keys etc. are subject to a license agreement between -# you and Univention and not subject to the GNU AGPL V3. -# -# In the case you use this program under the terms of the GNU AGPL V3, -# the program is provided 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public -# License with the Debian GNU/Linux or Univention distribution in file -# /usr/share/common-licenses/AGPL-3; if not, see -# . - -import univention.admin.uldap as udm_uldap -import univention.admin.uexceptions as udm_errors - -from ldap import LDAPError - -# decorator for LDAP connections -_ldap_connection = None -_ldap_position = None - - -class LDAP_ConnectionError(Exception): - """ - Error connecting LDAP server. - """ - pass - - -def LDAP_Connection(func): - """ - This decorator function provides an open LDAP connection that can - be accessed via the variable ldap_connection and a vaild position - within the LDAP directory in the variable ldap_position. It reuses - an already open connection or creates a new one. If the function - fails with an LDAP error the decorators tries to reopen the LDAP - connection and invokes the function again. if it still fails an - LDAP_ConnectionError is raised. - - When using the decorator the method gets two additional keyword arguments. - - example: - @LDAP_Connection - def do_ldap_stuff(arg1, arg2, ldap_connection=None, ldap_positio=None): - ... - ldap_connection.searchDn(..., position=ldap_position) - ... - """ - def wrapper_func(*args, **kwargs): - global _ldap_connection, _ldap_position - - if _ldap_connection is not None: - lo = _ldap_connection - po = _ldap_position - else: - try: - lo, po = udm_uldap.getMachineConnection(ldap_master=False) - except LDAPError, ex: - raise LDAP_ConnectionError('Opening LDAP connection failed: %s' % (ex,)) - - kwargs['ldap_connection'] = lo - kwargs['ldap_position'] = po - try: - ret = func(*args, **kwargs) - _ldap_connection = lo - _ldap_position = po - return ret - except udm_errors.base as ex: - raise LDAP_ConnectionError(str(ex)) - - return [] - - return wrapper_func