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
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