Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xp15417788 opened this issue Aug 12, 2024 · 0 comments
Open

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

xp15417788 opened this issue Aug 12, 2024 · 0 comments

Comments

@xp15417788
Copy link

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": ""
  }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant