本文整理汇总了Python中AutoNetkit.ip_to_net_ent_title方法的典型用法代码示例。如果您正苦于以下问题:Python AutoNetkit.ip_to_net_ent_title方法的具体用法?Python AutoNetkit.ip_to_net_ent_title怎么用?Python AutoNetkit.ip_to_net_ent_title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoNetkit
的用法示例。
在下文中一共展示了AutoNetkit.ip_to_net_ent_title方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure_interfaces
# 需要导入模块: import AutoNetkit [as 别名]
# 或者: from AutoNetkit import ip_to_net_ent_title [as 别名]
def configure_interfaces(self, device):
LOG.debug("Configuring interfaces for %s" % self.network.fqdn(device))
"""Interface configuration"""
lo_ip = self.network.lo_ip(device)
interfaces = []
interfaces.append({
'id': 'lo0',
'ip': str(lo_ip.ip),
'netmask': str(lo_ip.netmask),
'prefixlen': str(lo_ip.prefixlen),
'net_ent_title': ank.ip_to_net_ent_title(lo_ip.ip),
'description': 'Loopback',
})
for src, dst, data in self.network.graph.edges(device, data=True):
subnet = data['sn']
int_id = self.int_id(data['id'])
description = 'Interface %s -> %s' % (
ank.fqdn(self.network, src),
ank.fqdn(self.network, dst))
# Interface information for router config
interfaces.append({
'id': int_id,
'ip': str(data['ip']),
'prefixlen': str(subnet.prefixlen),
'broadcast': str(subnet.broadcast),
'description': description,
})
return interfaces
示例2: configure_interfaces
# 需要导入模块: import AutoNetkit [as 别名]
# 或者: from AutoNetkit import ip_to_net_ent_title [as 别名]
def configure_interfaces(self, device):
LOG.debug("Configuring interfaces for %s" % self.network.fqdn(device))
"""Interface configuration"""
lo_ip = self.network.lo_ip(device)
interfaces = []
static_routes = []
interfaces.append({
'id': 'lo0',
'ip': str(lo_ip.ip),
'netmask': str(lo_ip.netmask),
'prefixlen': str(lo_ip.prefixlen),
'net_ent_title': ank.ip_to_net_ent_title(lo_ip.ip),
'description': 'Loopback',
})
for src, dst, data in self.network.graph.edges(device, data=True):
neighbor = ank.fqdn(self.network, dst)
subnet = data['sn']
int_id = self.int_id(data['id'])
description = 'Interface %s -> %s' % (
ank.fqdn(self.network, src),
ank.fqdn(self.network, dst))
# Interface information for router config
interfaces.append({
'id': int_id,
'ip': str(data['ip']),
'prefixlen': str(subnet.prefixlen),
'netmask': str(subnet.netmask),
'broadcast': str(subnet.broadcast),
'description': description,
})
#static routes for the dummy nodes
for virtual in sorted(self.network.virtual_nodes(), key = lambda x: x.fqdn):
virtual_hostname = virtual.hostname
if neighbor == virtual_hostname:
subnet = data['sn']
static_routes.append({
'network': str(subnet.network),
'prefixlen': str(subnet.prefixlen),
'ip': str(data['ip']),
})
return interfaces,static_routes