Getting Started with Python (ii)

Source: Internet
Author: User

Work encountered problems, need to do a lot of repetitive work, that is, to comb the configuration of many routers. So you need to look at what's in the router configuration.


First, in the table to get the device name of the router, the device name is as follows:

# sysname xxxxxxxxx#

Second, you need to get the VLAN and eth-trunk information, which is as follows:

# ... #interface Vlanif40 description to-[xxxxxxxx]-aaa IP binding vpn-instance vpn-instance_111 IP address 192.168.17.125 2 55.255.255.252. #interface Vlanif50 Description to-[yyyyyyyy]-bbb IP binding vpn-instance vpn-instance_222 IP address 19 2.168.17.253 255.255.255.252 ... #......#
#interface eth-trunk1 Description TO-[MMMMMMMM]-CCC ..... #interface eth-trunk2 Description to-[nnnnnnnn]-ddd IP binding. Vpn-instance vpn-instance_333 IP Address 192.168.16.34 255.255.255.252 ... #

The above information, need to comb the sensitive information I replaced with other content, do not need to comb the information used ... have been replaced.


With the interface vlanif information and eth-trunk information above, you will then look at the interfaces that each VLAN contains and the interfaces that the eth-trunk contains. The contents are as follows:

#interface gigabitethernet1/0/0 description to-rrrrr undo shutdown portswitch Port default VLAN 1004# ... #interface Gigabit ETHERNET1/0/17 description to-sssss undo shutdown portswitch Port default VLAN 1002# ... #interface gigabitethernet1/0/22 NE Gotiation Auto Description des to-dddddddd undo shutdown Eth-trunk 8#

As can be seen from the above, g1/0/0 belongs to the interface of VLAN 1004, G1/0/17 belongs to VLAN 1002 interface, G1/0/22 belongs to Eth-trunk 8. Of course, some of the interfaces do not belong to VLANs and are not part of Eth-trunk.


From the above analysis, the VLAN and interface is a one-to-many case, that is, a VLAN contains multiple interfaces, an interface belongs to a VLAN. The same is true for Eth-trunk and interface relationships.


This is probably the case in the configuration. The next time you will be introduced specifically, how to use Python to parse these configurations into the table mentioned in the previous article.

This article is from the "Sleep Blog" blog, please be sure to keep this source http://wujue.blog.51cto.com/11999347/1858583

Getting Started with Python (ii)

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.