{% import "ios.bgp-macro.j2" as bgpcfg %}
!
router bgp {{ bgp.as }}
{% for vname,vdata in vrfs.items() %}
 address-family ipv4 vrf {{ vname }}
  redistribute connected
{% if 'ospf' in vdata %}
  redistribute ospf {{ vdata.vrfidx }}
{% endif %}
{%   for n in vdata.bgp.neighbors|default([]) %}
{%     for af in ['ipv4','ipv6'] if n[af] is defined %}
{{       bgpcfg.neighbor_global(n,n[af]) }}
{{       bgpcfg.neighbor_af(n,n[af],bgp) }}
{%     endfor %}
{%   endfor %}
{% endfor %}
