{% load i18n sizeformat %}

<div class="detail">
  <dl class="dl-horizontal">
    <dt>{% trans "Name" %}</dt>
    <dd data-display="{{ instance.name|default:instance.id }}" class="word-wrap">{{ instance.name }}</dd>
    <dt>{% trans "ID" %}</dt>
    <dd>{{ instance.id }}</dd>
    <dt>{% trans "Description" %}</dt>
    <dd>{{ instance.description|default:_("-") }}</dd>
    <dt>{% trans "Project ID" %}</dt>
    <dd>{{ instance.tenant_id|default:_("-") }}</dd>
    <dt>{% trans "Status" %}</dt>
    <dd>{{ instance.status_label|title }}</dd>
    {% if instance.locked != None %}
    <dt>{% trans "Locked" context "Locked status of an instance" %}</dt>
    <dd>{{ instance.locked }}</dd>
    {% endif %}
    <dt>{% trans "Availability Zone" %}</dt>
    <dd>{{ instance.availability_zone|default:_("-") }}</dd>
    <dt>{% trans "Created" %}</dt>
    <dd>{{ instance.created|parse_isotime }}</dd>
    <dt>{% trans "Age" %}</dt>
    <dd>{{ instance.created|parse_isotime|timesince }}</dd>
    {% if instance.has_extended_attrs %}
      <dt>{% trans "Host" %}</dt>
      <dd>{{ instance.host_server|default:_("-") }}</dd>
      <dt>{% trans "Instance Name" %}</dt>
      <dd>{{ instance.instance_name|default:_("-") }}</dd>
      <dt>{% trans "Reservation ID" %}</dt>
      <dd>{{ instance.reservation_id|default:_("-") }}</dd>
      <dt>{% trans "Launch Index" %}</dt>
      <dd>{{ instance.launch_index|default:_("-") }}</dd>
      <dt>{% trans "Hostname" %}</dt>
      <dd>{{ instance.hostname|default:_("-") }}</dd>
      <dt>{% trans "Kernel ID" %}</dt>
      <dd>{{ instance.kernel_id|default:_("-") }}</dd>
      <dt>{% trans "Ramdisk ID" %}</dt>
      <dd>{{ instance.ramdisk_id|default:_("-") }}</dd>
      <dt>{% trans "Device Name" %}</dt>
      <dd>{{ instance.root_device_name|default:_("-") }}</dd>
      <dt>{% trans "User Data" %}</dt>
      <dd>{{ instance.user_data|default:_("-") }}</dd>
    {% endif %}
  </dl>

  {% if instance.fault %}
    <h4>{% trans "Fault" %}</h4>
    <hr class="header_rule">
    <dl class="dl-horizontal">
      <dt>{% trans "Message" %}</dt>
      <dd>{{ instance.fault.message }}</dd>
      <dt>{% trans "Code" %}</dt>
      <dd>{{ instance.fault.code }}</dd>
      <dt>{% trans "Details" %}</dt>
      <dd>{{ instance.fault.details }}</dd>
      <dt>{% trans "Created" %}</dt>
      <dd>{{ instance.fault.created|parse_isotime }}</dd>
    </dl>
  {% endif %}

  <h4>{% trans "Specs" %}</h4>
  <hr class="header_rule">
  <dl class="dl-horizontal">
    {% if instance.full_flavor %}
      <dt>{% trans "Flavor Name" %}</dt>
      <dd class="word-wrap">{{ instance.full_flavor.name }}</dd>
      <dt>{% trans "Flavor ID" %}</dt>
      <dd>{{ instance.full_flavor.id }}</dd>
      <dt>{% trans "RAM" %}</dt>
      <dd>{{ instance.full_flavor.ram|mb_float_format }}</dd>
      <dt>{% trans "VCPUs" %}</dt>
      <dd>{{ instance.full_flavor.vcpus }} {% trans "VCPU" %}</dd>
      <dt>{% trans "Disk" %}</dt>
      <dd>{{ instance.full_flavor.disk }}{% trans "GB" %}</dd>
      {% if instance.full_flavor.ephemeral %}
        <dt>{% trans "Ephemeral Disk" %}</dt>
        <dd>{{ instance.full_flavor.ephemeral }}{% trans "GB" %}</dd>
      {% endif %}
    {% else %}
      <dt>{% trans "Flavor" %}</dt>
      <dd>{% trans "Not available" %}</dd>
    {% endif %}
  </dl>

    <h4>{% trans "IP Addresses" %}</h4>
    <hr class="header_rule">
    <dl class="dl-horizontal">
      {% for network, ip_list in instance.addresses.items %}
        <dt>{{ network }}</dt>
        <dd>
          {% if ip_list|length > 0 %}
            {% for ip in ip_list %}
              {% if not forloop.last %}
                {{ ip.addr }},&nbsp;
              {% else %}
                {{ ip.addr }}
              {% endif %}
            {% endfor %}
          {% else %}
            {% trans "(No IP address)" %}
          {% endif %}
        </dd>
      {% endfor %}
    </dl>

    <h4>{% trans "Security Groups" %}</h4>
    <hr class="header_rule">
    <dl class="dl-horizontal">
      {% for group in instance.security_groups %}
        <dt class="word-wrap">{{ group.name }}</dt>
        <dd>
          <ul class="list-unstyled">
          {% for rule in group.rules %}
            <li>{{ rule }}</li>
            {% empty %}
            <li><em>{% trans "No rules defined." %}</em></li>
          {% endfor %}
          </ul>
        </dd>
        {% empty %}
        {% trans "Not available" %}
      {% endfor %}
    </dl>

    <h4>{% trans "Metadata" %}</h4>
    <hr class="header_rule">
    <dl class="dl-horizontal">
      <dt>{% trans "Key Name" %}</dt>
      {% trans "None" as default_key_name %}
      {% with formatted_default_key_name="<em>"|add:default_key_name|add:"</em>" %}
        <dd class="word-wrap">{{ instance.key_name|default:formatted_default_key_name }}</dd>
      {% endwith %}
      {% if instance.image %}
        <dt>{% trans "Image Name" %}</dt>
        <dd class="word-wrap">
        {% if instance.image_name %}
          <a href="{{ instance.image_url }}">{{ instance.image_name }}</a>
        {% else %}
          {% trans "-" %}
        {% endif %}
        </dd>
        <dt>{% trans "Image ID" %}</dt>
        <dd>{{ instance.image.id }}</dd>
      {% else %}
        <dt>{% trans "Image" %}</dt>
        <dd>{% trans "None" %}</dd>
      {% endif %}
      {% with default_item_value="<em>"|add:_("N/A")|add:"</em>" %}
      {% for key, value in instance.metadata.items %}
        <dt>{{ key }}</dt>
        <dd>{{ value|default:default_item_value }}</dd>
      {% endfor %}
      {% endwith %}
    </dl>

    <h4>{% trans "Volumes Attached" %}</h4>
    <hr class="header_rule">
    <dl class="dl-horizontal">
    {% for volume in instance.volumes %}
        <dt>{% trans "Attached To" %}</dt>
        <dd class="word-wrap">
            {% url instance.volume_url volume.id as volume_url %}
            {% blocktrans trimmed with volume_label=volume.name|default:volume.id volume_device=volume.device %}
            <a href="{{ volume_url }}">{{ volume_label }}</a> on {{ volume_device }}
            {% endblocktrans %}
        </dd>
        {% empty %}
        <dt>{% trans "Volume" %}</dt>
        <dd><em>{% trans "No volumes attached." %}</em></dd>
    {% endfor %}
    </dl>
</div>
