'python ttp parser ignore line if I have ORPHRASE in template and consecutive blank spaces in input text
Envorionment: windows 10, python: 3.9, ttp: 0.8.4
I'm having a problem with ORPHRASE in the TTP template, and if there's consecutive blank-space characters in the string the template is supposed to pick up.
Input text:
vprn 5000122 customer 99999 create
description "LastMod: Jan 28, 2022 2:33:11 AM"
vrf-import "VPRN-5000122-IMPORT"
vrf-export "VPRN-5000122-EXPORT"
router-id 95.95.95.95
autonomous-system 5555
route-distinguisher 4444:8888888
auto-bind-tunnel
resolution-filter
ldp
exit
resolution filter
exit
interface "*dummy-1* L3 interface" create
description "*** single blank-space description ***"
address 199.199.199.199/32
exit
interface "*dummy-2* L3 interface" create
description "*** double blank-space description ***"
address 201.201.201.201/32
exit
service-name "dumy-vprn-service"
no shutdown
exit
TTP template:
<group name="service">
<group name="vprn.{{ service_id }}**">
vprn {{service_id | _start_ }} customer {{customer_id}} create
description "{{ description | ORPHRASE | default("")}}"
vrf-import "{{ vrf_import }}"
vrf-export "{{ vrf_export }}"
autonomous-system {{ autonous_system }}
route-distinguisher {{ route_distinguisher }}
<group name="interface.{{interface_id}}**">
interface "{{ interface_id | ORPHRASE | _start_ }}" create
description "{{ description | ORPHRASE }}"
address {{ ipv4_address }}
ip-mtu {{ ip_mtu }}
exit {{ _end_ }}
</group>
service-name "{{ service_name }}"
no shutdown {{ state | set("enabled") | default("disabled") }}
exit {{ _end_ }}
</group>
parsed output:
{
"5000122": {
"route_distinguisher": "4444:8888888",
"autonous_system": "5555",
"vrf_export": "VPRN-5000122-EXPORT",
"vrf_import": "VPRN-5000122-IMPORT",
"description": "LastMod: Jan 28, 2022 2:33:11 AM",
"customer_id": "99999",
"state": "enabled",
"interface": {
"*dummy-1* L3 interface": {
"ipv4_address": "199.199.199.199/32",
"description": "*** single blank-space description ***"
},
"*dummy-2* L3 interface": {
"ipv4_address": "201.201.201.201/32"
}
},
"service_name": "dumy-vprn-service"
}
}
Problem: The description line in the second interface is not picked up by the parser, because the consecutive blank-space characters in the string
Solution 1:[1]
you can use line instead of ORPHRASE (line with underscore both at the start and end)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ibsa |