diff --git a/ccserver/handlers.py b/ccserver/handlers.py index b7a74d995035c8fa6f9aeef658314644848a90d4..c97f291d58e1af78dbc80cd4289cb8465c69dddb 100644 --- a/ccserver/handlers.py +++ b/ccserver/handlers.py @@ -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 @@ -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) @@ -128,7 +130,11 @@ class ClientHandler(CCHandler): objects.append(vm_tags) # Filter the objects with the query, and return it: return query.filter(objects) - + + +class AuthenticationError(Exception): + pass + class WelcomeHandler(CCHandler): ''' @@ -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)') - role = self._server.conf.authentify(login, password) 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)