Jul-25-2018, 10:55 AM
Hi There,
trying ciscolib module to discover network topology. small script as below
ip:172.21.162.164 hostname:PUN-DIG-DIG-01-ONN-BR-BS-GL-01 remote_port:FastEthernet0/24 local_port:FastEthernet0/18
ip:172.21.162.157 hostname:PUN-DIG-DIG-02-ONN-BR-BS-01 remote_port:FastEthernet0/24 local_port:FastEthernet0/15
ip:172.21.160.2 hostname:pu-dig-dig-r1-as01 remote_port:GigabitEthernet1/0/9 local_port:GigabitEthernet0/1
trying ciscolib module to discover network topology. small script as below
import ciscolib switch = ciscolib.Device("172.21.160.3", "test123", "anna") switch.connect() print(switch.get_neighbors())
Output:[{'ip': '172.21.162.164', 'hostname': 'PUN-DIG-DIG-01-ONN-BR-BS-GL-01', 'remote_port': 'FastEthernet0/24', 'local_port': 'FastEthernet0/18'}, {'ip': '172.21.162.157', 'hostname': 'PUN-DIG-DIG-02-ONN-BR-BS-01', 'remote_port': 'FastEthernet0/24', 'local_port': 'FastEthernet0/15'}, {'ip': '172.21.162.71', 'hostname': 'PUN-DIG-DIG-01-ONN-BR-BS-70', 'remote_port': 'FastEthernet0/24', 'local_port': 'FastEthernet0/19'}, {'ip': '172.21.160.2', 'hostname': 'pu-dig-dig-r1-as01', 'remote_port': 'GigabitEthernet1/0/9', 'local_port': 'GigabitEthernet0/1'}]
need to print output as belowip:172.21.162.164 hostname:PUN-DIG-DIG-01-ONN-BR-BS-GL-01 remote_port:FastEthernet0/24 local_port:FastEthernet0/18
ip:172.21.162.157 hostname:PUN-DIG-DIG-02-ONN-BR-BS-01 remote_port:FastEthernet0/24 local_port:FastEthernet0/15
ip:172.21.160.2 hostname:pu-dig-dig-r1-as01 remote_port:GigabitEthernet1/0/9 local_port:GigabitEthernet0/1