Commit 057c7b65 authored by Antoine Millet's avatar Antoine Millet

Implemented bootstrap role.

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