From 8b540e6dbe61c6d287db52592c76abe977ee0b9f Mon Sep 17 00:00:00 2001 From: iSecloud <869820505@qq.com> Date: Mon, 15 Nov 2021 16:36:44 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E6=94=BE=E5=BC=80=E5=AF=B9=E4=BA=8E?= =?UTF-8?q?AIX=E6=93=8D=E4=BD=9C=E7=B3=BB=E7=BB=9F=E4=B8=BB=E6=9C=BA?= =?UTF-8?q?=E7=9A=84=E5=AE=89=E8=A3=85=E9=99=90=E5=88=B6(close=20#230)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/node_man/handlers/meta.py | 16 +++++++++++++++- apps/node_man/tests/test_meta.py | 7 +------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/apps/node_man/handlers/meta.py b/apps/node_man/handlers/meta.py index a355f2bc4..411447f8a 100644 --- a/apps/node_man/handlers/meta.py +++ b/apps/node_man/handlers/meta.py @@ -145,7 +145,7 @@ def fetch_host_condition(self): for index, item in enumerate(sublist): col_map[index].add(item) - os_types_children = [{"name": constants.OS_CHN.get(os, os), "id": os} for os in os_types if os != ""] + os_types_children = self.fetch_os_type(os_types) statuses_children = [ {"name": constants.PROC_STATUS_CHN.get(status, status), "id": status} for status in statuses if status != "" ] @@ -437,6 +437,17 @@ def fetch_plugin_version_condition(): return plugin_result + @staticmethod + def fetch_os_type(os_types=constants.OsType): + os_types_children = [] + for os_type in os_types: + if os_type == "": + continue + os_types_children.append( + {"id": os_type, "name": os_type if os_type == constants.OsType.AIX else os_type.capitalize()} + ) + return os_types_children + def filter_condition(self, category): """ 获取过滤条件 @@ -460,6 +471,9 @@ def filter_condition(self, category): elif category == "plugin_host": ret = self.fetch_plugin_host_condition() return ret + elif category == "os_type": + ret = self.fetch_os_type() + return ret def search(self, key): """ diff --git a/apps/node_man/tests/test_meta.py b/apps/node_man/tests/test_meta.py index 14cd017f4..c6312aa79 100644 --- a/apps/node_man/tests/test_meta.py +++ b/apps/node_man/tests/test_meta.py @@ -194,12 +194,7 @@ def test_fetch_plugin_list_condition_no_permission(self, *args, **kwargs): { "name": "操作系统", "id": "os_type", - "children": [ - {"id": "LINUX", "name": "Linux"}, - {"id": "WINDOWS", "name": "Windows"}, - {"id": "AIX", "name": "AIX"}, - {"id": "SOLARIS", "name": "Solaris"}, - ], + "children": MetaHandler.fetch_os_type(), }, ) self.assertEqual(