jack jones
asked on
Cisco ios upgrade Automation using script or any other way
How to automate a cisco ios upgrade process using a script like python or any other script or any other tool
ASKER
HI how can i make this setup
Ansible 1.8.2
Python 2.7.5
Paramiko 1.14.0
Python scp module 0.10.0
Netmiko 0.2.0
if there is tutorial for this https://pynet.twb-tech.com/blog/automation/cisco-ios.html it would be great .. im not able to setup the lab
is it possible to do it straightforward with the python script querying switches and tftp and carry rest of the process.
Ansible 1.8.2
Python 2.7.5
Paramiko 1.14.0
Python scp module 0.10.0
Netmiko 0.2.0
if there is tutorial for this https://pynet.twb-tech.com/blog/automation/cisco-ios.html it would be great .. im not able to setup the lab
is it possible to do it straightforward with the python script querying switches and tftp and carry rest of the process.
https://networklore.com/ansible-ios-upgrade/ has more details on the playbook.
If setting it up is an issue, an easier approach might be the Cisco Network Assistant to upgrade IOS on multiple devices. Point#6 in the http://www.cisco.com/c/en/us/products/collateral/cloud-systems-management/network-assistant/prod_white_paper0900aecd802d1b95.html (CISCO IOS SOFTWARE UPGRADE) step by steps.
If you still want to script it, you can look at a step by step here: https://0wned.it/2014/08/02/automating-mass-cisco-ios-upgrades/; where clogin from Rancid is used and scripted to automate ios upgrades using a shell script.
There are other languages, too, that can help - expect and Tcl come to mind.
If setting it up is an issue, an easier approach might be the Cisco Network Assistant to upgrade IOS on multiple devices. Point#6 in the http://www.cisco.com/c/en/us/products/collateral/cloud-systems-management/network-assistant/prod_white_paper0900aecd802d1b95.html (CISCO IOS SOFTWARE UPGRADE) step by steps.
If you still want to script it, you can look at a step by step here: https://0wned.it/2014/08/02/automating-mass-cisco-ios-upgrades/; where clogin from Rancid is used and scripted to automate ios upgrades using a shell script.
There are other languages, too, that can help - expect and Tcl come to mind.
ASKER
Hi netcmh,
Im using win8 pc. I have installed python and paramiko. Now im able to ssh a device.
Regarding This link https://0wned.it/2014/08/02/automating-mass-cisco-ios-upgrades/
he is using rancid and shell script.
Can we convert the upgrade.sh to python to suit my lab or change the existing shell script.
Regarding this link https://networklore.com/ansible-ios-upgrade/
Im not sure is he installed the ansible module on python and executed the script in python..
Since im using python and paramiko also now m able to ssh a device means its reachable now.
Can we make a those 5-6 steps of upgrade in python and execute ?
Im using win8 pc. I have installed python and paramiko. Now im able to ssh a device.
Regarding This link https://0wned.it/2014/08/02/automating-mass-cisco-ios-upgrades/
he is using rancid and shell script.
Can we convert the upgrade.sh to python to suit my lab or change the existing shell script.
Regarding this link https://networklore.com/ansible-ios-upgrade/
Im not sure is he installed the ansible module on python and executed the script in python..
Since im using python and paramiko also now m able to ssh a device means its reachable now.
Can we make a those 5-6 steps of upgrade in python and execute ?
Ansible: baby steps: https://networklore.com/ansible-getting-started/
converting to python is a bit beyond the usual requests I get.
More on python help to automate login to router and issue commands: https://communities.cisco.com/people/franklaszlo/blog/2016/04/03/using-python-to-script-cisco-routers
converting to python is a bit beyond the usual requests I get.
More on python help to automate login to router and issue commands: https://communities.cisco.com/people/franklaszlo/blog/2016/04/03/using-python-to-script-cisco-routers
ASKER
Thanks i will try this.
Also can i achieve this using python and paramiko
Also wat setup is required for this https://0wned.it/2014/08/02/automating-mass-cisco-ios-upgrades/ that is tools to implement this can we exclude rancid
Also can i achieve this using python and paramiko
Also wat setup is required for this https://0wned.it/2014/08/02/automating-mass-cisco-ios-upgrades/ that is tools to implement this can we exclude rancid
ASKER
I have 2 switch i want to take backup of those two using python can you pls advise the script that can help.. using windows 8 machine and python 2.7 and paramiko installed
For the python and paramiko: https://pynet.twb-tech.com/blog/python/paramiko-ssh-part1.html
ASKER
I have installed python 2.7 and paramiko on my test machine. Also installed gns3 on test machine.
In gns console I have configured switches How do I query or ssh those network device using python that is installed on my test machine
Pls let me know ..
In gns console I have configured switches How do I query or ssh those network device using python that is installed on my test machine
Pls let me know ..
I do not know. I thought you were working with real switches.
ASKER
Yes im working with real switches ... I was able ssh real switches but I would like to perform lab before going production
ASKER
ssh was very basic so I tried on real switches and it worked.. then other steps I would like to perform on lab before going on production pls help
I understand, but I don't know what kind of settings you may have on the GNS3 that would prevent an otherwise working solution.
ASKER
so u mean by default, if I configure a switch in gns I can ssh it using python installed on my test machine?
Please see https://wn.com/gns3_talks_python_for_network_engineers_with_gns3_part_1__paramiko,_ssh,_python_and_cisco. This is a series of instructional videos on what you're trying to achieve. Hope it helps.
ASKER
Hi netcmh,
Yes i have divided the task for ios upgrade doing this part by part. im creating a text file so it may contain more then 2 entries of switches.
ssh a switch
Till here im able to successfully ssh the switch.
Now i want to execute command on switch to backup
How can i integrate this command in my script to take backup?
Also how can i make it for multiple switches to take the backup just like iteration in my text file containing list of entry for switches
Yes i have divided the task for ios upgrade doing this part by part. im creating a text file so it may contain more then 2 entries of switches.
ssh a switch
import paramiko
import sys
import time
#setting parameters like host IP, username, passwd and number of iterations to gather cmds
HOST = "10.11.214.143"
USER = "admin"
PASS = "passwd"
ITERATION = 3
#A function that logins and execute commands
def fn():
client1=paramiko.SSHClient()
#Add missing client key
client1.set_missing_host_key_policy(paramiko.AutoAddPolicy())
#connect to switch
client1.connect(HOST,username=USER,password=PASS)
print "SSH connection to %s established" %HOST
Till here im able to successfully ssh the switch.
Now i want to execute command on switch to backup
copy nvram:startup-config { ftp: | rcp: | tftp: }
How can i integrate this command in my script to take backup?
Also how can i make it for multiple switches to take the backup just like iteration in my text file containing list of entry for switches
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If this has been resolved, please assist with housekeeping and close the ticket. Thanks.
ASKER
thanks netmch I was on leave haven't checked yet will check soon.
Ok. Thanks for the grade. Good luck.
Ansible will get you to the upgrade: http://anastarsha.com/automating-cisco-device-upgrades-with-ansible/
If not, there are other ways. Let me know.