{% if prefix_list is defined and prefix_list is not none %}
{% for prefix_list, prefix_list_config in prefix_list.items() | natural_sort %}
{% if prefix_list_config.description is defined and prefix_list_config.description is not none %}
ip prefix-list {{ prefix_list }} description {{ prefix_list_config.description }}
{% endif %}
{% if prefix_list_config.rule is defined and prefix_list_config.rule is not none %}
{% for rule, rule_config in prefix_list_config.rule.items() | natural_sort %}
{% if rule_config.prefix is defined and rule_config.prefix is not none %}
ip prefix-list {{ prefix_list }} seq {{ rule }} {{ rule_config.action }} {{ rule_config.prefix }} {{ 'ge ' + rule_config.ge if rule_config.ge is defined }} {{ 'le ' + rule_config.le if rule_config.le is defined }}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
!
{% if prefix_list6 is defined and prefix_list6 is not none %}
{% for prefix_list, prefix_list_config in prefix_list6.items() | natural_sort %}
{% if prefix_list_config.description is defined and prefix_list_config.description is not none %}
{% if rule_config.call is defined and rule_config.call is not none %}
call {{ rule_config.call }}
{% endif %}
{% if rule_config.continue is defined and rule_config.continue is not none %}
on-match goto {{ rule_config.continue }}
{% endif %}
{% if rule_config.description is defined and rule_config.description is not none %}
description {{ rule_config.description }}
{% endif %}
{% if rule_config.match is defined and rule_config.match is not none %}
{% if rule_config.match.as_path is defined and rule_config.match.as_path is not none %}
match as-path {{ rule_config.match.as_path }}
{% endif %}
{% if rule_config.match.community is defined and rule_config.match.community.community_list is defined and rule_config.match.community.community_list is not none %}
match community {{ rule_config.match.community.community_list }} {{ 'exact-match' if rule_config.match.community.exact_match is defined }}
{% endif %}
{% if rule_config.match.extcommunity is defined and rule_config.match.extcommunity is not none %}
match extcommunity {{ rule_config.match.extcommunity }}
{% endif %}
{% if rule_config.match.interface is defined and rule_config.match.interface is not none %}
match interface {{ rule_config.match.interface }}
{% endif %}
{% if rule_config.match.ip is defined and rule_config.match.ip.address is defined and rule_config.match.ip.address.access_list is defined and rule_config.match.ip.address.access_list is not none %}
match ip address {{ rule_config.match.ip.address.access_list }}
{% endif %}
{% if rule_config.match.ip is defined and rule_config.match.ip.address is defined and rule_config.match.ip.address.prefix_list is defined and rule_config.match.ip.address.prefix_list is not none %}
match ip address prefix-list {{ rule_config.match.ip.address.prefix_list }}
{% endif %}
{% if rule_config.match.ip is defined and rule_config.match.ip.nexthop is defined and rule_config.match.ip.nexthop.access_list is defined and rule_config.match.ip.nexthop.access_list is not none %}
match ip next-hop {{ rule_config.match.ip.nexthop.access_list }}
{% endif %}
{% if rule_config.match.ip is defined and rule_config.match.ip.nexthop is defined and rule_config.match.ip.nexthop.prefix_list is defined and rule_config.match.ip.nexthop.prefix_list is not none %}
match ip next-hop prefix-list {{ rule_config.match.ip.nexthop.prefix_list }}
{% endif %}
{% if rule_config.match.ip is defined and rule_config.match.ip.route_source is defined and rule_config.match.ip.route_source.access_list is defined and rule_config.match.ip.route_source.access_list is not none %}
match ip route-source {{ rule_config.match.ip.route_source.access_list }}
{% endif %}
{% if rule_config.match.ip is defined and rule_config.match.ip.route_source is defined and rule_config.match.ip.route_source.prefix_list is defined and rule_config.match.ip.route_source.prefix_list is not none %}
match ip route-source prefix-list {{ rule_config.match.ip.route_source.prefix_list }}
{% endif %}
{% if rule_config.match.ipv6 is defined and rule_config.match.ipv6.address is defined and rule_config.match.ipv6.address.access_list is defined and rule_config.match.ipv6.address.access_list is not none %}
match ipv6 address {{ rule_config.match.ipv6.address.access_list }}
{% endif %}
{% if rule_config.match.ipv6 is defined and rule_config.match.ipv6.address is defined and rule_config.match.ipv6.address.prefix_list is defined and rule_config.match.ipv6.address.prefix_list is not none %}
match ipv6 address prefix-list {{ rule_config.match.ipv6.address.prefix_list }}
{% endif %}
{% if rule_config.match.ipv6 is defined and rule_config.match.ipv6.nexthop is defined and rule_config.match.ipv6.nexthop is not none %}
match ipv6 next-hop {{ rule_config.match.ipv6.nexthop }}
{% endif %}
{% if rule_config.match.large_community is defined and rule_config.match.large_community.large_community_list is defined and rule_config.match.large_community.large_community_list is not none %}
match large-community {{ rule_config.match.large_community.large_community_list }}
{% endif %}
{% if rule_config.match.local_preference is defined and rule_config.match.local_preference is not none %}
match local-preference {{ rule_config.match.local_preference }}
{% endif %}
{% if rule_config.match.metric is defined and rule_config.match.metric is not none %}
match metric {{ rule_config.match.metric }}
{% endif %}
{% if rule_config.match.origin is defined and rule_config.match.origin is not none %}
match origin {{ rule_config.match.origin }}
{% endif %}
{% if rule_config.match.peer is defined and rule_config.match.peer is not none %}
match peer {{ rule_config.match.peer }}
{% endif %}
{% if rule_config.match.rpki is defined and rule_config.match.rpki is not none %}
match rpki {{ rule_config.match.rpki }}
{% endif %}
{% if rule_config.match.tag is defined and rule_config.match.tag is not none %}
match tag {{ rule_config.match.tag }}
{% endif %}
{% endif %}
{% if rule_config.on_match is defined and rule_config.on_match is not none %}
{% if rule_config.on_match.next is defined %}
on-match next
{% endif %}
{% if rule_config.on_match.goto is defined and rule_config.on_match.goto is not none %}
on-match goto {{ rule_config.on_match.goto }}
{% endif %}
{% endif %}
{% if rule_config.set is defined and rule_config.set is not none %}
{% if rule_config.set.aggregator is defined and rule_config.set.aggregator.as is defined and rule_config.set.aggregator.ip is defined %}
set aggregator as {{ rule_config.set.aggregator.as }} {{ rule_config.set.aggregator.ip }}
{% endif %}
{% if rule_config.set.as_path_exclude is defined and rule_config.set.as_path_exclude is not none %}
set as-path exclude {{ rule_config.set.as_path_exclude }}
{% endif %}
{% if rule_config.set.as_path_prepend is defined and rule_config.set.as_path_prepend is not none %}
set as-path prepend {{ rule_config.set.as_path_prepend }}
{% endif %}
{% if rule_config.set.atomic_aggregate is defined %}
set atomic-aggregate
{% endif %}
{% if rule_config.set.comm_list is defined and rule_config.set.comm_list.comm_list is defined and rule_config.set.comm_list.comm_list is not none %}
set comm-list {{ rule_config.set.comm_list.comm_list }} {{ 'delete' if rule_config.set.comm_list.delete is defined }}
{% endif %}
{% if rule_config.set.community is defined and rule_config.set.community is not none %}
set community {{ rule_config.set.community }}
{% endif %}
{% if rule_config.set.distance is defined and rule_config.set.distance is not none %}
set distance {{ rule_config.set.distance }}
{% endif %}
{% if rule_config.set.extcommunity_rt is defined and rule_config.set.extcommunity_rt is not none %}
set extcommunity rt {{ rule_config.set.extcommunity_rt }}
{% endif %}
{% if rule_config.set.extcommunity_soo is defined and rule_config.set.extcommunity_soo is not none %}
set extcommunity soo {{ rule_config.set.extcommunity_soo }}
{% endif %}
{% if rule_config.set.ip_next_hop is defined and rule_config.set.ip_next_hop is not none %}
set ip next-hop {{ rule_config.set.ip_next_hop }}
{% endif %}
{% if rule_config.set.ipv6_next_hop is defined and rule_config.set.ipv6_next_hop.global is defined and rule_config.set.ipv6_next_hop.global is not none %}
set ipv6 next-hop global {{ rule_config.set.ipv6_next_hop.global }}
{% endif %}
{% if rule_config.set.ipv6_next_hop is defined and rule_config.set.ipv6_next_hop.local is defined and rule_config.set.ipv6_next_hop.local is not none %}
set ipv6 next-hop local {{ rule_config.set.ipv6_next_hop.local }}
{% endif %}
{% if rule_config.set.large_community is defined and rule_config.set.large_community is not none %}
set large-community {{ rule_config.set.large_community }}
{% endif %}
{% if rule_config.set.local_preference is defined and rule_config.set.local_preference is not none %}
set local-preference {{ rule_config.set.local_preference }}
{% endif %}
{% if rule_config.set.metric is defined and rule_config.set.metric is not none %}
set metric {{ rule_config.set.metric }}
{% endif %}
{% if rule_config.set.metric_type is defined and rule_config.set.metric_type is not none %}
set metric-type {{ rule_config.set.metric_type }}
{% endif %}
{% if rule_config.set.origin is defined and rule_config.set.origin is not none %}
set origin {{ rule_config.set.origin }}
{% endif %}
{% if rule_config.set.originator_id is defined and rule_config.set.originator_id is not none %}
set originator-id {{ rule_config.set.originator_id }}
{% endif %}
{% if rule_config.set.src is defined and rule_config.set.src is not none %}
set src {{ rule_config.set.src }}
{% endif %}
{% if rule_config.set.table is defined and rule_config.set.table is not none %}
set table {{ rule_config.set.table }}
{% endif %}
{% if rule_config.set.tag is defined and rule_config.set.tag is not none %}
set tag {{ rule_config.set.tag }}
{% endif %}
{% if rule_config.set.weight is defined and rule_config.set.weight is not none %}