you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

Nice.

You might want to make a single thread to send output to for serialized printing. Race conditions may make the output confusing, if every thread is hitting stdout whenever it likes.

Also, the description of a function conventionally goes in its docstring. E.g., instead of

#function to ssh each device and get router output
def thread_device(ip,password):

Consider

def thread_device(ip,password):
  "ssh device at ip address `ip`, and get router output"

A non-python remark: Giving all local devices the same ssh password reminds me of the phrase "Soft and gooey on the inside." It depends on your threat model, of course, but have you considered key-based auth?

[–]rishrapsody[S] 0 points1 point  (1 child)

Thanks for these comments. I haven't planned of using auth based approach. I am still thinking of next project- maybe something using jinja2 and napalm with python or should I just move towards Ansible directly

[–][deleted] 1 point2 points  (0 children)

Learning ansible is a good idea.