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(