Advertisement
Guest User

Untitled

a guest
Apr 10th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. import paramiko
  2. import time
  3. import sys
  4. import os
  5. import json
  6. import re
  7.  
  8.  
  9.  
  10. app_server_mgmt_ip = '192.168.10.20'
  11. app_switch_mgmt_ip = '192.168.20.5'
  12. username = ''
  13. password = ''
  14. ip = app_switch_mgmt_ip
  15.  
  16.  
  17. from netmiko import ConnectHandler
  18.  
  19. cisco_ios_xrv = {
  20. 'device_type': 'cisco_xr',
  21. 'ip': app_switch_mgmt_ip,
  22. 'username': username,
  23. 'password': password,
  24. 'port' : 22, # optional, defaults to 22
  25. 'secret': 'secret', # optional, defaults to ''
  26. 'verbose': False, # optional, defaults to False
  27. }
  28. net_connect = ConnectHandler(**cisco_ios_xrv)
  29. output = net_connect.send_command('sh ver')
  30. datai222 = str(output)
  31. print datai222
  32.  
  33. output = net_connect.send_command('sh ip route '+app_server_mgmt_ip)
  34. data = str(output)
  35. displaymessage1 = data
  36. #print displaymessage1
  37.  
  38. output2 = net_connect.send_command('sh ip arp '+app_server_mgmt_ip)
  39. data2 = str(output2)
  40. ##print data2
  41. stringsplit2 = data2.split()
  42. #print stringsplit2
  43. stringsplit2value = stringsplit2[11].strip()
  44. displaymessage2 = data2
  45. #print displaymessage2
  46.  
  47. #third command
  48. output3 = net_connect.send_command('ping '+app_server_mgmt_ip)
  49. data3 = str(output3)
  50. displaymessage3 = data3
  51. #print displaymessage3
  52. import time
  53. #time.sleep(1)
  54. #print "4th command"
  55. #print "stringsplit2value"+stringsplit2value
  56. output4 = net_connect.send_command('sh mac address-table address '+stringsplit2value)
  57. #output4 = net_connect.send_command('sh mac address-table address '+stringsplit2value)
  58. data4 = str(output4)
  59. displaymessage4 = data4
  60. #print displaymessage4
  61. stringsplit4 = data4.split('n')
  62. ##print stringsplit4
  63. stringfound4 = str(stringsplit4[7]).find('Po')
  64. #print stringfound4
  65. if(stringfound4 == -1):
  66. print("Not found")
  67. else:
  68. stringsplit4split = stringsplit4[7].split('Po')
  69. stringsplit4splitvalue4 = stringsplit4split[1].strip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement