protocols {
  delete: isis;
}
protocols {
  isis {
{% if 'ipv6' in isis.af %}
    topologies {
      ipv6-unicast;
    }
{% endif %}
    interface lo0.0;
{% for l in interfaces|default([]) if 'isis' in l %}
    interface {{ l.ifname }} {
{%   if l.isis.network_type is defined %}
      {{ l.isis.network_type }};
{%   endif %}
{%   if l.isis.passive %}
      passive;
{%   endif %}
{%   if l.isis.bfd.ipv4|default(False) %}
        family inet {
          bfd-liveness-detection {
            minimum-receive-interval {{ l.bfd.min_rx|default(bfd.min_rx)|default(500) }};
            multiplier {{ l.bfd.multiplier|default(bfd.multiplier)|default(3) }};
            transmit-interval {
              minimum-interval {{ l.bfd.min_tx|default(bfd.min_tx)|default(500) }};
            }
          }
        }
{%   endif %}
{%   if l.isis.bfd.ipv6|default(False) %}
        family inet6 {
          bfd-liveness-detection {
            minimum-receive-interval {{ l.bfd.min_rx|default(bfd.min_rx)|default(500) }};
            multiplier {{ l.bfd.multiplier|default(bfd.multiplier)|default(3) }};
            transmit-interval {
              minimum-interval {{ l.bfd.min_tx|default(bfd.min_tx)|default(500) }};
            }
          }
        }
{%   endif %}
{%   if l.isis.metric is defined or l.isis.cost is defined %}
      level 1 metric {{ l.isis.metric|default(l.isis.cost) }};
      level 2 metric {{ l.isis.metric|default(l.isis.cost) }};
{%     if 'ipv6' in isis.af and 'ipv6' in l %}
      level 1 ipv6-unicast-metric {{ l.isis.metric|default(l.isis.cost) }};
      level 2 ipv6-unicast-metric {{ l.isis.metric|default(l.isis.cost) }};
{%     endif %}
{%   endif %}
    }
{% endfor %}
  }
}
security {
  forwarding-options {
    family {
      iso {
        mode packet-based;
      }
    }
  }
}

interfaces {
  lo0 {
    unit 0 {
      family iso {
{% if isis.net is defined %}
        address {{ isis.net }}
{% elif isis.area is defined %}
        address {{ "%s.0000.0000.%04d.00" % (isis.area,id) }}
{% endif %}
      }
    }
  }
{% for l in interfaces|default([]) if 'isis' in l %}
  {{ l.ifname }} {
    unit 0 {
      family iso;
    }
  }
{% endfor %}
}
