network.html 5.41 KB
Newer Older
1
{% load i18n %}
2 3 4 5 6 7
<h2>
  <a href="#" id="vm-details-network-add" class="btn btn-success pull-right no-js-hidden">
    <i class="icon-plus"></i> add interface
  </a>
  Interfaces
</h2>
8

9
<div class="row" id="vm-details-network-add-for-form">
10

11
</div>
12
{% for i in instance.interface_set.all %}
13
  <h3 class="list-group-item-heading dashboard-vm-details-network-h3">
14
    <i class="icon-{% if i.host %}globe{% else %}link{% endif %}"></i> {{ i.vlan.name }} 
15 16 17
    {% if not i.host %}(unmanaged) <a href="#" class="btn btn-danger btn-xs">remove</a>{% endif %}
  </h3>
  {% if i.host %}
18 19 20
    <div class="row">
      <div class="col-md-5">
        <dl>
21 22 23 24 25 26 27 28 29
          <dt>{% trans "IPv4 address" %}:</dt> <dd>{{ i.host.ipv4 }}</dd>
          <dt>{% trans "IPv6 address" %}:</dt> <dd>{{ i.host.ipv6 }}</dd>
          <dt>{% trans "DNS name" %}:</dt> <dd>{{ i.host.get_fqdn }}</dd>
          <dt>{% trans "Groups" %}:</dt>
          <dd>
          {% for g in i.host.groups.all %}
            {{ g }}{% if not forloop.last %},{% endif %}
          {% endfor %}
          </dd>
30 31 32 33
        </dl>
      </div>
      <div class="col-md-7">
        <ul class="nav nav-pills pull-right">
34 35
          <li class="active"><a href="#ipv4_{{ i.host.vlan.pk }}" data-toggle="pill" class="text-center">IPv4</a></li>
          <li><a href="#ipv6_{{ i.host.vlan.pk }}" data-toggle="pill" class="text-center">IPv6</a></li>
36 37
        </ul>
        <h4>Port access</h4>
38
        <div class="tab-content" style="padding-top: 10px;">
39
          <div class="tab-pane active" id="ipv4_{{ i.host.vlan.pk }}">
40 41 42 43 44 45 46 47 48 49 50 51 52
            <table class="table table-striped rule-table">
              <thead>
                <tr><th>
                  <i class="icon-globe icon-2x"></i>
                  <i class="icon-long-arrow-right icon-2x"></i>
                  </th><th>
                  <i class="icon-shield icon-2x"></i>
                  </th><th colspan="2">
                  <i class="icon-long-arrow-right icon-2x"></i>
                  <i class="icon-desktop icon-2x"></i>
                </th></tr>
              </thead>
              <tbody>
53 54 55 56 57 58
                {% for l in i.host.list_ports %}
                  {% if l.ipv4 %}
                    <tr>
                      <td>
                        {{ l.ipv4.host }}:{{ l.ipv4.port }}
                      </td>
59 60
                      <td><i class="icon-long-arrow-right"></i></td>
                      <td>
61 62 63
                        {{ l.private }}/{{ l.proto }}
                      </td>
                      <td>
64
                        <a href="{% url "dashboard.views.remove-port" pk=instance.pk rule=l.ipv4.pk %}" class="btn btn-link btn-xs vm-details-remove-port" data-rule="{{ l.ipv4.pk }}" title="{% trans "Remove" %}"><i class="icon-remove"><span class="sr-only">{% trans "Remove" %}</span></i></a>
65 66 67 68
                      </td>
                    </tr>
                  {% endif %}
                {% endfor %}
69 70 71
              </tbody>
            </table>
          </div> <!-- /ipv4 -->
72
          <div class="tab-pane" id="ipv6_{{ i.host.vlan.pk }}">
73
            {% if i.host.ipv6 %} 
74 75 76 77 78 79 80 81 82 83 84
            <table class="table table-striped rule-table">
              <thead>
                <tr><th>
                  <i class="icon-globe icon-2x"></i>
                </th><th>
                  <i class="icon-long-arrow-right icon-2x"></i>
                </th><th colspan="2">
                  <i class="icon-desktop icon-2x"></i>
                </th></tr>
              </thead>
              <tbody>
85 86 87 88 89 90
                {% for l in i.host.list_ports %}
                  {% if l.ipv6 %}
                    <tr>
                      <td>
                        {{ l.ipv6.host }}:{{ l.ipv6.port }}
                      </td>
91 92
                      <td><i class="icon-long-arrow-right"></i></td>
                      <td>
93 94 95
                        {{ l.private }}/{{ l.proto }}
                      </td>
                      <td>
96
                        <a href="{% url "dashboard.views.remove-port" pk=instance.pk rule=l.ipv4.pk %}" class="btn btn-link btn-xs vm-details-remove-port" data-rule="{{ l.ipv6.pk }}" title="{% trans "Remove" %}"><i class="icon-remove"><span class="sr-only">{% trans "Remove" %}</span></i></a>
97 98 99 100
                      </td>
                    </tr>
                  {% endif %}
                {% endfor %}
101 102
              </tbody>
            </table>
103 104 105 106
            {% else %}
              <h4>{% trans "This VM doesn't have an IPv6 address!" %}</h4>
            {% endif %}
          </div><!-- /ipv6 -->
107
          {% include "dashboard/vm-detail/_network-port-add.html" %}
108 109 110
        </div>
      </div>
    </div>
111 112
  {% endif %}
{% endfor %}
113 114 115 116 117 118 119 120 121 122 123
<div class="js-hidden row" id="vm-details-network-add-form">
  <div class="col-md-12">
    <div>
      <hr />
      <h3>
        {% trans "Add new network interface!" %}
      </h3>
      <form method="POST" action="">
        {% csrf_token %}
        <div class="input-group" style="max-width: 330px;">
          <select name="new_network_vlan" class="form-control">
124 125 126
            {% if vlans|length == 0 %} 
              <option value="-1">No more networks!</option>
            {% endif %}
127 128 129 130 131 132 133 134 135 136 137 138 139
            {% for v in vlans %}
              <option value="{{ v.pk }}">{{ v.name }}</option>
            {% endfor %}
          </select>
          <div class="input-group-btn">
            <button type="submit" class="btn btn-success"><i class="icon-plus-sign"></i></button>
          </div>
        </div>
      </form>
      <hr />
    </div> 
  </div>
</div>