本文整理汇总了Python中lib.cuckoo.core.database.Database.view_machine方法的典型用法代码示例。如果您正苦于以下问题:Python Database.view_machine方法的具体用法?Python Database.view_machine怎么用?Python Database.view_machine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.cuckoo.core.database.Database
的用法示例。
在下文中一共展示了Database.view_machine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import view_machine [as 别名]
def main():
parser = argparse.ArgumentParser()
parser.add_argument("vmname", type=str, help="Name of the Virtual Machine.")
parser.add_argument("--debug", action="store_true", help="Debug log in case of errors.")
parser.add_argument("--add", action="store_true", help="Add a Virtual Machine.")
parser.add_argument("--delete", action="store_true", help="Delete a Virtual Machine.")
parser.add_argument("--ip", type=str, help="Static IP Address.")
parser.add_argument("--platform", type=str, default="windows", help="Guest Operating System.")
parser.add_argument("--options", type=str, help="Machine options.")
parser.add_argument("--tags", type=str, help="Tags for this Virtual Machine.")
parser.add_argument("--interface", type=str, help="Sniffer interface for this machine.")
parser.add_argument("--snapshot", type=str, help="Specific Virtual Machine Snapshot to use.")
parser.add_argument("--resultserver", type=str, help="IP:Port of the Result Server.")
args = parser.parse_args()
logging.basicConfig()
log = logging.getLogger()
if args.debug:
log.setLevel(logging.DEBUG)
db = Database()
conf = Config()
if args.resultserver:
resultserver_ip, resultserver_port = args.resultserver.split(":")
else:
resultserver_ip = conf.resultserver.ip
resultserver_port = conf.resultserver.port
if args.add:
if db.view_machine(args.vmname):
sys.exit("A Virtual Machine with this name already exists!")
db.add_machine(
args.vmname,
args.vmname,
args.ip,
args.platform,
args.options,
args.tags,
args.interface,
args.snapshot,
resultserver_ip,
int(resultserver_port),
)
db.unlock_machine(args.vmname)
update_conf(conf.cuckoo.machinery, args, action="add")
if args.delete:
# TODO Add a db.del_machine() function for runtime modification.
update_conf(conf.cuckoo.machinery, args, action="delete")