dmulyalin / ttp

Template Text Parser
MIT License
350 stars 34 forks source link

How do I match the following configuration using ttp #111

Open bobo-xiaopeng opened 1 year ago

bobo-xiaopeng commented 1 year ago

The following is the information about the bgp neighbors of Huawei routers. It contains nine BGP neighbors. The first neighbor is an Ipv4 unicast neighbor, and the last eight neighbors belong to vpn-instance Chengdu. However, if vpn-instance Chengdu has eight neighbors, how do I match a unicast neighbor with a vpn neighbor? I want to match this structure with TTP.

[{vrf:None,peer:'192.168.1.1',remote-as:'2.9273'}, {vrf:'Chengdu',peer:172.16.0.1,rmore-as:'65237'}, {vrf:'Chengdu',peer:172.16.1.1,rmore-as:'65237'}, {vrf:'Chengdu',peer:172.16.2.1,rmore-as:'65237'}, {vrf:'Chengdu',peer:172.16.3.1,rmore-as:'65237'}, {vrf:'Chengdu',peer:172.16.4.1,rmore-as:'2.9273'}, {vrf:'Chengdu',peer:172.16.5.1,rmore-as:'2.9273'}, {vrf:'Chengdu',peer:172.16.6.1,rmore-as:'2.9273'}, {vrf:'Chengdu',peer:172.16.7.1,rmore-as:'2.9273'}]

