Commit 172840f7 authored by Antoine Millet's avatar Antoine Millet
Browse files

Bootstrap client now have an host role.

parent 0a7cb4c4
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -111,13 +111,14 @@ class CCServer(object):
            if role is None or client.role == role:
                yield client

    def register(self, login, role, connection):
    def register(self, login, role, connection, create_object=False):
        '''
        Register a new connected account on the server.

        :param login: login of the account
        :param connection: connection to register
        :param tags: tags to add for the client
        :param create_object: create the object on objectdb
        '''

        if login in self._connected:
@@ -126,9 +127,8 @@ class CCServer(object):
        else:
            self._connected[login] = CCClient(login, role, self, connection)

        # If the registered role is bootstrap, we need to register the object
        # on objectdb because it have no account:
        if role == 'bootstrap':
        # Create the object on objectdb if required:
        if create_object:
            obj = TqlObject(id=login, r=role)
            logging.info('%s' % obj)
            self.objects.register(obj)
+6 −1
Original line number Diff line number Diff line
@@ -881,13 +881,18 @@ class WelcomeHandler(CCHandler):
                                conn.getpeername(), login)
                raise BadRoleError('%r is not a legal role' % role)
            
            create_object = False

            # If authentication is a success, try to register the client:
            if role == 'bootstrap':
                # Set a bootstrap id for the object:
                login = '%s.%s' % (login, conn.get_fd())
                # Real role of the node will be host:
                role = 'host'
                create_object = True

            try:
                self._server.register(login, role, conn)
                self._server.register(login, role, conn, create_object)
            except AlreadyRegistered:
                logging.warning(logmsg + 'already connected (%s)',
                                conn.getpeername(), login)