mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-03 14:18:16 -06:00
Merge 15b6834c7e
into fb85867d72
This commit is contained in:
commit
6560e04582
@ -1904,6 +1904,15 @@
|
|||||||
"rpc_client": "opengear"
|
"rpc_client": "opengear"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"model": "dcim.platform",
|
||||||
|
"pk": 3,
|
||||||
|
"fields": {
|
||||||
|
"name": "SnapRoute FlexSwitch",
|
||||||
|
"slug": "snaproute-flexswitch",
|
||||||
|
"rpc_client": "flexswitch"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"model": "dcim.device",
|
"model": "dcim.device",
|
||||||
"pk": 1,
|
"pk": 1,
|
||||||
|
@ -144,6 +144,14 @@
|
|||||||
"slug": "super-micro"
|
"slug": "super-micro"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"model": "dcim.manufacturer",
|
||||||
|
"pk": 9,
|
||||||
|
"fields": {
|
||||||
|
"name": "Accton",
|
||||||
|
"slug": "accton"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"model": "dcim.platform",
|
"model": "dcim.platform",
|
||||||
"pk": 1,
|
"pk": 1,
|
||||||
@ -197,5 +205,14 @@
|
|||||||
"slug": "opengear",
|
"slug": "opengear",
|
||||||
"rpc_client": "opengear"
|
"rpc_client": "opengear"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "dcim.platform",
|
||||||
|
"pk": 7,
|
||||||
|
"fields": {
|
||||||
|
"name": "SnapRoute FlexSwitch",
|
||||||
|
"slug": "snaproute-flexswitch",
|
||||||
|
"rpc_client": "snaproute-flexswitch"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -215,10 +215,12 @@ CONNECTION_STATUS_CHOICES = [
|
|||||||
RPC_CLIENT_JUNIPER_JUNOS = 'juniper-junos'
|
RPC_CLIENT_JUNIPER_JUNOS = 'juniper-junos'
|
||||||
RPC_CLIENT_CISCO_IOS = 'cisco-ios'
|
RPC_CLIENT_CISCO_IOS = 'cisco-ios'
|
||||||
RPC_CLIENT_OPENGEAR = 'opengear'
|
RPC_CLIENT_OPENGEAR = 'opengear'
|
||||||
|
RPC_CLIENT_SNAPROUTE_FLEXSWITCH = 'snaproute-flexswitch'
|
||||||
RPC_CLIENT_CHOICES = [
|
RPC_CLIENT_CHOICES = [
|
||||||
[RPC_CLIENT_JUNIPER_JUNOS, 'Juniper Junos (NETCONF)'],
|
[RPC_CLIENT_JUNIPER_JUNOS, 'Juniper Junos (NETCONF)'],
|
||||||
[RPC_CLIENT_CISCO_IOS, 'Cisco IOS (SSH)'],
|
[RPC_CLIENT_CISCO_IOS, 'Cisco IOS (SSH)'],
|
||||||
[RPC_CLIENT_OPENGEAR, 'Opengear (SSH)'],
|
[RPC_CLIENT_OPENGEAR, 'Opengear (SSH)'],
|
||||||
|
[RPC_CLIENT_SNAPROUTE_FLEXSWITCH, 'SnapRoute FlexSwitch (RPC)'],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,8 @@ import paramiko
|
|||||||
import re
|
import re
|
||||||
import xmltodict
|
import xmltodict
|
||||||
import time
|
import time
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
CONNECT_TIMEOUT = 5 # seconds
|
CONNECT_TIMEOUT = 5 # seconds
|
||||||
|
|
||||||
@ -55,7 +56,6 @@ class RPCClient(object):
|
|||||||
|
|
||||||
class SSHClient(RPCClient):
|
class SSHClient(RPCClient):
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
|
|
||||||
self.ssh = paramiko.SSHClient()
|
self.ssh = paramiko.SSHClient()
|
||||||
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
try:
|
try:
|
||||||
@ -263,10 +263,48 @@ class OpengearSSH(SSHClient):
|
|||||||
'items': [],
|
'items': [],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FlexSwitchRPC(RPCClient):
|
||||||
|
"""
|
||||||
|
RPC client for FlexSwitch devices
|
||||||
|
"""
|
||||||
|
def __init__(self, device, username='', password=''):
|
||||||
|
super(FlexSwitchRPC, self).__init__(device, username='', password='')
|
||||||
|
self.headers = {'Accept' : 'application/json', 'Content-Type' : 'application/json'}
|
||||||
|
self.httpSuccessCodes = [200, 201, 202, 204]
|
||||||
|
self.port = 8080
|
||||||
|
self.timeout = 15
|
||||||
|
self.configUrlBase = 'http://%s:%s/public/v1/config/' % (self.host, self.port)
|
||||||
|
self.stateUrlBase = 'http://%s:%s/public/v1/state/' % (self.host, self.port)
|
||||||
|
self.actionUrlBase = 'http://%s:%s/public/v1/action/' % (self.host, self.port)
|
||||||
|
def __enter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
|
return
|
||||||
|
|
||||||
|
def get_lldp_neighbors(self):
|
||||||
|
reqUrl = self.stateUrlBase + 'LLDPIntfs'
|
||||||
|
resp = requests.get(reqUrl, timeout=self.timeout)
|
||||||
|
if resp.status_code in self.httpSuccessCodes:
|
||||||
|
data = resp.json()
|
||||||
|
result = []
|
||||||
|
for obj in data['Objects']:
|
||||||
|
lldpInfo = dict()
|
||||||
|
lldpInfo['local-interface'] = obj['Object']['IntfRef']
|
||||||
|
lldpInfo['name'] = obj['Object']['PeerHostName']
|
||||||
|
lldpInfo['remote-interface'] = obj['Object']['PeerPort']
|
||||||
|
lldpInfo['chassis-id'] = obj['Object']['PeerMac']
|
||||||
|
print lldpInfo
|
||||||
|
result.append(lldpInfo)
|
||||||
|
return result
|
||||||
|
else:
|
||||||
|
print 'failed querry %s' %(resp.status_code)
|
||||||
|
return None
|
||||||
|
|
||||||
# For mapping platform -> NC client
|
# For mapping platform -> NC client
|
||||||
RPC_CLIENTS = {
|
RPC_CLIENTS = {
|
||||||
'juniper-junos': JunosNC,
|
'juniper-junos': JunosNC,
|
||||||
'cisco-ios': IOSSSH,
|
'cisco-ios': IOSSSH,
|
||||||
'opengear': OpengearSSH,
|
'opengear': OpengearSSH,
|
||||||
|
'snaproute-flexswitch': FlexSwitchRPC,
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
<th>Configured Interface</th>
|
<th>Configured Interface</th>
|
||||||
<th>LLDP Device</th>
|
<th>LLDP Device</th>
|
||||||
<th>LLDP Interface</th>
|
<th>LLDP Interface</th>
|
||||||
|
<th>LLDP Chassis-Id</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -36,6 +37,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<td class="device"></td>
|
<td class="device"></td>
|
||||||
<td class="interface"></td>
|
<td class="interface"></td>
|
||||||
|
<td class="chassis-id"></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -57,6 +59,7 @@ $(document).ready(function() {
|
|||||||
// Add LLDP neighbors to table
|
// Add LLDP neighbors to table
|
||||||
row.children('td.device').html(neighbor['name']);
|
row.children('td.device').html(neighbor['name']);
|
||||||
row.children('td.interface').html(neighbor['remote-interface']);
|
row.children('td.interface').html(neighbor['remote-interface']);
|
||||||
|
row.children('td.chassis-id').html(neighbor['chassis-id']);
|
||||||
// Apply colors to rows
|
// Apply colors to rows
|
||||||
if (!configured_device && neighbor['name']) {
|
if (!configured_device && neighbor['name']) {
|
||||||
row.addClass('info');
|
row.addClass('info');
|
||||||
|
Loading…
Reference in New Issue
Block a user