Просмотр исходного кода

Expanded device interfaces display to include MTU, MAC address, and tags

Jeremy Stretch 7 лет назад
Родитель
Сommit
7bed48f5fe
3 измененных файлов с 35 добавлено и 10 удалено
  1. 4 2
      netbox/dcim/views.py
  2. 1 0
      netbox/templates/dcim/device.html
  3. 30 8
      netbox/templates/dcim/inc/interface.html

+ 4 - 2
netbox/dcim/views.py

@@ -858,8 +858,10 @@ class DeviceView(View):
             device.device_type.interface_ordering
             device.device_type.interface_ordering
         ).select_related(
         ).select_related(
             'connected_as_a__interface_b__device', 'connected_as_b__interface_a__device',
             'connected_as_a__interface_b__device', 'connected_as_b__interface_a__device',
-            'circuit_termination__circuit'
-        ).prefetch_related('ip_addresses')
+            'circuit_termination__circuit__provider'
+        ).prefetch_related(
+            'tags', 'ip_addresses'
+        )
 
 
         # Device bays
         # Device bays
         device_bays = natsorted(
         device_bays = natsorted(

+ 1 - 0
netbox/templates/dcim/device.html

@@ -525,6 +525,7 @@
                                 <th>Name</th>
                                 <th>Name</th>
                                 <th>LAG</th>
                                 <th>LAG</th>
                                 <th>Description</th>
                                 <th>Description</th>
+                                <th>MTU</th>
                                 <th>Mode</th>
                                 <th>Mode</th>
                                 <th colspan="2">Connection</th>
                                 <th colspan="2">Connection</th>
                                 <th></th>
                                 <th></th>

+ 30 - 8
netbox/templates/dcim/inc/interface.html

@@ -1,4 +1,5 @@
-<tr class="interface{% if not iface.enabled %} danger{% elif iface.connection and iface.connection.connection_status or iface.circuit_termination %} success{% elif iface.connection and not iface.connection.connection_status %} info{% elif iface.is_virtual %} warning{% endif %}" id="iface_{{ iface.name }}">
+{% load helpers %}
+<tr class="interface{% if not iface.enabled %} danger{% elif iface.connection and iface.connection.connection_status or iface.circuit_termination %} success{% elif iface.connection and not iface.connection.connection_status %} info{% elif iface.is_virtual %} warning{% endif %}" id="interface_{{ iface.name }}">
 
 
     {# Checkbox #}
     {# Checkbox #}
     {% if perms.dcim.change_interface or perms.dcim.delete_interface %}
     {% if perms.dcim.change_interface or perms.dcim.delete_interface %}
@@ -7,32 +8,53 @@
         </td>
         </td>
     {% endif %}
     {% endif %}
 
 
-    {# Icon and name #}
+    {# Icon/name/MAC #}
     <td>
     <td>
         <span title="{{ iface.get_form_factor_display }}">
         <span title="{{ iface.get_form_factor_display }}">
             <i class="fa fa-fw fa-{% if iface.mgmt_only %}wrench{% elif iface.is_lag %}align-justify{% elif iface.is_virtual %}circle{% elif iface.is_wireless %}wifi{% else %}exchange{% endif %}"></i>
             <i class="fa fa-fw fa-{% if iface.mgmt_only %}wrench{% elif iface.is_lag %}align-justify{% elif iface.is_virtual %}circle{% elif iface.is_wireless %}wifi{% else %}exchange{% endif %}"></i>
             <a href="{{ iface.get_absolute_url }}">{{ iface }}</a>
             <a href="{{ iface.get_absolute_url }}">{{ iface }}</a>
         </span>
         </span>
+        {% if iface.mac_address %}
+            <br/><small class="text-muted">{{ iface.mac_address }}</small>
+        {% endif %}
     </td>
     </td>
 
 
     {# LAG #}
     {# LAG #}
     <td>
     <td>
         {% if iface.lag %}
         {% if iface.lag %}
-            <a href="#iface_{{ iface.lag }}" class="label label-default" title="{{ iface.lag.description }}">{{ iface.lag }}</a>
+            <a href="#interface_{{ iface.lag }}" class="label label-primary" title="{{ iface.lag.description }}">{{ iface.lag }}</a>
+        {% endif %}
+    </td>
+
+    {# Description/tags #}
+    <td>
+        {% if iface.description %}
+            {{ iface.description }}<br/>
         {% endif %}
         {% endif %}
+        {% for tag in iface.tags.all %}
+            {% tag tag %}
+        {% empty %}
+            {% if not iface.description %}&mdash;{% endif %}
+        {% endfor %}
     </td>
     </td>
 
 
-    {# Description #}
-    <td>{{ iface.description|default:"&mdash;" }}</td>
+    {# MTU #}
+    <td>{{ iface.mtu|default:"&mdash;" }}</td>
 
 
     {# 802.1Q mode #}
     {# 802.1Q mode #}
-    <td>{{ iface.get_mode_display }}</td>
+    <td>{{ iface.get_mode_display|default:"&mdash;" }}</td>
 
 
     {# Connection or type #}
     {# Connection or type #}
     {% if iface.is_lag %}
     {% if iface.is_lag %}
         <td colspan="2" class="text-muted">
         <td colspan="2" class="text-muted">
             LAG interface<br />
             LAG interface<br />
-            <small class="text-muted">{{ iface.member_interfaces.all|join:", "|default:"No members" }}</small>
+            <small class="text-muted">
+                {% for member in iface.member_interfaces.all %}
+                    <a href="#interface_{{ member.name }}">{{ member }}</a>{% if not forloop.last %}, {% endif %}
+                {% empty %}
+                    No members
+                {% endfor %}
+            </small>
         </td>
         </td>
     {% elif iface.is_virtual %}
     {% elif iface.is_virtual %}
         <td colspan="2" class="text-muted">Virtual interface</td>
         <td colspan="2" class="text-muted">Virtual interface</td>
@@ -138,7 +160,7 @@
             {% endif %}
             {% endif %}
 
 
             {# IP addresses table #}
             {# IP addresses table #}
-            <td colspan="7" style="padding: 0">
+            <td colspan="8" style="padding: 0">
                 <table class="table table-condensed interface-ips">
                 <table class="table table-condensed interface-ips">
                     <thead>
                     <thead>
                         <tr class="text-muted">
                         <tr class="text-muted">