I'm using python ttp parser to parse network device configuration file. For example, I have the following text content of a vprn service ( the indentation of the first line is 8 blank-space characters ):
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
When I create the ttp template, I have to have the exact same indentation to match the line in the config data, link the following:
<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 | _start_ }}" create
description "{{ description | ORPHRASE }}"
address {{ ipv4_address }}/{{ipv4_mask}}
ip-mtu {{ ip_mtu }}
exit {{ _end_ }}
</group>
service-name "{{ service_name }}"
no shutdown {{ state | set("enabled") | default("disabled") }}
exit {{ _end_ }}
</group>
In the config file, if I remove 4 blank-space characters from the beginning of each line, then I will have to make similar change to the template, otherwise the parsed output will be empty.
Is there some settings in the parser that would allow me to use the same template for config data with different indentation size?
Thanks