Loading ccserver/exceptions.py +3 −0 Original line number Diff line number Diff line Loading @@ -24,3 +24,6 @@ class NotConnectedAccountError(Exception): class ReservedTagError(Exception): pass class BadRoleError(Exception): pass ccserver/handlers.py +9 −2 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ import logging from sjrpc.utils import RpcHandler, pure from conf import CCConf from exceptions import (AlreadyRegistered, AuthenticationError, RightError, ReservedTagError, BadObjectError, ReservedTagError, BadObjectError, BadRoleError, NotConnectedAccountError) def listed(func): Loading Loading @@ -196,7 +196,10 @@ class CliHandler(OnlineCCHandler): ''' Create a new account with specified login. ''' if role in WelcomeHandler.ROLES: self._server.conf.create_account(login, role, password) else: raise BadRoleError('%r is not a legal role.' % role) @listed def addtag(self, conn, query, tag_name, tag_value): Loading Loading @@ -452,6 +455,7 @@ class WelcomeHandler(CCHandler): ROLES = { 'cli': CliHandler, 'hv': HypervisorHandler, 'host': None, } @listed Loading @@ -469,6 +473,9 @@ class WelcomeHandler(CCHandler): if 'close' in self._server.conf.show(login)['tags']: raise AuthenticationError('Account is closed') if role not in WelcomeHandler.ROLES: raise BadRoleError('%r is not a legal role' % role) if role is None: logging.info('New authentication from %s: failure', login.encode('ascii', 'ignore')) Loading Loading
ccserver/exceptions.py +3 −0 Original line number Diff line number Diff line Loading @@ -24,3 +24,6 @@ class NotConnectedAccountError(Exception): class ReservedTagError(Exception): pass class BadRoleError(Exception): pass
ccserver/handlers.py +9 −2 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ import logging from sjrpc.utils import RpcHandler, pure from conf import CCConf from exceptions import (AlreadyRegistered, AuthenticationError, RightError, ReservedTagError, BadObjectError, ReservedTagError, BadObjectError, BadRoleError, NotConnectedAccountError) def listed(func): Loading Loading @@ -196,7 +196,10 @@ class CliHandler(OnlineCCHandler): ''' Create a new account with specified login. ''' if role in WelcomeHandler.ROLES: self._server.conf.create_account(login, role, password) else: raise BadRoleError('%r is not a legal role.' % role) @listed def addtag(self, conn, query, tag_name, tag_value): Loading Loading @@ -452,6 +455,7 @@ class WelcomeHandler(CCHandler): ROLES = { 'cli': CliHandler, 'hv': HypervisorHandler, 'host': None, } @listed Loading @@ -469,6 +473,9 @@ class WelcomeHandler(CCHandler): if 'close' in self._server.conf.show(login)['tags']: raise AuthenticationError('Account is closed') if role not in WelcomeHandler.ROLES: raise BadRoleError('%r is not a legal role' % role) if role is None: logging.info('New authentication from %s: failure', login.encode('ascii', 'ignore')) Loading