本文整理汇总了Python中host.Host.ip方法的典型用法代码示例。如果您正苦于以下问题:Python Host.ip方法的具体用法?Python Host.ip怎么用?Python Host.ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类host.Host
的用法示例。
在下文中一共展示了Host.ip方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initialize
# 需要导入模块: from host import Host [as 别名]
# 或者: from host.Host import ip [as 别名]
def initialize(self):
if self.subnet:
address_range = self.get_address_range(self.subnet)
print('Size of network: ' + str(address_range.size()))
self.alive_hosts = self.get_alive_hosts(address_range)
for counter, ip in enumerate(self.alive_hosts):
host = Host()
host.ip = ip
host.id += str(counter)
self.host_list.append(host)
else:
host = Host()
host.ip = self.address
self.add_host(host)
示例2: get_arp_cache
# 需要导入模块: from host import Host [as 别名]
# 或者: from host.Host import ip [as 别名]
def get_arp_cache(self, host):
"""Get ARP table from host"""
results = Crawler.snmp.walk(host.ip, '.1.3.6.1.2.1.4.22.1.2.' + str(host.interface))
if results is not None:
for result in results:
for name, val in result:
print(str(name) + ' = ' + hex_to_mac(val))
if str(name).find('1.3.6.1.2.1.4.22.1.2.' + str(host.interface)) != -1:
new_host = Host()
new_host.ip = str(name).split('1.3.6.1.2.1.4.22.1.2.' + str(host.interface) + '.',1)[1]
#print('new host ip: ' + new_host.ip)
new_host.mac = hex_to_mac(val)
#print('new host mac: ' + new_host.mac)
self.add_host(new_host)
示例3: create_host
# 需要导入模块: from host import Host [as 别名]
# 或者: from host.Host import ip [as 别名]
def create_host(self, ip_addr):
"""Create a new host"""
#print('CREATING NEW HOST WITH IP ' + str(ip_addr))
if self.ip_exists(ip_addr):
#print('\tIP ALREADY EXISTS')
return self.get_host_by_ip(ip_addr)
new_host = Host()
new_host.id += str(self.host_counter)
new_host.ip = ip_addr
new_host.add_ip(ip_addr)
self.host_counter += 1
self.all_hosts.append(new_host)
self.add_to_host_list(new_host)
return new_host
示例4: get_neighbors
# 需要导入模块: from host import Host [as 别名]
# 或者: from host.Host import ip [as 别名]
def get_neighbors(self, host): #needs more testing
"""Get list of host neighbors using Cisco Discovery Protocol"""
print('Getting neighbors')
neighbors = []
host.visited = True
results = Crawler.snmp.walk(host.ip, self.oid.neighbors2)
if results is None:
return []
for result in results:
for name, val in result:
new_host = Host()
new_host.ip = hex_to_ip(val)
new_host.id = self.get_host_id((new_host.ip))
if new_host.id is not None:
neighbors.append(new_host.id)
return neighbors
示例5: Host
# 需要导入模块: from host import Host [as 别名]
# 或者: from host.Host import ip [as 别名]
elementos = []
# __ __ __
#| | | | | |
#| |----| |----| |
#|--| |--| |--|
# h0 r0 h1
rotas ={'10.0.0.0': '0', '10.1.1.0': '1'}
#Rede
#-hosts
h0 = Host("h0")
h0.ip = '10.0.0.1'
h0.setPapel('ircc')
h0
h1 = Host("h1")
h1.ip = '10.1.1.1'
h1.setPapel('ircc')
h1
#-roteadores
r0 = Router("r0", 2)
ipRouter = ['0', '10.0.0.2','1','10.1.1.2', '2' , '192.168.3.3']
r0.setIp(ipRouter)
r0
#-enlaces
e0 = Enlace(h0, r0.getPorta(0), "10M", "5s")
e1 = Enlace(h1, r0.getPorta(1), "10M", "5s")
#e1 = Enlace(h0, h1, "10M", "5s")