def agent_add():
payload = request.get_json()
for agent in payload['agents']:
host = ip(agent['host'])
port = agent['port']
try:
res = remote.ping(host, port)
if res['status'] != 0:
abort(406, '{}:{} ?? agent ??'.format(host, port))
except requests.ConnectionError:
abort(500, '{}:{} Connection error'.format(host, port))
try:
Agent.add(host, port)
except sqlalchemy.exc.SQLAlchemyError:
abort(500, '{}:{} ????'.format(host, port))
return jsonify(status=0)
评论列表
文章目录