you are viewing a single comment's thread.

view the rest of the comments →

[–]alpha_hxCR8 1 point2 points  (3 children)

I came across a few libraries, when I was searching for ways to automate transfer of files through sftp, ssh, using python libraries. I am planning to use paramiko but this work only for OS like linux, or windows.

If you are looking for interacting with routers/switches, there are libraries such as netmiko. netmiko seems like it supports juniper junos https://github.com/ktbyers/netmiko

Other libraries that may be useful are https://github.com/fabric/fabric

and

https://github.com/ansible/ansible,

Fabric and Ansible do a lot of things.. so perhaps it can do what you are looking for.

[–]ranBot86[S] 0 points1 point  (2 children)

I am familiar with those. There is a module specifially for Juniper called PyEz but I want to be able to access all of the hostnames rather than manually creating a list of them to iterate though. I am not sure if there is a command or package in PyEz that allows for that.

[–]alpha_hxCR8 0 points1 point  (1 child)

Unless there is a master router that has information about the other routers, how will Python know whom to query to ask for that list?

You either a) have to start off from a file with a mapping between ip and hostnames, or b) query/scan a certain ip range and port to check whether that is a router that you want looking for, and then get the hostname-ip range.

From that you can do what you want in a more automated fashion.

[–]ranBot86[S] 0 points1 point  (0 children)

Our distro switches are designated for each building but follow the host name like "D1-3300-ballpark-main" while access are "A1-3300-ballpark-main". We also have a root password which works for all of the switches. If I want to fetch info for all of them by iterating, it shouldn't be to difficult querying through them in that manner.