'''
python
import re
data=[]
result=[]
vpn_instance=re.compile(r" VPN-Instance (AAA_\w+), Router ID \d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}:")
peer_v4=re.compile(r" (\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}).*")
peer_v6=re.compile(r" (2001:2001:\S+)\s+\d")
with open("1.txt","r") as f:
lines=f.readlines()
for line in lines:
# print(vpn_instance.findall(line))
if vpn_instance.findall(line) != []:
data=[]
if vpn_instance.findall(line) != []:
data.append(re.findall(vpn_instance,line)[0])
elif "45164" in line and "." in line:
data.append(re.findall(peer_v4,line)[0])
result.append(("display bgp vpnv4 vpn-instance %s routing-table peer %s" % (data[0],data[1])))
elif "45164" in line and ":" in line:
data.append(re.findall(peer_v6,line)[0])
result.append(("display bgp vpnv6 vpn-instance %s routing-table peer %s" % (data[0],data[1])))
with open("result.txt","w") as f2:
f2.write("scr 0 t"+"\n")
for i in range(len(result)):
f2.write((result)[i]+" ad"+"\n")
VPN-Instance AAA_ZJ, Router ID 58.247.59.128:
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
58.247.59.250 4 65007 84668 84343 0 1256h40m Established 1
58.247.73.18 4 45164 930897 792157 0 ****h29m Established 0
Peer of IPv6-family for vpn instance :
VPN-Instance AAA_Gn, Router ID 58.255.64.5:
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
2001:2001:934:87F1:301::1 4 45164 853915 792829 0 ****h29m Established 8
2001:2001:934:87F1:301::301 4 65007 84788 84493 0 1256h38m Established 60
'''