Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import paramiko
- import time
- import sys
- import os
- import json
- import re
- app_server_mgmt_ip = '192.168.10.20'
- app_switch_mgmt_ip = '192.168.20.5'
- username = ''
- password = ''
- ip = app_switch_mgmt_ip
- from netmiko import ConnectHandler
- cisco_ios_xrv = {
- 'device_type': 'cisco_xr',
- 'ip': app_switch_mgmt_ip,
- 'username': username,
- 'password': password,
- 'port' : 22, # optional, defaults to 22
- 'secret': 'secret', # optional, defaults to ''
- 'verbose': False, # optional, defaults to False
- }
- net_connect = ConnectHandler(**cisco_ios_xrv)
- output = net_connect.send_command('sh ver')
- datai222 = str(output)
- print datai222
- output = net_connect.send_command('sh ip route '+app_server_mgmt_ip)
- data = str(output)
- displaymessage1 = data
- #print displaymessage1
- output2 = net_connect.send_command('sh ip arp '+app_server_mgmt_ip)
- data2 = str(output2)
- ##print data2
- stringsplit2 = data2.split()
- #print stringsplit2
- stringsplit2value = stringsplit2[11].strip()
- displaymessage2 = data2
- #print displaymessage2
- #third command
- output3 = net_connect.send_command('ping '+app_server_mgmt_ip)
- data3 = str(output3)
- displaymessage3 = data3
- #print displaymessage3
- import time
- #time.sleep(1)
- #print "4th command"
- #print "stringsplit2value"+stringsplit2value
- output4 = net_connect.send_command('sh mac address-table address '+stringsplit2value)
- #output4 = net_connect.send_command('sh mac address-table address '+stringsplit2value)
- data4 = str(output4)
- displaymessage4 = data4
- #print displaymessage4
- stringsplit4 = data4.split('n')
- ##print stringsplit4
- stringfound4 = str(stringsplit4[7]).find('Po')
- #print stringfound4
- if(stringfound4 == -1):
- print("Not found")
- else:
- stringsplit4split = stringsplit4[7].split('Po')
- stringsplit4splitvalue4 = stringsplit4split[1].strip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement