本文整理汇总了Python中lib.cuckoo.core.database.Database.add_remote_machinery方法的典型用法代码示例。如果您正苦于以下问题:Python Database.add_remote_machinery方法的具体用法?Python Database.add_remote_machinery怎么用?Python Database.add_remote_machinery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.cuckoo.core.database.Database
的用法示例。
在下文中一共展示了Database.add_remote_machinery方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Machinery
# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import add_remote_machinery [as 别名]
class Machinery(object):
"""Base abstract class for machinery modules."""
def __init__(self):
self.module_name = ""
self.options = None
self.options_globals = Config(os.path.join(CUCKOO_ROOT, "conf", "cuckoo.conf"))
# Database pointer.
self.db = Database()
# Machine table is cleaned to be filled from configuration file
# at each start.
self.db.clean_machines()
def set_options(self, options):
"""Set machine manager options.
@param options: machine manager options dict.
"""
self.options = options
def initialize(self, module_name):
"""Read, load, and verify machines configuration.
@param module_name: module name.
"""
# Load.
self._initialize(module_name)
# Run initialization checks.
self._initialize_check()
def _initialize(self, module_name):
"""Read configuration.
@param module_name: module name.
"""
self.module_name = module_name
mmanager_opts = self.options.get(module_name)
# Save Remote Machinery configuration
if mmanager_opts["remote"] == True :
try:
remote_product = mmanager_opts["remote_type"]
remote_ip = mmanager_opts["remote_host"]
remote_port = mmanager_opts["remote_port"]
remote_user = mmanager_opts["remote_user"] if mmanager_opts.has_key("remote_user") else ""
remote_password = mmanager_opts["remote_pass"] if mmanager_opts.has_key("remote_pass") else ""
remote_datastore = mmanager_opts["remote_datastore"] if mmanager_opts.has_key("remote_datastore") else ""
self.db.add_remote_machinery(name=module_name,
product=remote_product,
ip=remote_ip,
port=remote_port,
user=remote_user ,
password=remote_password,
datastore=remote_datastore)
except (AttributeError, CuckooOperationalError) as e:
log.warning("Configuration details about machinery %s "
"are missing: %s", module_name, e)
# Save Machines configuration
for machine_id in mmanager_opts["machines"].strip().split(","):
try:
machine_opts = self.options.get(machine_id.strip())
machine = Dictionary()
machine.id = machine_id.strip()
machine.label = machine_opts["label"]
machine.platform = machine_opts["platform"]
machine.tags = machine_opts.get("tags", None)
machine.ip = machine_opts["ip"]
# If configured, use specific network interface for this
# machine, else use the default value.
machine.interface = machine_opts.get("interface", None)
# If configured, use specific snapshot name, else leave it
# empty and use default behaviour.
machine.snapshot = machine_opts.get("snapshot", None)
# If configured, use specific resultserver IP and port,
# else use the default value.
opt_resultserver = self.options_globals.resultserver
ip = machine_opts.get("resultserver_ip", opt_resultserver.ip)
port = machine_opts.get("resultserver_port", opt_resultserver.port)
machine.resultserver_ip = ip
machine.resultserver_port = port
# Strip params.
for key in machine.keys():
if machine[key]:
# Only strip strings
if isinstance(machine[key], (str, unicode)):
machine[key] = machine[key].strip()
self.db.add_machine(name=machine.id,
label=machine.label,
ip=machine.ip,
platform=machine.platform,
tags=machine.tags,
interface=machine.interface,
snapshot=machine.snapshot,
resultserver_ip=ip,
#.........这里部分代码省略.........