Selaa lähdekoodia

Closes #6054: Display NAPALM-enabled device tabs only when relevant

Jeremy Stretch 4 vuotta sitten
vanhempi
commit
b7309d5c69

+ 7 - 0
docs/additional-features/napalm.md

@@ -2,6 +2,13 @@
 
 NetBox supports integration with the [NAPALM automation](https://napalm-automation.net/) library. NAPALM allows NetBox to serve a proxy for operational data, fetching live data from network devices and returning it to a requester via its REST API. Note that NetBox does not store any NAPALM data locally.
 
+The NetBox UI will display tabs for status, LLDP neighbors, and configuration under the device view if the following conditions are met:
+
+* Device status is "Active"
+* A primary IP has been assigned to the device
+* A platform with a NAPALM driver has been assigned
+* The authenticated user has the `dcim.napalm_read_device` permission
+
 !!! note
     To enable this integration, the NAPALM library must be installed. See [installation steps](../../installation/3-netbox/#napalm) for more information.
 

+ 4 - 0
docs/release-notes/version-2.10.md

@@ -2,6 +2,10 @@
 
 ## v2.10.9 (FUTURE)
 
+### Enhancements
+
+* [#6054](https://github.com/netbox-community/netbox/issues/6054) - Display NAPALM-enabled device tabs only when relevant
+
 ### Bug Fixes
 
 * [#6073](https://github.com/netbox-community/netbox/issues/6073) - Permit users to manage their own REST API tokens without needing explicit permission

+ 11 - 10
netbox/templates/dcim/device/base.html

@@ -153,16 +153,17 @@
                 </li>
             {% endif %}
         {% endwith %}
-        {% if perms.dcim.napalm_read_device %}
-            {% if object.status != 'active' %}
-                {% include 'dcim/inc/device_napalm_tabs.html' with disabled_message='Device must be in active status' %}
-            {% elif not object.platform %}
-                {% include 'dcim/inc/device_napalm_tabs.html' with disabled_message='No platform assigned to this device' %}
-            {% elif not object.platform.napalm_driver %}
-                {% include 'dcim/inc/device_napalm_tabs.html' with disabled_message='No NAPALM driver assigned for this platform' %}
-            {% else %}
-                {% include 'dcim/inc/device_napalm_tabs.html' %}
-            {% endif %}
+        {% if perms.dcim.napalm_read_device and object.status == 'active' and object.primary_ip and object.platform.napalm_driver %}
+            {# NAPALM-enabled tabs #}
+            <li role="presentation"{% if active_tab == 'status' %} class="active"{% endif %}>
+                <a href="{% url 'dcim:device_status' pk=object.pk %}">Status</a>
+            </li>
+            <li role="presentation"{% if active_tab == 'lldp-neighbors' %} class="active"{% endif %}>
+                <a href="{% url 'dcim:device_lldp_neighbors' pk=object.pk %}">LLDP Neighbors</a>
+            </li>
+            <li role="presentation"{% if active_tab == 'config' %} class="active"{% endif %}>
+                <a href="{% url 'dcim:device_config' pk=object.pk %}">Configuration</a>
+            </li>
         {% endif %}
         {% if perms.extras.view_configcontext %}
             <li role="presentation"{% if active_tab == 'config-context' %} class="active"{% endif %}>

+ 0 - 15
netbox/templates/dcim/inc/device_napalm_tabs.html

@@ -1,15 +0,0 @@
-{% if not disabled_message %}
-    <li role="presentation"{% if active_tab == 'status' %} class="active"{% endif %}>
-        <a href="{% url 'dcim:device_status' pk=object.pk %}">Status</a>
-    </li>
-    <li role="presentation"{% if active_tab == 'lldp-neighbors' %} class="active"{% endif %}>
-        <a href="{% url 'dcim:device_lldp_neighbors' pk=object.pk %}">LLDP Neighbors</a>
-    </li>
-    <li role="presentation"{% if active_tab == 'config' %} class="active"{% endif %}>
-        <a href="{% url 'dcim:device_config' pk=object.pk %}">Configuration</a>
-    </li>
-{% else %}
-    <li role="presentation" class="disabled"><a href="#" title="{{ disabled_message }}">Status</a></li>
-    <li role="presentation" class="disabled"><a href="#" title="{{ disabled_message }}">LLDP Neighbors</a></li>
-    <li role="presentation" class="disabled"><a href="#" title="{{ disabled_message }}">Configuration</a></li>
-{% endif %}