当前位置: 首页>>代码示例>>Python>>正文


Python Database.view_experiment方法代码示例

本文整理汇总了Python中lib.cuckoo.core.database.Database.view_experiment方法的典型用法代码示例。如果您正苦于以下问题:Python Database.view_experiment方法的具体用法?Python Database.view_experiment怎么用?Python Database.view_experiment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib.cuckoo.core.database.Database的用法示例。


在下文中一共展示了Database.view_experiment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Machinery

# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import view_experiment [as 别名]
class Machinery(object):
    """Base abstract class for machinery modules."""

    # Default label used in machinery configuration file to supply virtual
    # machine name/label/vmx path. Override it if you dubbed it in another
    # way.
    LABEL = "label"

    def __init__(self):
        self.module_name = ""
        self.options = None
        self.options_globals = Config()
        # 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)

        for name in mmanager_opts["machines"].split(","):
            if not name.strip():
                continue

            try:
                options = self.options.get(name.strip())
                machine = Dictionary()
                machine.name = name.strip()
                machine.label = options[self.LABEL]
                machine.platform = options["platform"]
                machine.tags = options.get("tags")
                machine.ip = options["ip"]

                # If configured, use specific network interface for this
                # machine, else use the default value.
                machine.interface = options.get("interface")

                # If configured, use specific snapshot name, else leave it
                # empty and use default behaviour.
                machine.snapshot = options.get("snapshot")

                machine.rdp_port = options.get("rdp_port", "")

                # If configured, use specific resultserver IP and port,
                # else use the default value.
                opt_resultserver = self.options_globals.resultserver

                if "resultserver_ip" in options and "resultserver_port" in options:
                    machine.resultserver_ip = options["resultserver_ip"]
                    machine.resultserver_port = options["resultserver_port"]
                else:
                    machine.resultserver_ip = opt_resultserver.ip
                    machine.resultserver_port = opt_resultserver.port

                # Strip parameters.
                for key, value in machine.items():
                    if value and isinstance(value, basestring):
                        machine[key] = value.strip()

                experiment = self.db.view_experiment(machine_name=machine.name)
                if experiment is not None:
                    machine.locked_by = experiment.id
                else:
                    machine.locked_by = None

                self.db.add_machine(name=machine.name,
                                    label=machine.label,
                                    ip=machine.ip,
                                    platform=machine.platform,
                                    tags=machine.tags,
                                    interface=machine.interface,
                                    snapshot=machine.snapshot,
                                    resultserver_ip=machine.resultserver_ip,
                                    resultserver_port=machine.resultserver_port,
                                    rdp_port=machine.rdp_port,
                                    locked_by=machine.locked_by)
            except (AttributeError, CuckooOperationalError) as e:
                log.warning("Configuration details about machine %s "
#.........这里部分代码省略.........
开发者ID:jbremer,项目名称:longcuckoo,代码行数:103,代码来源:abstracts.py


注:本文中的lib.cuckoo.core.database.Database.view_experiment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。