From d99a78a973b264280272bac87590870d598d7541 Mon Sep 17 00:00:00 2001 From: lixin Date: Fri, 10 Nov 2023 17:42:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=BD=AF=E4=BB=B6=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E6=A3=80=E6=B5=8B=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- views/server.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/views/server.py b/views/server.py index 71cbb8e..b13d908 100644 --- a/views/server.py +++ b/views/server.py @@ -211,4 +211,57 @@ def get_kernel_data(data): res['num'] = len(info_list) json_res = json.dumps(res) - return json_res \ No newline at end of file + return json_res + + +def get_repo_data(data): + """ + 定时检查软件仓库检测结果 + :return: + """ + task_status_sql = "select agent_id from agent_task where task_status=2" + get_task_status = DBHelper().execute(task_status_sql).fetchall() + if len(get_task_status) == 0: + data = {"centos7_x86": "", "centos8_x86": "", "centos7_aarch64": "", "centos8_aarch64": ""} + json_data = json.dumps(data) + return json_data + else: + centos7_x86_sql = "select agent_ip from agent_info where (agent_os='centos7' or agent_os='redhat7') " \ + "and agent_arch='x86_64' and repo_status=1;" + + centos8_x86_sql = "select agent_ip from agent_info where (agent_os='centos8' or agent_os='redhat8') " \ + "and agent_arch='x86_64' and repo_status=1;" + + centos7_aarch64_sql = "select agent_ip from agent_info where (agent_os='centos7' or agent_os='redhat7') " \ + "and agent_arch='aarch64' and repo_status=1;" + + centos8_aarch64_sql = "select agent_ip from agent_info where (agent_os='centos8' or agent_os='redhat8') " \ + "and agent_arch='aarch64' and repo_status=1;" + + data = {} + get_centos7_x86_status = DBHelper().execute(centos7_x86_sql).fetchall() + if len(get_centos7_x86_status) == 0: + data['centos7_x86'] = 'success' + else: + data['centos7_x86'] = 'faild' + + get_centos8_x86_status = DBHelper().execute(centos8_x86_sql).fetchall() + if len(get_centos8_x86_status) == 0: + data['centos8_x86'] = 'success' + else: + data['centos8_x86'] = 'faild' + + get_centos7_aarch64_status = DBHelper().execute(centos7_aarch64_sql).fetchall() + if len(get_centos7_aarch64_status) == 0: + data['centos7_aarch64'] = 'success' + else: + data['centos7_aarch64'] = 'faild' + + get_centos8_aarch64_status = DBHelper().execute(centos8_aarch64_sql).fetchall() + if len(get_centos8_aarch64_status) == 0: + data['centos8_aarch64'] = 'success' + else: + data['centos8_aarch64'] = 'faild' + + json_data = json.dumps(data) + return json_data \ No newline at end of file -- 2.20.1