` BGP Peer is 192.168.1.1, remote AS 2.9273 Type: EBGP link BGP version 4, Remote router ID 0.0.0.0 Update-group ID: 4 BGP current state: Active BGP current event: TcpFail BGP last state: Connect BGP Peer Up count: 0 Configured: Connect-retry Time: 32 sec Configured: Min Hold Time: 0 sec Received: Total 0 messages Update messages 0 Open messages 0 KeepAlive messages 0 Notification messages 0 Refresh messages 0 Sent: Total 0 messages Update messages 0 Open messages 0 KeepAlive messages 0 Notification messages 0 Refresh messages 0 Authentication type configured: None No keepalive received since peer has been configured No keepalive sent since peer has been configured No update received since peer has been configured No update sent since peer has been configured No refresh received since peer has been configured No refresh sent since peer has been configured Maximum allowed route limit: 20 Threshold: 90%, Parameter: idle-timeout 30 Minimum route advertisement interval is 30 seconds Optional capabilities: Route refresh capability has been enabled 4-byte-as capability has been enabled Send community has been configured Peer's BFD has been enabled Peer Preferred Value: 0 Memory Priority: medium Routing policy configured: No routing policy is configured IPv4-family for VPN instance: Chengdu

     BGP Peer is 172.16.0.1,  remote AS 65237
     Type: EBGP link
     BGP version 4, Remote router ID 61.166.156.7
     Update-group ID: 5
     BGP current state: Established, Up for 402d14h14m32s
     BGP current event: KATimerExpired
     BGP last state: OpenConfirm
     BGP Peer Up count: 1
     Received total routes: 5
     Received active routes total: 5
     Advertised total routes: 2745
     Port: Local - 61540        Remote - 179
     Configured: Connect-retry Time: 32 sec
     Configured: Min Hold Time: 0 sec
     Configured: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Received  : Active Hold Time: 180 sec
     Negotiated: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Peer optional capabilities:
     Peer supports bgp multi-protocol extension
     Peer supports bgp route refresh capability
     Peer supports bgp 4-byte-as capability
     Address family IPv4 Unicast: advertised and received

Received: Total 1430229 messages Update messages 121259 Open messages 1 KeepAlive messages 1308965 Notification messages 0 Refresh messages 4 Sent: Total 1544552 messages Update messages 212698 Open messages 1 KeepAlive messages 1331851 Notification messages 0 Refresh messages 2 Authentication type configured: None Last keepalive received: 2023-06-30 15:16:26+08:00 Last keepalive sent : 2023-06-30 15:16:29+08:00 Last update received: 2023-04-07 04:09:55+08:00 Last update sent : 2023-06-30 13:25:50+08:00 Last refresh received: 2023-04-07 02:32:35+08:00 Last refresh sent : 2023-04-04 10:12:32+08:00 Minimum route advertisement interval is 30 seconds Optional capabilities: Route refresh capability has been enabled 4-byte-as capability has been enabled Send community has been configured Peer's BFD has been enabled Peer Preferred Value: 0 Memory Priority: medium Routing policy configured: No import update filter list No export update filter list No import prefix list No export prefix list Import route policy is: rp_Chengdu_in No export route policy No import distribute policy No export distribute policy Peer soo is: 65110:87100

     BGP Peer is 172.16.1.1,  remote AS 65237
     Type: EBGP link
     BGP version 4, Remote router ID 61.166.156.8
     Update-group ID: 5
     BGP current state: Established, Up for 402d14h14m30s
     BGP current event: KATimerExpired
     BGP last state: OpenConfirm
     BGP Peer Up count: 1
     Received total routes: 5
     Received active routes total: 0
     Advertised total routes: 2745
     Port: Local - 51325        Remote - 179
     Configured: Connect-retry Time: 32 sec
     Configured: Min Hold Time: 0 sec
     Configured: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Received  : Active Hold Time: 180 sec
     Negotiated: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Peer optional capabilities:
     Peer supports bgp multi-protocol extension
     Peer supports bgp route refresh capability
     Peer supports bgp 4-byte-as capability
     Address family IPv4 Unicast: advertised and received

Received: Total 1431004 messages Update messages 121718 Open messages 1 KeepAlive messages 1309283 Notification messages 0 Refresh messages 2 Sent: Total 1544227 messages Update messages 212242 Open messages 1 KeepAlive messages 1331982 Notification messages 0 Refresh messages 2 Authentication type configured: None Last keepalive received: 2023-06-30 15:16:17+08:00 Last keepalive sent : 2023-06-30 15:16:24+08:00 Last update received: 2023-04-07 04:13:05+08:00 Last update sent : 2023-06-30 13:25:50+08:00 Last refresh received: 2023-04-07 02:34:33+08:00 Last refresh sent : 2023-04-04 10:12:32+08:00 Minimum route advertisement interval is 30 seconds Optional capabilities: Route refresh capability has been enabled 4-byte-as capability has been enabled Send community has been configured Peer's BFD has been enabled Peer Preferred Value: 0 Memory Priority: medium Routing policy configured: No import update filter list No export update filter list No import prefix list No export prefix list Import route policy is: rp_Chengdu_in No export route policy No import distribute policy No export distribute policy Peer soo is: 65110:87100

     BGP Peer is 172.16.2.1,  remote AS 65237
     Type: EBGP link
     BGP version 4, Remote router ID 61.166.156.7
     Update-group ID: 5
     BGP current state: Established, Up for 402d14h14m31s
     BGP current event: KATimerExpired
     BGP last state: OpenConfirm
     BGP Peer Up count: 1
     Received total routes: 5
     Received active routes total: 0
     Advertised total routes: 2745
     Port: Local - 63098        Remote - 179
     Configured: Connect-retry Time: 32 sec
     Configured: Min Hold Time: 0 sec
     Configured: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Received  : Active Hold Time: 180 sec
     Negotiated: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Peer optional capabilities:
     Peer supports bgp multi-protocol extension
     Peer supports bgp route refresh capability
     Peer supports bgp 4-byte-as capability
     Address family IPv4 Unicast: advertised and received

Received: Total 1430210 messages Update messages 121195 Open messages 1 KeepAlive messages 1309010 Notification messages 0 Refresh messages 4 Sent: Total 1544726 messages Update messages 212698 Open messages 1 KeepAlive messages 1332025 Notification messages 0 Refresh messages 2 Authentication type configured: None Last keepalive received: 2023-06-30 15:16:24+08:00 Last keepalive sent : 2023-06-30 15:16:32+08:00 Last update received: 2023-04-07 04:09:55+08:00 Last update sent : 2023-06-30 13:25:50+08:00 Last refresh received: 2023-04-07 02:32:35+08:00 Last refresh sent : 2023-04-04 10:12:32+08:00 Minimum route advertisement interval is 30 seconds Optional capabilities: Route refresh capability has been enabled 4-byte-as capability has been enabled Send community has been configured Peer's BFD has been enabled Peer Preferred Value: 0 Memory Priority: medium Routing policy configured: No import update filter list No export update filter list No import prefix list No export prefix list Import route policy is: rp_Chengdu_in No export route policy No import distribute policy No export distribute policy Peer soo is: 65110:87100

     BGP Peer is 172.16.3.1,  remote AS 65237
     Type: EBGP link
     BGP version 4, Remote router ID 61.166.156.8
     Update-group ID: 5
     BGP current state: Established, Up for 189d18h27m22s
     BGP current event: RecvKeepalive
     BGP last state: OpenConfirm
     BGP Peer Up count: 2
     Received total routes: 5
     Received active routes total: 0
     Advertised total routes: 2745
     Port: Local - 62199        Remote - 179
     Configured: Connect-retry Time: 32 sec
     Configured: Min Hold Time: 0 sec
     Configured: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Received  : Active Hold Time: 180 sec
     Negotiated: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Peer optional capabilities:
     Peer supports bgp multi-protocol extension
     Peer supports bgp route refresh capability
     Peer supports bgp 4-byte-as capability
     Address family IPv4 Unicast: advertised and received

Received: Total 716873 messages Update messages 99775 Open messages 1 KeepAlive messages 617095 Notification messages 0 Refresh messages 2 Sent: Total 811865 messages Update messages 184737 Open messages 1 KeepAlive messages 627125 Notification messages 0 Refresh messages 2 Authentication type configured: None Last keepalive received: 2023-06-30 15:16:27+08:00 Last keepalive sent : 2023-06-30 15:16:27+08:00 Last update received: 2023-04-07 04:13:05+08:00 Last update sent : 2023-06-30 13:25:50+08:00 Last refresh received: 2023-04-07 02:34:33+08:00 Last refresh sent : 2023-04-04 10:12:32+08:00 Minimum route advertisement interval is 30 seconds Optional capabilities: Route refresh capability has been enabled 4-byte-as capability has been enabled Send community has been configured Peer's BFD has been enabled Peer Preferred Value: 0 Memory Priority: medium Routing policy configured: No import update filter list No export update filter list No import prefix list No export prefix list Import route policy is: rp_Chengdu_in No export route policy No import distribute policy No export distribute policy Peer soo is: 65110:87100

     BGP Peer is 172.16.4.1,  remote AS 2.9273
     Type: EBGP link
     BGP version 4, Remote router ID 61.166.156.11
     Update-group ID: 5
     BGP current state: Established, Up for 337d12h40m15s
     BGP current event: RecvKeepalive
     BGP last state: OpenConfirm
     BGP Peer Up count: 3
     Received total routes: 2
     Received active routes total: 1
     Advertised total routes: 2745
     Port: Local - 53774        Remote - 179
     Configured: Connect-retry Time: 32 sec
     Configured: Min Hold Time: 0 sec
     Configured: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Received  : Active Hold Time: 90 sec
     Negotiated: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Peer optional capabilities:
     Peer supports bgp multi-protocol extension
     Peer supports bgp route refresh capability
     Peer supports bgp 4-byte-as capability
     Address family IPv4 Unicast: advertised and received

Received: Total 1096736 messages Update messages 2 Open messages 1 KeepAlive messages 1096731 Notification messages 0 Refresh messages 2 Sent: Total 1318679 messages Update messages 202159 Open messages 1 KeepAlive messages 1116519 Notification messages 0 Refresh messages 0 Authentication type configured: None Last keepalive received: 2023-06-30 15:16:36+08:00 Last keepalive sent : 2023-06-30 15:16:34+08:00 Last update received: 2022-07-28 02:37:39+08:00 Last update sent : 2023-06-30 13:25:50+08:00 Last refresh received: 2022-08-18 01:14:40+08:00 No refresh sent since peer has been configured Maximum allowed route limit: 1000 Threshold: 90%, Parameter: idle-timeout 30 Minimum route advertisement interval is 30 seconds Optional capabilities: Route refresh capability has been enabled 4-byte-as capability has been enabled Send community has been configured Peer's BFD has been enabled Peer Preferred Value: 0 Memory Priority: medium Routing policy configured: No import update filter list No export update filter list No import prefix list No export prefix list Import route policy is: rp_Chengdu_in No export route policy No import distribute policy No export distribute policy Peer soo is: 65110:87100

     BGP Peer is 172.16.5.1,  remote AS 2.9273
     Type: EBGP link
     BGP version 4, Remote router ID 61.166.156.11
     Update-group ID: 5
     BGP current state: Established, Up for 337d12h40m11s
     BGP current event: KATimerExpired
     BGP last state: OpenConfirm
     BGP Peer Up count: 3
     Received total routes: 2
     Received active routes total: 0
     Advertised total routes: 2745
     Port: Local - 49882        Remote - 179
     Configured: Connect-retry Time: 32 sec
     Configured: Min Hold Time: 0 sec
     Configured: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Received  : Active Hold Time: 90 sec
     Negotiated: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Peer optional capabilities:
     Peer supports bgp multi-protocol extension
     Peer supports bgp route refresh capability
     Peer supports bgp 4-byte-as capability
     Address family IPv4 Unicast: advertised and received

Received: Total 1096534 messages Update messages 2 Open messages 1 KeepAlive messages 1096529 Notification messages 0 Refresh messages 2 Sent: Total 1318701 messages Update messages 202159 Open messages 1 KeepAlive messages 1116541 Notification messages 0 Refresh messages 0 Authentication type configured: None Last keepalive received: 2023-06-30 15:16:37+08:00 Last keepalive sent : 2023-06-30 15:16:38+08:00 Last update received: 2022-07-28 02:37:43+08:00 Last update sent : 2023-06-30 13:25:50+08:00 Last refresh received: 2022-08-18 01:14:40+08:00 No refresh sent since peer has been configured Maximum allowed route limit: 1000 Threshold: 90%, Parameter: idle-timeout 30 Minimum route advertisement interval is 30 seconds Optional capabilities: Route refresh capability has been enabled 4-byte-as capability has been enabled Send community has been configured Peer's BFD has been enabled Peer Preferred Value: 0 Memory Priority: medium Routing policy configured: No import update filter list No export update filter list No import prefix list No export prefix list Import route policy is: rp_Chengdu_in No export route policy No import distribute policy No export distribute policy Peer soo is: 65110:87100

     BGP Peer is 172.16.6.1,  remote AS 2.9273
     Type: EBGP link
     BGP version 4, Remote router ID 61.166.156.12
     Update-group ID: 5
     BGP current state: Established, Up for 337d12h39m38s
     BGP current event: KATimerExpired
     BGP last state: OpenConfirm
     BGP Peer Up count: 3
     Received total routes: 2
     Received active routes total: 0
     Advertised total routes: 2745
     Port: Local - 51574        Remote - 179
     Configured: Connect-retry Time: 32 sec
     Configured: Min Hold Time: 0 sec
     Configured: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Received  : Active Hold Time: 90 sec
     Negotiated: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Peer optional capabilities:
     Peer supports bgp multi-protocol extension
     Peer supports bgp route refresh capability
     Peer supports bgp 4-byte-as capability
     Address family IPv4 Unicast: advertised and received

Received: Total 1096494 messages Update messages 2 Open messages 1 KeepAlive messages 1096490 Notification messages 0 Refresh messages 1 Sent: Total 1318558 messages Update messages 201962 Open messages 1 KeepAlive messages 1116595 Notification messages 0 Refresh messages 0 Authentication type configured: None Last keepalive received: 2023-06-30 15:16:17+08:00 Last keepalive sent : 2023-06-30 15:16:45+08:00 Last update received: 2022-07-28 02:38:16+08:00 Last update sent : 2023-06-30 13:25:50+08:00 Last refresh received: 2022-08-18 00:09:22+08:00 No refresh sent since peer has been configured Maximum allowed route limit: 1000 Threshold: 90%, Parameter: idle-timeout 30 Minimum route advertisement interval is 30 seconds Optional capabilities: Route refresh capability has been enabled 4-byte-as capability has been enabled Send community has been configured Peer's BFD has been enabled Peer Preferred Value: 0 Memory Priority: medium Routing policy configured: No import update filter list No export update filter list No import prefix list No export prefix list Import route policy is: rp_Chengdu_in No export route policy No import distribute policy No export distribute policy Peer soo is: 65110:87100

     BGP Peer is 172.16.7.1,  remote AS 2.9273
     Type: EBGP link
     BGP version 4, Remote router ID 61.166.156.12
     Update-group ID: 5
     BGP current state: Established, Up for 337d12h39m32s
     BGP current event: RecvKeepalive
     BGP last state: OpenConfirm
     BGP Peer Up count: 3
     Received total routes: 2
     Received active routes total: 0
     Advertised total routes: 2745
     Port: Local - 61056        Remote - 179
     Configured: Connect-retry Time: 32 sec
     Configured: Min Hold Time: 0 sec
     Configured: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Received  : Active Hold Time: 90 sec
     Negotiated: Active Hold Time: 90 sec   Keepalive Time:30 sec
     Peer optional capabilities:
     Peer supports bgp multi-protocol extension
     Peer supports bgp route refresh capability
     Peer supports bgp 4-byte-as capability
     Address family IPv4 Unicast: advertised and received

Received: Total 1096488 messages Update messages 2 Open messages 1 KeepAlive messages 1096484 Notification messages 0 Refresh messages 1 Sent: Total 1318553 messages Update messages 201962 Open messages 1 KeepAlive messages 1116590 Notification messages 0 Refresh messages 0 Authentication type configured: None Last keepalive received: 2023-06-30 15:16:40+08:00 Last keepalive sent : 2023-06-30 15:16:37+08:00 Last update received: 2022-07-28 02:38:22+08:00 Last update sent : 2023-06-30 13:25:50+08:00 Last refresh received: 2022-08-18 00:09:22+08:00 No refresh sent since peer has been configured Maximum allowed route limit: 1000 Threshold: 90%, Parameter: idle-timeout 30 Minimum route advertisement interval is 30 seconds Optional capabilities: Route refresh capability has been enabled 4-byte-as capability has been enabled Send community has been configured Peer's BFD has been enabled Peer Preferred Value: 0 Memory Priority: medium Routing policy configured: No import update filter list No export update filter list No import prefix list No export prefix list Import route policy is: rp_Chengdu_in No export route policy No import distribute policy No export distribute policy`