1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Merge pull request #3645 from BegBlev/llpd-port-id

Retrieve port-id in LLDP tab
This commit is contained in:
kobayashi
2019-10-28 12:19:10 -04:00
committed by GitHub

View File

@ -52,10 +52,10 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$.ajax({ $.ajax({
url: "{% url 'dcim-api:device-napalm' pk=device.pk %}?method=get_lldp_neighbors", url: "{% url 'dcim-api:device-napalm' pk=device.pk %}?method=get_lldp_neighbors_detail",
dataType: 'json', dataType: 'json',
success: function(json) { success: function(json) {
$.each(json['get_lldp_neighbors'], function(iface, neighbors) { $.each(json['get_lldp_neighbors_detail'], function(iface, neighbors) {
var neighbor = neighbors[0]; var neighbor = neighbors[0];
var row = $('#' + iface.split(".")[0].replace(/([\/:])/g, "\\$1")); var row = $('#' + iface.split(".")[0].replace(/([\/:])/g, "\\$1"));
@ -69,8 +69,8 @@ $(document).ready(function() {
} }
// Clean up hostnames/interfaces learned via LLDP // Clean up hostnames/interfaces learned via LLDP
var neighbor_host = neighbor['hostname'] || ""; // sanitize hostname if it's null to avoid breaking the split func var neighbor_host = neighbor['remote_system_name'] || ""; // sanitize hostname if it's null to avoid breaking the split func
var neighbor_port = neighbor['port'] || ""; // sanitize port if it's null to avoid breaking the split func var neighbor_port = neighbor['remote_port'] || ""; // sanitize port if it's null to avoid breaking the split func
var lldp_device = neighbor_host.split(".")[0]; // Strip off any trailing domain name var lldp_device = neighbor_host.split(".")[0]; // Strip off any trailing domain name
var lldp_interface = neighbor_port.split(".")[0]; // Strip off any trailing subinterface ID var lldp_interface = neighbor_port.split(".")[0]; // Strip off any trailing subinterface ID