From 353746455579de2e782f180b70d66a666c3572e0 Mon Sep 17 00:00:00 2001 From: lixin Date: Mon, 13 Nov 2023 14:31:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96agent=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.py | 1 + views/server.py | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/index.py b/index.py index 6b3b3d7..2f5c946 100644 --- a/index.py +++ b/index.py @@ -35,6 +35,7 @@ mods = { 'check_environment':migration.check_environment, 'get_environment_data': server.get_environment_data, 'get_repo_arch_info': server.get_repo_arch_info, + 'get_storage_num': server.get_storage_num, } diff --git a/views/server.py b/views/server.py index 0a8eeed..369a750 100644 --- a/views/server.py +++ b/views/server.py @@ -322,4 +322,25 @@ def get_repo_arch_info(data): res = {} res['info'] = info_list json_res = json.dumps(res) - return json_res \ No newline at end of file + return json_res + + +def get_storage_num(data): + """ + 获取可用空间足够和不足数量 + :param data: + :return: + """ + success_num_sql = "select agent_ip from agent_info where agent_online_status='0' and agent_storage>='10' " \ + "and agent_migration_os is null;" + get_success_num = DBHelper().execute(success_num_sql).fetchall() + + faild_num_sql = "select agent_ip from agent_info where agent_online_status='0' and agent_storage<'10' " \ + "and agent_migration_os is null;" + get_faild_num = DBHelper().execute(faild_num_sql).fetchall() + + success = len(get_success_num) + faild = len(get_faild_num) + data = {'success': success, 'faild': faild} + json_data = json.dumps(data) + return json_data \ No newline at end of file -- 2.20.1