1

I saved my sample configuration file below. I would like to parse interface details, like Interface name, Description, vlan-type, qos-policy, ip address and also want identify WAN ip pool through interface ip address.

#
interface Aux0/0/1
 link-protocol ppp
 undo shutdown
#
interface Eth-Trunk1
 description TO DEL-CON-S5328EI-SW-A5 Eth-Trunk2
 mode lacp-static
 lacp preempt enable
 max active-linknumber 1
 lacp preempt delay 10
 statistic enable
#
interface Eth-Trunk1.50
 statistic enable
#
interface Eth-Trunk1.120
 vlan-type dot1q 120
 description EXT_COGENT E SERVICES PRIVATE LIMITED_12005744750_50MB
 ip address 111.93.43.217 255.255.255.252
 traffic-policy INFRA-ACL inbound
 qos-profile 50Mbps inbound identifier none
 qos-profile 50Mbps outbound identifier none
 statistic enable
#
interface Eth-Trunk1.123
 vlan-type dot1q 123
 description EXT_ILL_SARALA-HANDICRAFTS_PANIPAT_5018027739
 ip address 182.156.211.161 255.255.255.252
 traffic-policy INFRA-ACL inbound
 user-queue cir 10240 pir 10400 inbound
 user-queue cir 10240 pir 10400 outbound
 statistic enable
#

ip route-static 111.93.39.244 255.255.255.252 Eth-Trunk1.123 182.156.211.162 description SARALA-HANDICRAFTS_5018027739
Mike Pennington
  • 41,899
  • 19
  • 136
  • 174
Anna Patil
  • 31
  • 3

1 Answers1

0

sample code, however not able to print output properly

from ciscoconfparse import CiscoConfParse
from pprint import pprint
parse = CiscoConfParse("huwaieconf.txt")
allInterfaces = {}
interfaces = {}
intfs = parse.find_objects_w_parents(r'^interface',r'Eth')
for intfobj in intfs:
    intf_name = intfobj.text.strip()
    #print (intf_name)
    interfaces.update({'name': intf_name})
    descr = intfobj.re_match_iter_typed((r" description "), group=1)
    interfaces.update({'description': descr})
    ip_addr = intfobj.re_match_iter_typed((r"ip\saddress\s(\S+\s+\S+)"),group=1)
    interfaces.update({'IP':ip_addr})
    print (interfaces)

{'name': 'description EXT/ILL/784395/INVESTOPAD/12405784395/New Delhi/ 30Mbps/Ethernet', 'description': '', 'IP': ''}
{'name': 'description EXT/ILL/782226/NYT NEWS BUREAU INDIA PRIVATE LIMITED/1105782226/New Delhi/Ethernet', 'description': '', 'IP': ''}
{'name': 'description EXT/ILL/784459/DYNAMIC DRILLING AND SERVICES PRIVATE LIMITED/1105784459/ 16 Mbps/New Delhi/Ethernet', 'description': '', 'IP': ''}

please suggest changed

Anna Patil
  • 31
  • 3