{% load i18n sizeformat %}
{% load url from future %}

<div class="detail">
  <dl class="dl-horizontal">
    <dt>{% trans "Name" %}</dt>
    <dd>{{ port.name|default:_("None") }}</dd>
    <dt>{% trans "ID" %}</dt>
    <dd>{{ port.id|default:_("None") }}</dd>
    {% url 'horizon:project:networks:detail' port.network_id as network_url %}
    <dt>{% trans "Network ID" %}</dt>
    <dd><a href="{{ network_url }}">{{ port.network_id|default:_("None") }}</a></dd>
    <dt>{% trans "Project ID" %}</dt>
    <dd>{{ port.tenant_id|default:_("-") }}</dd>
    <dt>{% trans "MAC Address" %}</dt>
    <dd>{{ port.mac_address|default:_("None") }}</dd>
    <dt>{% trans "Status" %}</dt>
    <dd>{{ port.status_label|default:_("None") }}</dd>
    <dt>{% trans "Admin State" %}</dt>
    <dd>{{ port.admin_state_label|default:_("None") }}</dd>
    {% if port.mac_state %}
    <dt>{% trans "MAC Learning State" %}</dt>
    <dd>{% trans "On" %}</dd>
    {% endif %}
    <h4>{% trans "Fixed IP" %}</h4>
    <hr class="header_rule">
    {% if port.fixed_ips.items|length > 1 %}
      {% for ip in port.fixed_ips %}
      <dt>{% trans "IP Address" %}</dt>
      <dd>{{ ip.ip_address }}</dd>
      {% url 'horizon:project:networks:subnets:detail' ip.subnet_id as subnet_url %}
      <dt>{% trans "Subnet ID" %}</dt>
      <dd><a href="{{ subnet_url }}">{{ ip.subnet_id }}</a></dd>
      {% endfor %}
    {% else %}
      <dd>{% trans "None" %}</dd>
    {% endif %}
    <h4>{% trans "Attached Device" %}</h4>
    <hr class="header_rule">
    {% if port.device_id|length > 1 or port.device_owner %}
      <dt>{% trans "Device Owner" %}</dt>
      <dd>{{ port.device_owner|default:_("None") }}</dd>
      <dt>{% trans "Device ID" %}</dt>
      <dd>{{ port.device_id|default:_("None") }}</dd>
    {% else %}
      <dd>{% trans "No attached device" %}</dd>
    {% endif %}
    <h4>{% trans "Binding" %}</h4>
    <hr class="header_rule">
    <dt>{% trans "Host" %}</dt>
    <dd>{{ port.binding__host_id|default:_("None") }}</dd>
    <dt>{% trans "Profile" %}</dt>
    <dd>{{ port.binding__profile|default:_("None") }}</dd>
    <dt>{% trans "VIF Type" %}</dt>
    <dd>{{ port.binding__vif_type|replace_underscores }}</dd>
    <dt>{% trans "VIF Details" %}</dt>
    {% if port.binding__vif_details.items %}
      <dd>
        <ul>
        {% for key,value in port.binding__vif_details.items %}
        <li><b>{{ key }}</b> {{ value }}</li>
        {% endfor %}
        </ul>
      </dd>
    {% else %}
      <dd>{% trans "None" %}</dd>
    {% endif %}
    {% if port.binding__vnic_type %}
      <dt>{% trans "VNIC Type" %}</dt>
      <dd>{{ port.binding__vnic_type }}</dd>
    {% endif %}
  </dl>
</div>
