Parcourir la source

RPC API fixes

Jeremy Stretch il y a 8 ans
Parent
commit
a5419ecc5c
2 fichiers modifiés avec 9 ajouts et 3 suppressions
  1. 5 2
      netbox/extras/rpc.py
  2. 4 1
      netbox/templates/dcim/device_lldp_neighbors.html

+ 5 - 2
netbox/extras/rpc.py

@@ -130,8 +130,11 @@ class JunosNC(RPCClient):
         for neighbor_raw in lldp_neighbors_raw:
         for neighbor_raw in lldp_neighbors_raw:
             neighbor = dict()
             neighbor = dict()
             neighbor['local-interface'] = neighbor_raw.get('lldp-local-port-id')
             neighbor['local-interface'] = neighbor_raw.get('lldp-local-port-id')
-            neighbor['name'] = neighbor_raw.get('lldp-remote-system-name')
-            neighbor['name'] = neighbor['name'].split('.')[0]  # Split hostname from domain if one is present
+            name = neighbor_raw.get('lldp-remote-system-name')
+            if name:
+                neighbor['name'] = name.split('.')[0]  # Split hostname from domain if one is present
+            else:
+                neighbor['name'] = ''
             try:
             try:
                 neighbor['remote-interface'] = neighbor_raw['lldp-remote-port-description']
                 neighbor['remote-interface'] = neighbor_raw['lldp-remote-port-description']
             except KeyError:
             except KeyError:

+ 4 - 1
netbox/templates/dcim/device_lldp_neighbors.html

@@ -47,7 +47,7 @@
 <script type="text/javascript">
 <script type="text/javascript">
 $(document).ready(function() {
 $(document).ready(function() {
     $.ajax({
     $.ajax({
-        url: "{% url 'dcim-api:device_lldp-neighbors' pk=device.pk %}",
+        url: "{% url 'dcim-api:device-lldp-neighbors' pk=device.pk %}",
         dataType: 'json',
         dataType: 'json',
         success: function(json) {
         success: function(json) {
             $.each(json, function(i, neighbor) {
             $.each(json, function(i, neighbor) {
@@ -66,6 +66,9 @@ $(document).ready(function() {
                     row.addClass('danger');
                     row.addClass('danger');
                 }
                 }
             });
             });
+        },
+        error: function(xhr) {
+            alert(xhr.responseText);
         }
         }
     });
     });
 });
 });