mirror of https://github.com/veops/cmdb.git
fix: discover scripts (#458)
Co-authored-by: wang-liang0615 <dhuwl0615@163.com>
This commit is contained in:
parent
d08827d086
commit
4232094aed
|
@ -419,51 +419,51 @@ const cmdb_en = {
|
||||||
updateFields: 'Update Field',
|
updateFields: 'Update Field',
|
||||||
pluginScript: `# -*- coding:utf-8 -*-
|
pluginScript: `# -*- coding:utf-8 -*-
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
class AutoDiscovery(object):
|
class AutoDiscovery(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_key(self):
|
def unique_key(self):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
:return: Returns the name of a unique attribute
|
:return: Returns the name of a unique attribute
|
||||||
"""
|
"""
|
||||||
return
|
return
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def attributes():
|
def attributes():
|
||||||
"""
|
"""
|
||||||
Define attribute fields
|
Define attribute fields
|
||||||
:return: Returns a list of attribute fields. The list items are (name, type, description). The name must be in English.
|
: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
|
type: String Integer Float Date DateTime Time JSON
|
||||||
For example:
|
For example:
|
||||||
return [
|
return [
|
||||||
("ci_type", "String", "CIType name"),
|
("ci_type", "String", "CIType name"),
|
||||||
("private_ip", "String", "Internal IP, multiple values separated by commas")
|
("private_ip", "String", "Internal IP, multiple values separated by commas")
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def run():
|
def run():
|
||||||
"""
|
"""
|
||||||
Execution entry, returns collected attribute values
|
Execution entry, returns collected attribute values
|
||||||
:return:
|
:return:
|
||||||
Returns a list, the list item is a dictionary, the dictionary key is the attribute name, and the value is the attribute value
|
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:
|
For example:
|
||||||
return [dict(ci_type="server", private_ip="192.168.1.1")]
|
return [dict(ci_type="server", private_ip="192.168.1.1")]
|
||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
result = AutoDiscovery().run()
|
result = AutoDiscovery().run()
|
||||||
if isinstance(result, list):
|
if isinstance(result, list):
|
||||||
print("AutoDiscovery::Result::{}".format(json.dumps(result)))
|
print("AutoDiscovery::Result::{}".format(json.dumps(result)))
|
||||||
else:
|
else:
|
||||||
print("ERROR: The collection return must be a list")
|
print("ERROR: The collection return must be a list")
|
||||||
`,
|
`,
|
||||||
server: 'Server',
|
server: 'Server',
|
||||||
vserver: 'VServer',
|
vserver: 'VServer',
|
||||||
|
|
|
@ -419,50 +419,51 @@ const cmdb_zh = {
|
||||||
updateFields: '更新字段',
|
updateFields: '更新字段',
|
||||||
pluginScript: `# -*- coding:utf-8 -*-
|
pluginScript: `# -*- coding:utf-8 -*-
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
class AutoDiscovery(object):
|
class AutoDiscovery(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_key(self):
|
def unique_key(self):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
:return: 返回唯一属性的名字
|
:return: Returns the name of a unique attribute
|
||||||
"""
|
"""
|
||||||
return
|
return
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def attributes():
|
def attributes():
|
||||||
"""
|
"""
|
||||||
定义属性字段
|
Define attribute fields
|
||||||
:return: 返回属性字段列表, 列表项是(名称, 类型, 描述), 名称必须是英文
|
:return: Returns a list of attribute fields. The list items are (name, type, description). The name must be in English.
|
||||||
类型: String Integer Float Date DateTime Time JSON
|
type: String Integer Float Date DateTime Time JSON
|
||||||
例如:
|
For example:
|
||||||
return [
|
return [
|
||||||
("ci_type", "String", "模型名称"),
|
("ci_type", "String", "CIType name"),
|
||||||
("private_ip", "String", "内网IP, 多值逗号分隔")
|
("private_ip", "String", "Internal IP, multiple values separated by commas")
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def run():
|
def run():
|
||||||
"""
|
"""
|
||||||
执行入口, 返回采集的属性值
|
Execution entry, returns collected attribute values
|
||||||
:return: 返回一个列表, 列表项是字典, 字典key是属性名称, value是属性值
|
:return:
|
||||||
例如:
|
Returns a list, the list item is a dictionary, the dictionary key is the attribute name, and the value is the attribute value
|
||||||
return [dict(ci_type="server", private_ip="192.168.1.1")]
|
For example:
|
||||||
"""
|
return [dict(ci_type="server", private_ip="192.168.1.1")]
|
||||||
return []
|
"""
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
result = AutoDiscovery().run()
|
result = AutoDiscovery().run()
|
||||||
if isinstance(result, list):
|
if isinstance(result, list):
|
||||||
print("AutoDiscovery::Result::{}".format(json.dumps(result)))
|
print("AutoDiscovery::Result::{}".format(json.dumps(result)))
|
||||||
else:
|
else:
|
||||||
print("ERROR: 采集返回必须是列表")
|
print("ERROR: The collection return must be a list")
|
||||||
`,
|
`,
|
||||||
server: '物理机',
|
server: '物理机',
|
||||||
vserver: '虚拟机',
|
vserver: '虚拟机',
|
||||||
|
|
Loading…
Reference in New Issue