cherrypy.session.regenerate()
cherrypy.session[Auth.SESSION_KEY] = username
cherrypy.session[Auth.SESSION_KEY_TS] = now
- self._log.debug("Login successful")
+ self._log.debug('Login successful')
return {'username': username}
cherrypy.response.status = 403
- self._log.debug("Login fail")
+ self._log.debug('Login failed')
return {'detail': 'Invalid credentials'}
def bulk_delete(self):
- self._log.debug("Logout successful")
+ self._log.debug('Logout successful')
cherrypy.session[Auth.SESSION_KEY] = None
cherrypy.session[Auth.SESSION_KEY_TS] = None
if username_ts and float(username_ts) < (now - expires):
cherrypy.session[Auth.SESSION_KEY] = None
cherrypy.session[Auth.SESSION_KEY_TS] = None
- module.log.debug("Session expired.")
+ module.log.debug('Session expired')
raise cherrypy.HTTPError(401,
'Session expired. You are not '
'authorized to access that resource')
COMMANDS = [
{
- "cmd": "dashboard set-login-credentials "
- "name=username,type=CephString "
- "name=password,type=CephString",
- "desc": "Set the login credentials",
- "perm": "w"
+ 'cmd': 'dashboard set-login-credentials '
+ 'name=username,type=CephString '
+ 'name=password,type=CephString',
+ 'desc': 'Set the login credentials',
+ 'perm': 'w'
}
]
'no server_addr configured; '
'try "ceph config-key put mgr/{}/{}/server_addr <ip>"'
.format(self.module_name, self.get_mgr_id()))
- self.log.info("server_addr: %s server_port: %s", server_addr,
+ self.log.info('server_addr: %s server_port: %s', server_addr,
server_port)
if not in_unittest:
'server.socket_host': server_addr,
'server.socket_port': int(server_port),
})
- cherrypy.tools.autenticate = cherrypy.Tool('before_handler',
- Auth.check_auth)
+ cherrypy.tools.authenticate = cherrypy.Tool('before_handler',
+ Auth.check_auth)
current_dir = os.path.dirname(os.path.abspath(__file__))
fe_dir = os.path.join(current_dir, 'frontend/dist')
config = {
'/': {
- "tools.staticdir.on": True,
+ 'tools.staticdir.on': True,
'tools.staticdir.dir': fe_dir,
- 'tools.staticdir.index': "index.html"
+ 'tools.staticdir.index': 'index.html'
}
}
- cherrypy.tree.mount(Module.ApiRoot(self), "/api")
+ cherrypy.tree.mount(Module.ApiRoot(self), '/api')
cherrypy.tree.mount(Module.StaticRoot(), '/', config=config)
def serve(self):
self.configure_cherrypy()
cherrypy.engine.start()
- self.log.info("Waiting for engine...")
+ self.log.info('Waiting for engine...')
cherrypy.engine.block()
- self.log.info("Engine done.")
+ self.log.info('Engine done')
def shutdown(self):
- self.log.info("Stopping server...")
+ self.log.info('Stopping server...')
cherrypy.engine.exit()
- self.log.info("Stopped server")
+ self.log.info('Stopped server')
def handle_command(self, cmd):
if cmd['prefix'] == 'dashboard set-login-credentials':
class ApiRoot(object):
def __init__(self, mgrmod):
ctrls = load_controllers(mgrmod)
- mgrmod.log.debug("loaded controllers: {}".format(ctrls))
+ mgrmod.log.debug('Loaded controllers: {}'.format(ctrls))
for ctrl in ctrls:
- mgrmod.log.info("adding controller: {} -> /api/{}"
+ mgrmod.log.info('Adding controller: {} -> /api/{}'
.format(ctrl.__name__, ctrl._cp_path_))
ins = ctrl()
setattr(Module.ApiRoot, ctrl._cp_path_, ins)
class AuthTest(ControllerTestCase):
@classmethod
def setup_test(cls):
- cherrypy.tools.autenticate = cherrypy.Tool('before_handler',
+ cherrypy.tools.authenticate = cherrypy.Tool('before_handler',
Auth.check_auth)
cherrypy.tree.mount(Ping(), "/api/test",
- config={'/': {'tools.autenticate.on': True}})
+ config={'/': {'tools.authenticate.on': True}})
cls._mgr_module.set_localized_config('session-expire', '2')
cls._mgr_module.set_localized_config('username', 'admin')
cls._mgr_module.set_localized_config('password',
if not hasattr(cls, '_cp_config'):
cls._cp_config = {
'tools.sessions.on': True,
- 'tools.autenticate.on': False
+ 'tools.authenticate.on': False
}
else:
cls._cp_config['tools.sessions.on'] = True
- if 'tools.autenticate.on' not in cls._cp_config:
- cls._cp_config['tools.autenticate.on'] = False
+ if 'tools.authenticate.on' not in cls._cp_config:
+ cls._cp_config['tools.authenticate.on'] = False
return cls
return decorate
def decorate(cls):
if not hasattr(cls, '_cp_config'):
cls._cp_config = {
- 'tools.autenticate.on': enabled
+ 'tools.authenticate.on': enabled
}
else:
- cls._cp_config['tools.autenticate.on'] = enabled
+ cls._cp_config['tools.authenticate.on'] = enabled
return cls
return decorate
sys.path.append(mgr_dir)
controllers = []
- ctrls_path = "{}/controllers".format(dashboard_dir)
+ ctrls_path = '{}/controllers'.format(dashboard_dir)
mods = [mod for _, mod, _ in pkgutil.iter_modules([ctrls_path])]
for mod_name in mods:
mod = importlib.import_module('.controllers.{}'.format(mod_name),