google / google/textfsm

In templates, does the Value have the Fillup option by default?

Open
#126 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
1.2k
Forks
194
PR merge metrics
No merged PRs in 30d

Description

i want to use the template below to parse a multiline commands, but i find Value like "protocol" and "vpn_instance" be filledup by default, how can i avoid it and retrieve the correct empty value? It feels strange, but i have no idea, I would appreciate some advice.

template is below,
```
Value Filldown acl_name ((\S+|\d+))
Value Filldown description (\S+(\s+\S+)*)
Value Required rule_num (\d+)
Value Required action (permit|deny)
Value protocol (ip|tcp|udp)
Value vpn_instance (\S+)
Value source_ip ((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|any)
Value source_wildcard ((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|0)
Value source_port ((eq|ge|le) (\S+|\d+))
Value dest_ip ((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|any)
Value dest_wildcard ((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|0)
Value dest_port ((eq|ge|le) (\S+|\d+))
Value dscp (\d+)
Value counting (counting)
Value List NotParsed (.*)

Start
^acl number ${acl_name}
^\s+description ${description}
^\s+rule ${rule_num} ${action}( ${protocol})*( vpn-instance ${vpn_instance})*( source ${source_ip}( ${source_wildcard})*)*( destination-port ${dest_port})*( ${counting})* -> Record
^\s+${NotParsed}
^# -> Record
```

raw command output is here,

```
acl number 2000
description for-nms-vty
rule 5 permit source 172.16.0.0 0.15.255.255
rule 10 permit source 192.168.0.0 0.0.255.255
rule 20 permit vpn-instance IBMGT source 172.16.0.0 0.15.255.255
rule 35 permit source 1.1.1.0 0.0.0.127
rule 45 permit vpn-instance IBMGT source 192.168.0.0 0.0.255.255
rule 1000 deny
#
acl number 3333
description dhcp request
rule 5 permit udp destination 10.81.40.4 0 destination-port eq bootpc counting
rule 10 permit udp destination-port eq bootpc counting
#
acl number 3334
description dhcp reply
rule 5 permit udp source 10.81.40.4 0 destination-port eq bootps counting
#
```

the result returned ,
```
[
{
"acl_name": "2000",
"action": "permit",
"counting": "counting",
"description": "for-nms-vty",
"dest_ip": "",
"dest_port": "eq bootpc",
"dest_wildcard": "",
"dscp": "",
"protocol": "udp",
"rule_num": "5",
"source_ip": "172.16.0.0",
"source_port": "",
"source_wildcard": "0.15.255.255",
"vpn_instance": "IBMGT"
},
{
"acl_name": "2000",
"action": "permit",
"counting": "counting",
"description": "for-nms-vty",
"dest_ip": "",
"dest_port": "eq bootpc",
"dest_wildcard": "",
"dscp": "",
"protocol": "udp",
"rule_num": "10",
"source_ip": "192.168.0.0",
"source_port": "",
"source_wildcard": "0.0.255.255",
"vpn_instance": "IBMGT"
},
{
"acl_name": "2000",
"action": "permit",
"counting": "counting",
"description": "for-nms-vty",
"dest_ip": "",
"dest_port": "eq bootpc",
"dest_wildcard": "",
"dscp": "",
"protocol": "udp",
"rule_num": "15",
"source_ip": "10.0.0.0",
"source_port": "",
"source_wildcard": "0.255.255.255",
"vpn_instance": "IBMGT"
},
{
"acl_name": "2000",
"action": "permit",
"counting": "counting",
"description": "for-nms-vty",
"dest_ip": "",
"dest_port": "eq bootpc",
"dest_wildcard": "",
"dscp": "",
"protocol": "udp",
"rule_num": "20",
"source_ip": "172.16.0.0",
"source_port": "",
"source_wildcard": "0.15.255.255",
"vpn_instance": "IBMGT"
},
{
"acl_name": "2000",
"action": "permit",
"counting": "counting",
"description": "for-nms-vty",
"dest_ip": "",
"dest_port": "eq bootpc",
"dest_wildcard": "",
"dscp": "",
"protocol": "udp",
"rule_num": "25",
"source_ip": "192.168.0.0",
"source_port": "",
"source_wildcard": "0.0.255.255",
"vpn_instance": "IBMGT"
},
{
"acl_name": "2000",
"action": "permit",
"counting": "counting",
"description": "for-nms-vty",
"dest_ip": "",
"dest_port": "eq bootpc",
"dest_wildcard": "",
"dscp": "",
"protocol": "udp",
"rule_num": "30",
"source_ip": "10.0.0.0",
"source_port": "",
"source_wildcard": "0.255.255.255",
"vpn_instance": "IBMGT"
},
{
"acl_name": "2000",
"action": "permit",
"counting": "counting",
"description": "for-nms-vty",
"dest_ip": "",
"dest_port": "eq bootpc",
"dest_wildcard": "",
"dscp": "",
"protocol": "udp",
"rule_num": "35",
"source_ip": "106.75.220.0",
"source_port": "",
"source_wildcard": "0.0.0.127",
"vpn_instance": "IBMGT"
},
{
"acl_name": "2000",
"action": "permit",
"counting": "counting",
"description": "for-nms-vty",
"dest_ip": "",
"dest_port": "eq bootpc",
"dest_wildcard": "",
"dscp": "",
"protocol": "udp",
"rule_num": "40",
"source_ip": "100.96.0.0",
"source_port": "",
"source_wildcard": "0.31.255.255",
"vpn_instance": "IBMGT"
},
{
"acl_name": "2000",
"action": "permit",
"counting": "counting",
"description": "for-nms-vty",
"dest_ip": "",
"dest_port": "eq bootpc",
"dest_wildcard": "",
"dscp": "",
"protocol": "udp",
"rule_num": "45",
"source_ip": "100.96.0.0",
"source_port": "",
"source_wildcard": "0.31.255.255",
"vpn_instance": "IBMGT"
},
{
"acl_name": "2000",
"action": "deny",
"counting": "counting",
"description": "for-nms-vty",
"dest_ip": "",
"dest_port": "eq bootpc",
"dest_wildcard": "",
"dscp": "",
"protocol": "udp",
"rule_num": "1000",
"source_ip": "10.81.40.4",
"source_port": "",
"source_wildcard": "0",
"vpn_instance": ""
},
{
"acl_name": "3333",
"action": "permit",
"counting": "counting",
"description": "dhcp request",
"dest_ip": "",
"dest_port": "eq bootpc",
"dest_wildcard": "",
"dscp": "",
"protocol": "udp",
"rule_num": "5",
"source_ip": "10.81.40.4",
"source_port": "",
"source_wildcard": "0",
"vpn_instance": ""
},
{
"acl_name": "3333",
"action": "permit",
"counting": "counting",
"description": "dhcp request",
"dest_ip": "",
"dest_port": "eq bootpc",
"dest_wildcard": "",
"dscp": "",
"protocol": "udp",
"rule_num": "10",
"source_ip": "10.81.40.4",
"source_port": "",
"source_wildcard": "0",
"vpn_instance": ""
},
{
"acl_name": "3334",
"action": "permit",
"counting": "counting",
"description": "dhcp reply",
"dest_ip": "",
"dest_port": "eq bootps",
"dest_wildcard": "",
"dscp": "",
"protocol": "udp",
"rule_num": "5",
"source_ip": "10.81.40.4",
"source_port": "",
"source_wildcard": "0",
"vpn_instance": ""
}
]
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.