<!-- TODO(termie): move most of this to horizon -->
{% load sizeformat %}
{% load i18n %}
<table id='instances' class="zebra-striped">
  <tr id='headings'>
    <th>{% trans "ID"%}</th>
    <th>{% trans "Name"%}</th>
    <th>{% trans "Groups"%}</th>
    <th>{% trans "Image"%}</th>
    <th>{% trans "Size"%}</th>
    <th>{% trans "IPs"%}</th>
    <th>{% trans "State"%}</th>
    <th>{% trans "Actions"%}</th>
  </tr>
  <tbody class='main'>
    {% for instance in instances %}
      <tr class="{% cycle 'odd' 'even' %}">
          <td>{{instance.id}}</td>
          <td class="name">
            <a href="{% url horizon:nova:instances:detail instance.id %}">
              {{instance.name}}
              {% if instance.attrs.key_name %}
                  <br/>
                  <small> ({{instance.attrs.key_name}}) </small>
              {% endif %}
            </a>
          </td>
          <td>
            <ul>
              {% for group in instance.attrs.security_groups %}
                <li>{{group}}</li>
              {% endfor %}
            <ul>
          </td>
          <td>{{instance.image_name}}</td>
          <td>
            <ul>
              <li>{{instance.attrs.memory_mb|mbformat}} Ram</li>
              <li>{{instance.attrs.vcpus}} VCPU</li>
              <li>{{instance.attrs.disk_gb}}GB Disk</li>
            </ul>
          </td>
          <td class="ip_list">
            {% for ip_group, addresses in instance.addresses.items %}
              {% if instance.addresses.items|length > 1 %}
              <h4>{{ip_group}}</h4>
              <ul>
                {% for address in addresses %}
                  <li>{{address.addr}}</li>
                {% endfor %}
              </ul>
              {% else %}
              <ul>
                {% for address in addresses %}
                  <li>{{address.addr}}</li>
                {% endfor %}
              </ul>
              {% endif %}
            {% endfor %}
          </td>
          <td>{{instance.status|lower|capfirst}}</td>
          <td id="actions">
            <ul>
              <li><a class="btn small" target="_blank" href="{% url horizon:nova:instances:console instance.id %}">{% trans "Log"%}</a></li>
              <li><a class="btn small" target="_blank" href="{% url horizon:nova:instances:vnc instance.id %}">{% trans "VNC Console"%}</a></li>
              <li><a class="btn small" href="{% url horizon:nova:instances:update instance.id %}">{% trans "Edit"%}</a></li>
              <li><a class="btn small" href="{% url horizon:nova:snapshots:create instance.id %}">{% trans "Snapshot"%}</a></li>
              <li class="form">{% include "nova/instances/_reboot.html" with form=reboot_form %}</li>
              <li class="form">{% include "nova/instances/_terminate.html" with form=terminate_form %}</li>
            </ul>
        </td>
      </tr>
    {% endfor %}
  </tbody>
</table>
