使用TTP解析器,如何从Nokia设备捕获以下BGP配置中的前缀限制?配置中有两个前缀限制行,一个用于ipv4,另一个用于ipv6;我需要提取这两个行。
neighbor 192.168.102.41
description "blablabla"
authentication-key "hashed-key-here" hash2
prefix-limit ipv4 600 threshold 80
prefix-limit ipv6 601 threshold 81
import "policy-1" "policy-2"
export "policy-3" "policy-4"
graceful-restart
stale-routes-time 360
restart-time 120
enable-notification
exit
peer-as 65510
bfd-enable
exit这是我想出的TTP模板,
<group name="neighbor.{{ neighbor }}">
neighbor {{ neighbor | _start_ }}
family {{ address_family | default("ipv4") }}
description {{ description | ORPHRASE | macro("remove_quot_marks") }}
authentication-key {{ auth_key | macro("remove_quot_marks") }} hash2
prefix-limit {{ family }} {{ prefix_limit }} threshold {{ threshold }}
peer-as {{ peer_AS_number }}
import {{ import_policy | ORPHRASE | macro("extract_import_export_policy") }}
export {{ export_policy | ORPHRASE | macro("extract_import_export_policy") }}
bfd-enable {{ bfd_enabled | set("enabled") }}
exit {{ _end_ }}
</group>这只提取了ipv4的配置;忽略了ipv6的配置。我试图将上面模板中的前缀限制行替换为以下两行,
prefix-limit ipv4 {{ ipv4_prefix_limit }} threshold {{ ipv4_threshold }}
prefix-limit ipv6 {{ ipv6_prefix_limit }} threshold {{ ipv6_threshold }}这也只提取了ipv4的配置;而ipv6的配置则被完全取消。
但是,如果我的TTP模板只有如下所示的一行,那么我可以扩展ipv4和ipv6的配置,
prefix-limit {{ family }} {{ prefix_limit }} threshold {{ threshold }}下面是使用上述模板解析的数据,
[
{
"family": "ipv4",
"prefix_limit": "600",
"threshold": "80"
},
{
"family": "ipv6",
"prefix_limit": "601",
"threshold": "81"
}
]我如何使它与其他信任一起工作,比如在我的第一个TTP模板中?
谢谢你,哈利
发布于 2022-04-15 14:46:55
回答我自己的问题,下面的TTP模板适用于我问题中的示例配置。(刚才我的脑子肯定在别的地方)
<group name="neighbor.{{ neighbor }}">
neighbor {{ neighbor | _start_ }}
family {{ address_family | default("ipv4") }}
description {{ description | ORPHRASE | macro("remove_quot_marks") }}
authentication-key {{ auth_key | macro("remove_quot_marks") }} hash2
<group name="prefix_limit.{{family}}">
prefix-limit {{ family }} {{ prefix_limit }} threshold {{ threshold }}
</group>
peer-as {{ peer_AS_number }}
import {{ import_policy | ORPHRASE | macro("extract_import_export_policy") }}
export {{ export_policy | ORPHRASE | macro("extract_import_export_policy") }}
bfd-enable {{ bfd_enabled | set("enabled") }}
exit {{ _end_ }}
</group>https://stackoverflow.com/questions/71885136
复制相似问题