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


Python Host.addChild方法代码示例

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


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

示例1: test_composite_host

# 需要导入模块: from model.hosts import Host [as 别名]
# 或者: from model.hosts.Host import addChild [as 别名]
    def test_composite_host(self):
        # add host
        host = Host(name="pepito", os="linux")
        host.setDescription("Some description")
        host.setOwned(True)
        self.mapper_manager.save(host)
        # add inteface
        iface = Interface(name="192.168.10.168", mac="01:02:03:04:05:06")
        iface.setDescription("Some description")
        iface.setOwned(True)
        iface.addHostname("www.test.com")
        iface.setIPv4({
            "address": "192.168.10.168",
            "mask": "255.255.255.0",
            "gateway": "192.168.10.1",
            "DNS": "192.168.10.1"
        })
        iface.setPortsOpened(2)
        iface.setPortsClosed(3)
        iface.setPortsFiltered(4)
        host.addChild(iface)
        self.mapper_manager.save(iface)

        h = self.mapper_manager.find(host.getID())
        self.assertEquals(
            len(h.getAllInterfaces()),
            len(host.getAllInterfaces()),
            "Interfaces from original host should be equals to retrieved host's interfaces")

        i = self.mapper_manager.find(h.getAllInterfaces()[0].getID())
        self.assertEquals(
            i.getID(),
            iface.getID(),
            "Interface's id' from original host should be equals to retrieved host's interface's id")
开发者ID:BwRy,项目名称:faraday,代码行数:36,代码来源:mapper_integration.py

示例2: testAddInterfaceToHost

# 需要导入模块: from model.hosts import Host [as 别名]
# 或者: from model.hosts.Host import addChild [as 别名]
    def testAddInterfaceToHost(self): 
        host = Host('coco')
        inter = Interface('cuca')
        host.addChild(inter)

        self.assertIn(inter, host.childs.values(), 'Interface not in childs')
        self.assertIn(inter, host.getAllInterfaces(), 'Interface not accessible')
开发者ID:BecomingMore,项目名称:faraday,代码行数:9,代码来源:model_composite.py

示例3: testHostWithMultipleChildTypes

# 需要导入模块: from model.hosts import Host [as 别名]
# 或者: from model.hosts.Host import addChild [as 别名]
    def testHostWithMultipleChildTypes(self):
        host = Host('coco')
        inter = Interface('cuca')
        vuln = ModelObjectVuln('vuln')
        host.addChild(inter) 
        host.addChild(vuln)

        self.assertEquals(len(host.getVulns()), 1, "Vulns added is not 1")
        self.assertIn(vuln, host.getVulns(), "Vuln not accessible")
        self.assertEquals(len(host.getAllInterfaces()), 1, "Interfaces added is not 1") 
开发者ID:BecomingMore,项目名称:faraday,代码行数:12,代码来源:model_composite.py

示例4: testDelNoteFromModelObjectSYNC

# 需要导入模块: from model.hosts import Host [as 别名]
# 或者: from model.hosts.Host import addChild [as 别名]
 def testDelNoteFromModelObjectSYNC(self):
     host = Host('coco')
     note = ModelObjectNote("int_mock0") 
     host.addChild(note.getID(), note)
     self.genericDelTest(host, note, 
             controller.ModelController.delNoteSYNC)
开发者ID:BwRy,项目名称:faraday,代码行数:8,代码来源:model_controller.py

示例5: testDelNoteFromHostSYNC

# 需要导入模块: from model.hosts import Host [as 别名]
# 或者: from model.hosts.Host import addChild [as 别名]
 def testDelNoteFromHostSYNC(self):
     host = Host('coco')
     note = ModelObjectNote("int_mock0") 
     host.addChild(note.getID(), note)
     self.genericDelTest(host, note, 
             controller.ModelController.delNoteFromHostASYNC, process_pending=True)
开发者ID:BwRy,项目名称:faraday,代码行数:8,代码来源:model_controller.py

示例6: testDelVulnFromObjectSYNC

# 需要导入模块: from model.hosts import Host [as 别名]
# 或者: from model.hosts.Host import addChild [as 别名]
 def testDelVulnFromObjectSYNC(self):
     host = Host('coco')
     vuln = ModelObjectVuln("int_mock0") 
     host.addChild(vuln.getID(), vuln)
     self.genericDelTest(host, vuln,
             controller.ModelController.delVulnSYNC)
开发者ID:BwRy,项目名称:faraday,代码行数:8,代码来源:model_controller.py

示例7: testDelVulnFromHostASYNC

# 需要导入模块: from model.hosts import Host [as 别名]
# 或者: from model.hosts.Host import addChild [as 别名]
 def testDelVulnFromHostASYNC(self):
     host = Host('coco')
     vuln = ModelObjectVuln("int_mock0") 
     host.addChild(vuln.getID(), vuln)
     self.genericDelTest(host, vuln,
             controller.ModelController.delVulnFromHostASYNC, process_pending=True)
开发者ID:BwRy,项目名称:faraday,代码行数:8,代码来源:model_controller.py

示例8: testHostWithCredentials

# 需要导入模块: from model.hosts import Host [as 别名]
# 或者: from model.hosts.Host import addChild [as 别名]
 def testHostWithCredentials(self):
     host = Host('coco')
     cred = ModelObjectCred('coco', 'coco123') 
     host.addChild(cred)
     self.assertEquals(len(host.getCreds()), 1, "Creds added is not 1")
     self.assertIn(cred, host.getCreds(), "Cred not accessible")
开发者ID:BecomingMore,项目名称:faraday,代码行数:8,代码来源:model_composite.py


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