Advertisement
Guest User

Untitled

a guest
Nov 14th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import getpass
  2. from netmiko import ConnectHandler
  3. from datetime import datetime
  4.  
  5. # Get credentials
  6. username = raw_input("Username: ")
  7. password = getpass.getpass("User Password: ")
  8. asa_secret = getpass.getpass("ASA Secret Password: ")
  9.  
  10. # Credential hash table for copying to device tables
  11. credentials = {
  12. 'username': username,
  13. 'password': password,
  14. }
  15.  
  16. # Device hash tables
  17. its_asa = {
  18. 'device_type': 'cisco_asa',
  19. 'ip': '172.16.10.1',
  20. 'secret': asa_secret,
  21. }
  22.  
  23. # List to include all devices controlled by this script
  24. all_devices = [its_asa]
  25.  
  26. # This loop will add the entered credentials to everything in the
  27. # 'all_devices' list
  28. for a_device in all_devices:
  29. a_device.update(credentials)
  30.  
  31. # Loop that executes command(s) on several devices
  32. start_time = datetime.now()
  33. for a_device in all_devices:
  34. ios_connect = ConnectHandler(**a_device)
  35. output = ios_connect.send_command("show version")
  36. print "\n\n-----> Device {0} <-----".format(a_device['device_type'])
  37. print output
  38. print "\n\n-----> END <-----"
  39.  
  40. end_time = datetime.now()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement