mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-17 04:32:51 -06:00
Added device config view
This commit is contained in:
parent
4ad5c6f864
commit
0f608f3a15
@ -124,6 +124,7 @@ urlpatterns = [
|
|||||||
url(r'^devices/(?P<pk>\d+)/inventory/$', views.DeviceInventoryView.as_view(), name='device_inventory'),
|
url(r'^devices/(?P<pk>\d+)/inventory/$', views.DeviceInventoryView.as_view(), name='device_inventory'),
|
||||||
url(r'^devices/(?P<pk>\d+)/status/$', views.DeviceStatusView.as_view(), name='device_status'),
|
url(r'^devices/(?P<pk>\d+)/status/$', views.DeviceStatusView.as_view(), name='device_status'),
|
||||||
url(r'^devices/(?P<pk>\d+)/lldp-neighbors/$', views.DeviceLLDPNeighborsView.as_view(), name='device_lldp_neighbors'),
|
url(r'^devices/(?P<pk>\d+)/lldp-neighbors/$', views.DeviceLLDPNeighborsView.as_view(), name='device_lldp_neighbors'),
|
||||||
|
url(r'^devices/(?P<pk>\d+)/config/$', views.DeviceConfigView.as_view(), name='device_config'),
|
||||||
url(r'^devices/(?P<pk>\d+)/add-secret/$', secret_add, name='device_addsecret'),
|
url(r'^devices/(?P<pk>\d+)/add-secret/$', secret_add, name='device_addsecret'),
|
||||||
url(r'^devices/(?P<device>\d+)/services/assign/$', ServiceCreateView.as_view(), name='service_assign'),
|
url(r'^devices/(?P<device>\d+)/services/assign/$', ServiceCreateView.as_view(), name='service_assign'),
|
||||||
url(r'^devices/(?P<object_id>\d+)/images/add/$', ImageAttachmentEditView.as_view(), name='device_add_image', kwargs={'model': Device}),
|
url(r'^devices/(?P<object_id>\d+)/images/add/$', ImageAttachmentEditView.as_view(), name='device_add_image', kwargs={'model': Device}),
|
||||||
|
@ -921,7 +921,8 @@ class DeviceInventoryView(View):
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
class DeviceStatusView(View):
|
class DeviceStatusView(PermissionRequiredMixin, View):
|
||||||
|
permission_required = 'dcim.napalm_read'
|
||||||
|
|
||||||
def get(self, request, pk):
|
def get(self, request, pk):
|
||||||
|
|
||||||
@ -932,7 +933,8 @@ class DeviceStatusView(View):
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
class DeviceLLDPNeighborsView(View):
|
class DeviceLLDPNeighborsView(PermissionRequiredMixin, View):
|
||||||
|
permission_required = 'dcim.napalm_read'
|
||||||
|
|
||||||
def get(self, request, pk):
|
def get(self, request, pk):
|
||||||
|
|
||||||
@ -951,6 +953,18 @@ class DeviceLLDPNeighborsView(View):
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
class DeviceConfigView(PermissionRequiredMixin, View):
|
||||||
|
permission_required = 'dcim.napalm_read'
|
||||||
|
|
||||||
|
def get(self, request, pk):
|
||||||
|
|
||||||
|
device = get_object_or_404(Device, pk=pk)
|
||||||
|
|
||||||
|
return render(request, 'dcim/device_config.html', {
|
||||||
|
'device': device,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
class DeviceCreateView(PermissionRequiredMixin, ObjectEditView):
|
class DeviceCreateView(PermissionRequiredMixin, ObjectEditView):
|
||||||
permission_required = 'dcim.add_device'
|
permission_required = 'dcim.add_device'
|
||||||
model = Device
|
model = Device
|
||||||
|
53
netbox/templates/dcim/device_config.html
Normal file
53
netbox/templates/dcim/device_config.html
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
{% extends '_base.html' %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
|
||||||
|
{% block title %}{{ device }} - Config{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% include 'inc/ajax_loader.html' %}
|
||||||
|
{% include 'dcim/inc/device_header.html' with active_tab='config' %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-10 col-md-offset-1">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading"><strong>Device Configuration</strong></div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
|
<li role="presentation" class="active"><a href="#running" aria-controls="running" role="tab" data-toggle="tab">Running</a></li>
|
||||||
|
<li role="presentation"><a href="#startup" aria-controls="startup" role="tab" data-toggle="tab">Startup</a></li>
|
||||||
|
<li role="presentation"><a href="#candidate" aria-controls="candidate" role="tab" data-toggle="tab">Candidate</a></li>
|
||||||
|
</ul>
|
||||||
|
<div class="tab-content">
|
||||||
|
<div role="tabpanel" class="tab-pane active" id="running">
|
||||||
|
<pre id="running_config"></pre>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane" id="startup">
|
||||||
|
<pre id="startup_config"></pre>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane" id="candidate">
|
||||||
|
<pre id="candidate_config"></pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
$.ajax({
|
||||||
|
url: "{% url 'dcim-api:device-napalm' pk=device.pk %}?method=get_config",
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(json) {
|
||||||
|
$('#running_config').html($.trim(json['get_config']['running']));
|
||||||
|
$('#startup_config').html($.trim(json['get_config']['startup']));
|
||||||
|
$('#candidate_config').html($.trim(json['get_config']['candidate']));
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
alert(xhr.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
@ -1,7 +1,7 @@
|
|||||||
{% extends '_base.html' %}
|
{% extends '_base.html' %}
|
||||||
{% load staticfiles %}
|
{% load staticfiles %}
|
||||||
|
|
||||||
{% block title %}{{ device }} - NAPALM{% endblock %}
|
{% block title %}{{ device }} - Status{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% include 'inc/ajax_loader.html' %}
|
{% include 'inc/ajax_loader.html' %}
|
||||||
|
@ -45,8 +45,9 @@
|
|||||||
<ul class="nav nav-tabs" style="margin-bottom: 20px">
|
<ul class="nav nav-tabs" style="margin-bottom: 20px">
|
||||||
<li role="presentation"{% if active_tab == 'info' %} class="active"{% endif %}><a href="{% url 'dcim:device' pk=device.pk %}">Info</a></li>
|
<li role="presentation"{% if active_tab == 'info' %} class="active"{% endif %}><a href="{% url 'dcim:device' pk=device.pk %}">Info</a></li>
|
||||||
<li role="presentation"{% if active_tab == 'inventory' %} class="active"{% endif %}><a href="{% url 'dcim:device_inventory' pk=device.pk %}">Inventory</a></li>
|
<li role="presentation"{% if active_tab == 'inventory' %} class="active"{% endif %}><a href="{% url 'dcim:device_inventory' pk=device.pk %}">Inventory</a></li>
|
||||||
<li role="presentation"{% if active_tab == 'status' %} class="active"{% endif %}><a href="{% url 'dcim:device_status' pk=device.pk %}">Status</a></li>
|
{% if perms.dcim.napalm_read and device.status == 1 and device.platform.napalm_driver and device.primary_ip %}
|
||||||
{% if device.status == 1 and device.platform.rpc_client and device.primary_ip %}
|
<li role="presentation"{% if active_tab == 'status' %} class="active"{% endif %}><a href="{% url 'dcim:device_status' pk=device.pk %}">Status</a></li>
|
||||||
<li role="presentation"{% if active_tab == 'lldp-neighbors' %} class="active"{% endif %}><a href="{% url 'dcim:device_lldp_neighbors' pk=device.pk %}">LLDP Neighbors</a></li>
|
<li role="presentation"{% if active_tab == 'lldp-neighbors' %} class="active"{% endif %}><a href="{% url 'dcim:device_lldp_neighbors' pk=device.pk %}">LLDP Neighbors</a></li>
|
||||||
|
<li role="presentation"{% if active_tab == 'config' %} class="active"{% endif %}><a href="{% url 'dcim:device_config' pk=device.pk %}">Configuration</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
Reference in New Issue
Block a user