本文整理匯總了Python中model.hosts.Host.getID方法的典型用法代碼示例。如果您正苦於以下問題:Python Host.getID方法的具體用法?Python Host.getID怎麽用?Python Host.getID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類model.hosts.Host
的用法示例。
在下文中一共展示了Host.getID方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_interface_creation
# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getID [as 別名]
def test_interface_creation(self):
name = "pepito"
os = "Windows"
host = Host(name, os)
when(self._model_controller).find(host.getID()).thenReturn(host)
name = ""
mac = "00:00:00:00:00:00"
ipv4_address = "0.0.0.0"
ipv4_mask = "0.0.0.0"
ipv4_gateway = "0.0.0.0"
ipv4_dns = []
ipv6_address = "0000:0000:0000:0000:0000:0000:0000:0000"
ipv6_prefix = "00"
ipv6_gateway = "0000:0000:0000:0000:0000:0000:0000:0000"
ipv6_dns = []
network_segment = ""
hostname_resolution = []
interface_id = self.client.createInterface(
name, mac, ipv4_address, ipv4_mask, ipv4_gateway, ipv4_dns,
ipv6_address, ipv6_prefix, ipv6_gateway, ipv6_dns, network_segment,
hostname_resolution, host.getID())
interface = Interface(
name, mac, ipv4_address, ipv4_mask, ipv4_gateway, ipv4_dns,
ipv6_address, ipv6_prefix, ipv6_gateway, ipv6_dns, network_segment,
hostname_resolution, parent_id=host.getID())
self.assertNotEquals(
interface_id, None, "interface created shouldn't be None")
self.assertEquals(
interface.getID(), interface_id, "ids should be the same")
示例2: test_host_creation
# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getID [as 別名]
def test_host_creation(self):
host = Host(name="pepito", os="linux")
self.hmapper.save(host)
h = self.hmapper.find(host.getID())
self.assertEquals(
h,
host,
"Host retrieved should be the same as persisted")
self.assertEquals(
h.getID(),
host.getID(),
"Host retrieved's Id should be the same as persisted's Id")
示例3: testDeleteHostObjectDispatchRemoveSYNC
# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getID [as 別名]
def testDeleteHostObjectDispatchRemoveSYNC(self):
host = Host("coquito")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(host.getID()).thenReturn(objectMapper)
when(objectMapper).delObject(host.getID()).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.delHostSYNC(host)
verify(mappersManager).getMapper(host.getID())
verify(objectMapper).delObject(host.getID())
示例4: testDeleteHostObjectDispatchRemoveASYNC
# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getID [as 別名]
def testDeleteHostObjectDispatchRemoveASYNC(self):
host = Host("coquito")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).find(host.getID()).thenReturn(host)
when(mappersManager).remove(host.getID()).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.delHostASYNC(host.getID())
model_controller.processAllPendingActions()
verify(mappersManager).remove(host.getID())
示例5: test_host_saving
# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getID [as 別名]
def test_host_saving(self):
host = Host(name="pepito", os="linux")
host.setDescription("Some description")
host.setOwned(True)
self.mapper_manager.save(host)
self.assertNotEquals(
self.connector.getDocument(host.getID()),
None,
"Document shouldn't be None")
self.assertEquals(
self.connector.getDocument(host.getID()).get("name"),
host.getName(),
"Document should have the same host name")
示例6: test_host_serialization
# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getID [as 別名]
def test_host_serialization(self):
host = Host(name="pepito", os="linux")
host.setDescription("Some description")
host.setOwned(True)
hserialized = self.hmapper.serialize(host)
# if serialization fails, returns None
self.assertNotEqual(
hserialized,
None,
"Serialized host shouldn't be None")
# we check the host attributes
self.assertEquals(
hserialized.get("_id"),
host.getID(),
"Serialized ID is not the same as Host ID")
self.assertEquals(
hserialized.get("name"),
host.getName(),
"Serialized name is not the same as Host name")
self.assertEquals(
hserialized.get("os"),
host.getOS(),
"Serialized OS is not the same as Host OS")
self.assertEquals(
hserialized.get("description"),
host.getDescription(),
"Serialized description is not the same as Host description")
self.assertEquals(
hserialized.get("owned"),
host.isOwned(),
"Serialized owned flag is not the same as Host owned flag")
示例7: test_find_not_loaded_host
# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getID [as 別名]
def test_find_not_loaded_host(self):
host = Host(name="pepito", os="linux")
host.setDescription("Some description")
host.setOwned(True)
self.mapper_manager.save(host)
#create a set of mappers, so we have a clean map
self.mapper_manager = MapperManager()
self.mapper_manager.createMappers(self.connector)
h = self.mapper_manager.find(host.getID())
self.assertNotEquals(
h,
None,
"Existent host shouldn't return None")
self.assertEquals(
h.getName(),
"pepito",
"Host name should be pepito")
self.assertEquals(
h.getOS(),
"linux",
"Host os should be linux")
示例8: testDelRemovesObjectFromTrie
# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getID [as 別名]
def testDelRemovesObjectFromTrie(self):
host = Host("coquito")
mappersManager = self.createMapperMock()
objectMapper = mock()
triemock = mock()
when(mappersManager).getMapper(host.class_signature).thenReturn(objectMapper)
when(mappersManager).find(host.getID()).thenReturn(host)
when(triemock).addWord(host.getName()).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.treeWordsTries = triemock
model_controller.delHostSYNC(host.getID())
verify(mappersManager).remove(host.getID())
verify(triemock).removeWord(host.getName())
示例9: test_host_create_and_delete
# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getID [as 別名]
def test_host_create_and_delete(self):
host = Host(name="coquito")
self.mapper_manager.save(host)
h_id = host.getID()
self.assertNotEquals(
self.mapper_manager.find(h_id),
None,
"Host should be in the mapper")
self.assertNotEquals(
self.connector.getDocument(h_id),
None,
"Host should be in the db")
self.mapper_manager.remove(h_id)
self.assertEquals(
self.mapper_manager.find(h_id),
None,
"Host shouldn't exist anymore in the mapper")
self.assertEquals(
self.connector.getDocument(h_id),
None,
"Host shouldn't exist anymore in the db")
示例10: test_composite_host
# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getID [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")
示例11: test_host_creation
# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getID [as 別名]
def test_host_creation(self):
name = "pepito"
os = "Windows"
host_id = self.client.createHost(name, os)
host = Host(name, os)
self.assertEquals(host.getID(), host_id, "ids should be the same")
示例12: testAddObjectSavesChildInParent
# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getID [as 別名]
def testAddObjectSavesChildInParent(self):
host = Host('coco')
interface = Interface("int_mock0")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(interface).thenReturn(objectMapper)
when(objectMapper).saveObject(interface).thenReturn(True)
when(mappersManager).find(host.getID()).thenReturn(host)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.addInterfaceSYNC(host.getID(), interface)
verify(mappersManager).getMapper(interface)
verify(objectMapper).saveObject(interface)
self.assertEquals(interface, host.findChild(interface.getID()),
"Orphan child, what happen papi?")
示例13: testEditHostSyncGetsMapperDispatchedSYNC
# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getID [as 別名]
def testEditHostSyncGetsMapperDispatchedSYNC(self):
host = Host("coquito")
mappersManager = self.createMapperMock()
objectMapper = mock()
triemock = mock()
when(mappersManager).find(host.getID()).thenReturn(host)
when(mappersManager).saveObject(host).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.editHostSYNC(host.getID(), 'new_name', 'new_desc', 'new_os', True)
verify(mappersManager).saveObject(host)
verify(mappersManager).find(host.getID())
self.assertEquals(host.getName(), 'new_name', "Name not updated")
self.assertEquals(host.getDescription(), 'new_desc', "Description not updated")
self.assertEquals(host.getOS(), 'new_os', "OS not updated")
self.assertEquals(host.isOwned(), True, "Owned status not updated")
示例14: testAddInterfaceGetsMapperDispatchSaveSYNC
# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getID [as 別名]
def testAddInterfaceGetsMapperDispatchSaveSYNC(self):
host = Host('coco')
interface = Interface("int_mock0")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(interface).thenReturn(objectMapper)
when(objectMapper).saveObject(interface).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.addInterfaceSYNC(host.getID(), interface)
verify(mappersManager).getMapper(interface)
verify(objectMapper).saveObject(interface)
示例15: testAddNoteToModelObjectSYNC
# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getID [as 別名]
def testAddNoteToModelObjectSYNC(self):
host = Host("pepito")
note = ModelObjectNote("a_note")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(note).thenReturn(objectMapper)
when(objectMapper).saveObject(note).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.addNoteSYNC(host.getID(), note)
verify(mappersManager).getMapper(note)
verify(objectMapper).saveObject(note)