network.html 6.01 KB
Newer Older
1
{% load i18n %}
2
{% load network_tags %} 
3 4
<h2>
  <a href="#" id="vm-details-network-add" class="btn btn-success pull-right no-js-hidden">
Őry Máté committed
5
    <i class="icon-plus"></i> {% trans "add interface" %}
6
  </a>
Őry Máté committed
7
  {% trans "Interfaces" %}
8
</h2>
9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
<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 font-awesome-font">
            {% for v in vlans %}
              <option value="{{ v.pk }}">
                {% if v.managed %}
                  &#xf0ac;
                {% else %}
                  &#xf0c1;
                {% endif %}
                {{ v.name }}
              </option>
              {% empty %}
              <option value="-1">No more networks!</option>
            {% endfor %}
          </select>
          <div class="input-group-btn">
            <button {% if vlans|length == 0 %}disabled{% endif %}
              type="submit" class="btn btn-success"><i class="icon-plus-sign"></i></button>
          </div>
        </div>
      </form>
      <hr />
    </div> 
  </div>
43
</div>
44

45
{% for i in instance.interface_set.all %}
46
<div>
47
  <h3 class="list-group-item-heading dashboard-vm-details-network-h3">
48
    <i class="icon-{% if i.host %}globe{% else %}link{% endif %}"></i> {{ i.vlan.name }} 
49
    {% if not i.host%}({% trans "unmanaged" %}){% endif %}
50 51 52 53 54 55
    {% if user.is_superuser %}
      <a href="{{ i.host.get_absolute_url }}" 
        class="btn btn-default btn-xs">{% trans "edit" %}</a>
    {% endif %}
    <a href="{% url "dashboard.views.interface-delete" pk=i.pk %}?next={{ request.path }}" 
      class="btn btn-danger btn-xs interface-remove"
56 57 58
      data-interface-pk="{{ i.pk }}">
      {% trans "remove" %}
    </a>
59 60
  </h3>
  {% if i.host %}
61 62 63
    <div class="row">
      <div class="col-md-5">
        <dl>
64 65 66 67 68 69 70
          <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 %}
71 72
            {% empty %}
            -
73 74
          {% endfor %}
          </dd>
75 76 77 78
        </dl>
      </div>
      <div class="col-md-7">
        <ul class="nav nav-pills pull-right">
Őry Máté committed
79 80
          <li class="active"><a href="#ipv4_{{ i.host.vlan.pk }}" data-toggle="pill" class="text-center">{% trans "IPv4" %}</a></li>
          <li><a href="#ipv6_{{ i.host.vlan.pk }}" data-toggle="pill" class="text-center">{% trans "IPv6" %}</a></li>
81
        </ul>
Őry Máté committed
82
        <h4>{% trans "Port access" %}</h4>
83
        <div class="tab-content" style="padding-top: 10px;">
84
          <div class="tab-pane active" id="ipv4_{{ i.host.vlan.pk }}">
85 86 87 88 89 90 91 92 93 94 95 96 97
            <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>
98 99 100 101
                {% for l in i.host.list_ports %}
                  {% if l.ipv4 %}
                    <tr>
                      <td>
102
                        {% display_portforward4 l %}
103
                      </td>
104 105
                      <td><i class="icon-long-arrow-right"></i></td>
                      <td>
106 107 108
                        {{ l.private }}/{{ l.proto }}
                      </td>
                      <td>
109
                        <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>
110 111 112 113
                      </td>
                    </tr>
                  {% endif %}
                {% endfor %}
114 115 116
              </tbody>
            </table>
          </div> <!-- /ipv4 -->
117
          <div class="tab-pane" id="ipv6_{{ i.host.vlan.pk }}">
118
            {% if i.host.ipv6 %} 
119 120 121 122 123 124 125 126 127 128 129
            <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>
130 131 132 133
                {% for l in i.host.list_ports %}
                  {% if l.ipv6 %}
                    <tr>
                      <td>
134
                        {% display_portforward6 l %}
135
                      </td>
136 137
                      <td><i class="icon-long-arrow-right"></i></td>
                      <td>
138 139 140
                        {{ l.private }}/{{ l.proto }}
                      </td>
                      <td>
141
                        <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>
142 143 144 145
                      </td>
                    </tr>
                  {% endif %}
                {% endfor %}
146 147
              </tbody>
            </table>
148 149 150 151
            {% else %}
              <h4>{% trans "This VM doesn't have an IPv6 address!" %}</h4>
            {% endif %}
          </div><!-- /ipv6 -->
152
          {% include "dashboard/vm-detail/_network-port-add.html" %}
153 154 155
        </div>
      </div>
    </div>
156
  {% endif %}
157
</div>
158
{% endfor %}