Creating loopback interface

Let us see another example, in which we validate if the Loopback45 interface is created on all routers. If not, the script should automatically create the Loopback45 interface and finally validate the availability of that interface on routers.

Let us first write a code to validate a given interface on all the routers:

#usecase_loopback.pyfrom netmiko import ConnectHandlerfrom threading import Threadfrom pysnmp.entity.rfc3413.oneliner import cmdgencmdGen = cmdgen.CommandGenerator()threads = []def checkloopback45(ip,interface):     loopbackpresent=False     cmdGen = cmdgen.CommandGenerator()     errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.bulkCmd(    cmdgen.CommunityData('mytest'), cmdgen.UdpTransportTarget((ip, ...

Get Practical Network Automation - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.