Discover a foreigner using Python to write a small framework Tratto for managing Cisco devices that can be used to execute commands in bulk.
There are 3 main files after download:
systems.py defines the operating systems of a number of different devices and their common commands.
Connectivity.py is the main implementation of the code, in fact, the main is the use of P
Ciscolib is an open-source third-party Python module on git that manages Cisco switches. Only simple Telnet management is supported at this time. The management method is very simple, the module source code itself is not complex. It is helpful for daily batch configuration.The module structure is:Official Operating Example:Import ciscolib switch = Ciscolib. Device ("hostname or IP", "Login password", "Optio
Today, a small framework tratto for managing Cisco devices, written in Python, can be used to execute commands in bulk.
There are 3 main files after download:
systems.py defines the operating systems of a number of different devices and their common commands.
Connectivity.py is the main implementation of the code, in fact, the main is the use of Python pexpect m
!! Using the Telnetlib Library1 topologiesR4, R5 are not routed to 1.1.1.1 and 2.2.2.2 when the script is not running:The configuration document is placed in the same directory as the Python script:After running the Python script:-process=image/watermark,size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_ zmfuz3pozw5nagvpdgk= "alt=" Python
Records the interface of Cisco devices using a Python script.#!/usr/bin/envpythonimportparamikoimportsysimporttimeclassciscoswitch (): def__init__ (Self,host,username,password): self.username=username self.host=host self.password =passworddeflogin (self): Self.child=paramiko. Sshclient () NBSP;NBSP;NBSP;NBSP;NBSP;NBSP;NBSP;NBSP;NBSP;NBSP;NBSP;NBSP;NBSP;NBSP;NBSP;NBSP;NBSp;self.child.set_missing_host_key_p
() switch.interfaceinfo (' showipint Brief ') nbsP;switch.show (' show Version ') switch.close () except (eoferror,netmikotimeoutexception): print (' Cannot connecttodevice! ')How to increase the number of subnets requires more than one layer of loops, the code changes as follows:if__name__== ' __main__ ':p rint "[+]thisprogramisbegingdone ... " #username =raw_input (' username: ') #password =getpass.getpass () ipadd=ipset ([IP (' 10.0.0.0/30 '), IP (' 10.0.1.0/30 '), IP (' 10.0.2.0/30 ')
It took me one hours to study the other Python plug-in for the network device Netmiko, which is still full of fun, but I still do not understand how to multi-threading, or have to work hard.#!/usr/bin/pythonfromnetmikoimportconnecthandlerimporttimeclasscisconetwork: def__init__ (self): pass defciscodevice (self,iplist): device={' device_type ': ' Cisco_ios ', ' IP ':iplist, ' username ': ' admin ', ' Password ':' Password.123 ' } print "connectt
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.