From 33e58a658b7b837a2d5b9e583ab80bf6aafb78a1 Mon Sep 17 00:00:00 2001 From: ivonGwy Date: Fri, 29 Mar 2024 15:48:46 +0800 Subject: [PATCH] fix: discover scripts (#458) Co-authored-by: wang-liang0615 --- cmdb-ui/src/modules/cmdb/lang/en.js | 74 ++++++++++++++--------------- cmdb-ui/src/modules/cmdb/lang/zh.js | 73 ++++++++++++++-------------- 2 files changed, 74 insertions(+), 73 deletions(-) diff --git a/cmdb-ui/src/modules/cmdb/lang/en.js b/cmdb-ui/src/modules/cmdb/lang/en.js index 6aa4dac..ad39212 100644 --- a/cmdb-ui/src/modules/cmdb/lang/en.js +++ b/cmdb-ui/src/modules/cmdb/lang/en.js @@ -419,51 +419,51 @@ const cmdb_en = { updateFields: 'Update Field', pluginScript: `# -*- coding:utf-8 -*- - import json +import json - class AutoDiscovery(object): +class AutoDiscovery(object): - @property - def unique_key(self): - """ + @property + def unique_key(self): + """ - :return: Returns the name of a unique attribute - """ - return + :return: Returns the name of a unique attribute + """ + return - @staticmethod - def attributes(): - """ - Define attribute fields - :return: Returns a list of attribute fields. The list items are (name, type, description). The name must be in English. - type: String Integer Float Date DateTime Time JSON - For example: - return [ - ("ci_type", "String", "CIType name"), - ("private_ip", "String", "Internal IP, multiple values separated by commas") - ] - """ - return [] + @staticmethod + def attributes(): + """ + Define attribute fields + :return: Returns a list of attribute fields. The list items are (name, type, description). The name must be in English. + type: String Integer Float Date DateTime Time JSON + For example: + return [ + ("ci_type", "String", "CIType name"), + ("private_ip", "String", "Internal IP, multiple values separated by commas") + ] + """ + return [] - @staticmethod - def run(): - """ - Execution entry, returns collected attribute values - :return: - Returns a list, the list item is a dictionary, the dictionary key is the attribute name, and the value is the attribute value - For example: - return [dict(ci_type="server", private_ip="192.168.1.1")] - """ - return [] + @staticmethod + def run(): + """ + Execution entry, returns collected attribute values + :return: + Returns a list, the list item is a dictionary, the dictionary key is the attribute name, and the value is the attribute value + For example: + return [dict(ci_type="server", private_ip="192.168.1.1")] + """ + return [] - if __name__ == "__main__": - result = AutoDiscovery().run() - if isinstance(result, list): - print("AutoDiscovery::Result::{}".format(json.dumps(result))) - else: - print("ERROR: The collection return must be a list") +if __name__ == "__main__": + result = AutoDiscovery().run() + if isinstance(result, list): + print("AutoDiscovery::Result::{}".format(json.dumps(result))) + else: + print("ERROR: The collection return must be a list") `, server: 'Server', vserver: 'VServer', diff --git a/cmdb-ui/src/modules/cmdb/lang/zh.js b/cmdb-ui/src/modules/cmdb/lang/zh.js index 3960c11..016346a 100644 --- a/cmdb-ui/src/modules/cmdb/lang/zh.js +++ b/cmdb-ui/src/modules/cmdb/lang/zh.js @@ -419,50 +419,51 @@ const cmdb_zh = { updateFields: '更新字段', pluginScript: `# -*- coding:utf-8 -*- - import json +import json - class AutoDiscovery(object): +class AutoDiscovery(object): - @property - def unique_key(self): - """ + @property + def unique_key(self): + """ - :return: 返回唯一属性的名字 - """ - return + :return: Returns the name of a unique attribute + """ + return - @staticmethod - def attributes(): - """ - 定义属性字段 - :return: 返回属性字段列表, 列表项是(名称, 类型, 描述), 名称必须是英文 - 类型: String Integer Float Date DateTime Time JSON - 例如: - return [ - ("ci_type", "String", "模型名称"), - ("private_ip", "String", "内网IP, 多值逗号分隔") - ] - """ - return [] + @staticmethod + def attributes(): + """ + Define attribute fields + :return: Returns a list of attribute fields. The list items are (name, type, description). The name must be in English. + type: String Integer Float Date DateTime Time JSON + For example: + return [ + ("ci_type", "String", "CIType name"), + ("private_ip", "String", "Internal IP, multiple values separated by commas") + ] + """ + return [] - @staticmethod - def run(): - """ - 执行入口, 返回采集的属性值 - :return: 返回一个列表, 列表项是字典, 字典key是属性名称, value是属性值 - 例如: - return [dict(ci_type="server", private_ip="192.168.1.1")] - """ - return [] + @staticmethod + def run(): + """ + Execution entry, returns collected attribute values + :return: + Returns a list, the list item is a dictionary, the dictionary key is the attribute name, and the value is the attribute value + For example: + return [dict(ci_type="server", private_ip="192.168.1.1")] + """ + return [] - if __name__ == "__main__": - result = AutoDiscovery().run() - if isinstance(result, list): - print("AutoDiscovery::Result::{}".format(json.dumps(result))) - else: - print("ERROR: 采集返回必须是列表") +if __name__ == "__main__": + result = AutoDiscovery().run() + if isinstance(result, list): + print("AutoDiscovery::Result::{}".format(json.dumps(result))) + else: + print("ERROR: The collection return must be a list") `, server: '物理机', vserver: '虚拟机',