# AllowAS-IN
{% for n in bgp.neighbors if n.allowas_in is defined %}
{%   for af in ['ipv4','ipv6'] if n[af] is defined %}
/routing/bgp/connection set [/routing/bgp/connection find remote.address={{ n[af] }} and templates=default] input.allow-as={{ n.allowas_in }}
{%   endfor %}
{% endfor %}

{% if vrfs is defined %}
{% for vname,vdata in vrfs.items() if vdata.bgp is defined %}
{%   for n in vdata.bgp.neighbors|default([]) if n.allowas_in is defined %}
{%     for af in ['ipv4','ipv6'] if n[af] is defined and n.allowas_in %}
/routing/bgp/connection set [/routing/bgp/connection find remote.address={{ n[af] }} and templates={{vname}}] input.allow-as={{ n.allowas_in }}
{%     endfor %}
{%   endfor %}
{% endfor %}
{% endif %}

# AS-Override
{% for n in bgp.neighbors if n.as_override is defined %}
{%   for af in ['ipv4','ipv6'] if n[af] is defined %}
/routing/bgp/connection set [/routing/bgp/connection find remote.address={{ n[af] }} and templates=default] as-override=yes
{%   endfor %}
{% endfor %}

{% if vrfs is defined %}
{% for vname,vdata in vrfs.items() if vdata.bgp is defined %}
{%   for n in vdata.bgp.neighbors|default([]) if n.as_override is defined %}
{%     for af in ['ipv4','ipv6'] if n[af] is defined and n.as_override %}
/routing/bgp/connection set [/routing/bgp/connection find remote.address={{ n[af] }} and templates={{vname}}] as-override=yes
{%     endfor %}
{%   endfor %}
{% endfor %}
{% endif %}

# Default Originate
{% for n in bgp.neighbors if n.default_originate is defined %}
{%   for af in ['ipv4','ipv6'] if n[af] is defined and n.default_originate %}
/routing/bgp/connection set [/routing/bgp/connection find remote.address={{ n[af] }} and templates=default] output.default-originate=always
{%   endfor %}
{% endfor %}

{% if vrfs is defined %}
{% for vname,vdata in vrfs.items() if vdata.bgp is defined %}
{%   for n in vdata.bgp.neighbors|default([]) if n.default_originate is defined %}
{%     for af in ['ipv4','ipv6'] if n[af] is defined and n.default_originate %}
/routing/bgp/connection set [/routing/bgp/connection find remote.address={{ n[af] }} and templates={{vname}}] output.default-originate=always
{%     endfor %}
{%   endfor %}
{% endfor %}
{% endif %}

# Password
{% for n in bgp.neighbors if n.password is defined %}
{%   for af in ['ipv4','ipv6'] if n[af] is defined %}
/routing/bgp/connection set [/routing/bgp/connection find remote.address={{ n[af] }} and templates=default] tcp-md5-key={{ n.password }}
{%   endfor %}
{% endfor %}

{% if vrfs is defined %}
{% for vname,vdata in vrfs.items() if vdata.bgp is defined %}
{%   for n in vdata.bgp.neighbors|default([]) if n.password is defined %}
{%     for af in ['ipv4','ipv6'] if n[af] is defined and n.password %}
/routing/bgp/connection set [/routing/bgp/connection find remote.address={{ n[af] }} and templates={{vname}}] tcp-md5-key={{ n.password }}
{%     endfor %}
{%   endfor %}
{% endfor %}
{% endif %}