Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@bp.route_post_json('/add', True)
def add_redis():
host = request.form['host']
port = int(request.form['port'])
# do some necessary validation
status = 0
reason = 'success'
try:
with Connection(host, port) as t:
try:
info = t.talk("info")
info_dict = parse_config(info)
if info_dict['cluster_enabled'] == '0':
status = 3
reason = 'not in cluster mode'
except ReplyError as e:
reason = e.message
status = 2
except IOError, e:
status = 1
reason = e.message
if status == 0:
models.node.create_instance(host, port)
models.audit.raw_event(host, port, models.audit.EVENT_TYPE_CREATE,
bp.app.get_user_id())
return {'reason': reason, 'status': status}