test_cisco_simple.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env python
  2. from netmiko import ConnectHandler
  3. from getpass import getpass
  4. #ip_addr = raw_input("Enter IP Address: ")
  5. pwd = getpass()
  6. ip_addr = '184.105.247.70'
  7. telnet_device = {
  8. 'device_type': 'cisco_ios_telnet',
  9. 'ip': ip_addr,
  10. 'username': 'pyclass',
  11. 'password': pwd,
  12. 'port': 23,
  13. }
  14. ssh_device = {
  15. 'device_type': 'cisco_ios_ssh',
  16. 'ip': ip_addr,
  17. 'username': 'pyclass',
  18. 'password': pwd,
  19. 'port': 22,
  20. }
  21. print "telnet"
  22. net_connect1 = ConnectHandler(**telnet_device)
  23. print "telnet prompt: {}".format(net_connect1.find_prompt())
  24. print "send_command: "
  25. print '-' * 50
  26. print net_connect1.send_command_timing("show arp")
  27. print '-' * 50
  28. print '-' * 50
  29. print net_connect1.send_command("show run")
  30. print '-' * 50
  31. print
  32. print "SSH"
  33. net_connect2 = ConnectHandler(**ssh_device)
  34. print "SSH prompt: {}".format(net_connect2.find_prompt())
  35. print "send_command: "
  36. print '-' * 50
  37. print net_connect2.send_command("show arp")
  38. print '-' * 50
  39. print '-' * 50
  40. print net_connect1.send_command("show run")
  41. print '-' * 50
  42. print
  43. #output = net_connect.send_command_expect("show version")
  44. #print
  45. #print '#' * 50
  46. #print output
  47. #print '#' * 50
  48. #print