Commit 954621fc authored by Antoine Millet's avatar Antoine Millet
Browse files

Fixed bug in list method of client handler (now return only useful tags).

parent fdac7d95
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -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)
@@ -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.
@@ -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)