Device OS upgrades
Sometimes we need to upgrade devices such as routers, switches, and firewalls. It is easy to perform upgrades on one device, but we need automation to upgrade multiple routers. Different devices have different ways of upgrading IOS or OS images, and the automation or scripts are created with different methods depending on the device.
Taking an example of upgrading a Cisco IOS router; there are two basic steps or tasks that need to be performed:
- Copy the relevant OS or IOS image into
flash:
orbootflash:
. - Change the config to reload the router with the new image.
Task 1: Prerequisites (to copy relevant OS or IOS image):
- We need a FTP server that's accessible from the router and has the IOS image that we need on the router
- We need the image, the correct MD5 checksum, and the image size for validation
The sample code for task 1 is as follows:
from netmiko import ConnectHandler import time def pushimage(imagename,cmd,myip,imgsize,md5sum=None): uname="cisco" passwd="cisco...