Skip to content
Snippets Groups Projects
Commit 057c7b65 authored by Antoine Millet's avatar Antoine Millet
Browse files

Implemented bootstrap role.

parent ea22fd8d
No related branches found
No related tags found
No related merge requests found
...@@ -126,6 +126,13 @@ class CCServer(object): ...@@ -126,6 +126,13 @@ class CCServer(object):
else: else:
self._connected[login] = CCClient(login, role, self, connection) 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':
obj = TqlObject(id=login, r=role)
logging.info('%s' % obj)
self.objects.register(obj)
def unregister(self, connection): def unregister(self, connection):
''' '''
Unregister an already connected account. Unregister an already connected account.
......
...@@ -825,6 +825,15 @@ class CliHandler(OnlineCCHandler): ...@@ -825,6 +825,15 @@ class CliHandler(OnlineCCHandler):
return client.connection.call(command, *args, **kwargs) return client.connection.call(command, *args, **kwargs)
class BootstrapHandler(OnlineCCHandler):
'''
Handler for bootstrap clients.
'''
pass
class WelcomeHandler(CCHandler): class WelcomeHandler(CCHandler):
''' '''
Default handler used on client connections of the server. Default handler used on client connections of the server.
...@@ -837,6 +846,7 @@ class WelcomeHandler(CCHandler): ...@@ -837,6 +846,7 @@ class WelcomeHandler(CCHandler):
'hv': HypervisorHandler, 'hv': HypervisorHandler,
'host': None, 'host': None,
'spv': SpvHandler, 'spv': SpvHandler,
'bootstrap': BootstrapHandler,
} }
@listed @listed
...@@ -874,14 +884,18 @@ class WelcomeHandler(CCHandler): ...@@ -874,14 +884,18 @@ class WelcomeHandler(CCHandler):
raise BadRoleError('%r is not a legal role' % role) raise BadRoleError('%r is not a legal role' % role)
# If authentication is a success, try to register the client: # 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())
try: try:
self._server.register(login, role, conn) self._server.register(login, role, conn)
except AlreadyRegistered: except AlreadyRegistered:
logging.warning(logmsg + 'already connected (%s)', logging.warning(logmsg + 'already connected (%s)',
conn.getpeername(), login) conn.getpeername(), login)
raise AuthenticationError('Already connected') raise AuthenticationError('Already connected')
conn.set_handler(WelcomeHandler.ROLES.get(role)(self._server))
conn.set_handler(WelcomeHandler.ROLES.get(role)(self._server))
logging.info('Authentication success from %s with login %s', logging.info('Authentication success from %s with login %s',
conn.getpeername(), login) conn.getpeername(), login)
return role return role
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment