Loading ccserver/handlers.py +13 −4 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import inspect import logging from sjrpc.utils import RpcHandler, pure from tql import TqlQuery from conf import CCConf def listed(func): func.__listed__ = True Loading Loading @@ -104,8 +105,9 @@ class ClientHandler(CCHandler): # Try to get vm for each matched hypervisor: async_calls = {} tags = tuple(query.tags) for hy in hypervisors: async_calls[hy.connection.async_call('list_vm')] = hy async_calls[hy.connection.async_call('list_vm', tags=tags)] = hy logging.debug('Waiting for the response of hypervisors...') responses = self._server.manager.wait(frozenset(async_calls), timeout=5) Loading @@ -130,6 +132,10 @@ class ClientHandler(CCHandler): return query.filter(objects) class AuthenticationError(Exception): pass class WelcomeHandler(CCHandler): ''' Default handler used on client connections of the server. Loading @@ -147,11 +153,14 @@ class WelcomeHandler(CCHandler): ''' Authenticate the client. ''' try: role = self._server.conf.authentify(login, password) except CCConf.UnknownAccount: raise AuthenticationError('Authentication failure (Unknown login)') if role is None: logging.info('New authentication from %s: failure' % login) return False raise AuthenticationError('Authentication failure') else: # If authentication is a success, ask tags to the server: self._server.register(login, role, connection) Loading Loading
ccserver/handlers.py +13 −4 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import inspect import logging from sjrpc.utils import RpcHandler, pure from tql import TqlQuery from conf import CCConf def listed(func): func.__listed__ = True Loading Loading @@ -104,8 +105,9 @@ class ClientHandler(CCHandler): # Try to get vm for each matched hypervisor: async_calls = {} tags = tuple(query.tags) for hy in hypervisors: async_calls[hy.connection.async_call('list_vm')] = hy async_calls[hy.connection.async_call('list_vm', tags=tags)] = hy logging.debug('Waiting for the response of hypervisors...') responses = self._server.manager.wait(frozenset(async_calls), timeout=5) Loading @@ -130,6 +132,10 @@ class ClientHandler(CCHandler): return query.filter(objects) class AuthenticationError(Exception): pass class WelcomeHandler(CCHandler): ''' Default handler used on client connections of the server. Loading @@ -147,11 +153,14 @@ class WelcomeHandler(CCHandler): ''' Authenticate the client. ''' try: role = self._server.conf.authentify(login, password) except CCConf.UnknownAccount: raise AuthenticationError('Authentication failure (Unknown login)') if role is None: logging.info('New authentication from %s: failure' % login) return False raise AuthenticationError('Authentication failure') else: # If authentication is a success, ask tags to the server: self._server.register(login, role, connection) Loading