mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-28 11:26:26 -06:00
initial commit for flexswitch
This commit is contained in:
parent
424c2a59d6
commit
676af9fea5
@ -1904,6 +1904,15 @@
|
||||
"rpc_client": "opengear"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "dcim.platform",
|
||||
"pk": 3,
|
||||
"fields": {
|
||||
"name": "SnapRoute FlexSwitch",
|
||||
"slug": "snaproute-flexswitch",
|
||||
"rpc_client": "flexswitch"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "dcim.device",
|
||||
"pk": 1,
|
||||
|
@ -197,5 +197,14 @@
|
||||
"slug": "opengear",
|
||||
"rpc_client": "opengear"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "dcim.platform",
|
||||
"pk": 7,
|
||||
"fields": {
|
||||
"name": "SnapRoute FlexSwitch",
|
||||
"slug": "snaproute-flexswitch",
|
||||
"rpc_client": "flexswitch"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -182,10 +182,12 @@ CONNECTION_STATUS_CHOICES = [
|
||||
RPC_CLIENT_JUNIPER_JUNOS = 'juniper-junos'
|
||||
RPC_CLIENT_CISCO_IOS = 'cisco-ios'
|
||||
RPC_CLIENT_OPENGEAR = 'opengear'
|
||||
RPC_CLIENT_SNAPROUTE_FLEXSWITCH = 'snaproute-flexswitch'
|
||||
RPC_CLIENT_CHOICES = [
|
||||
[RPC_CLIENT_JUNIPER_JUNOS, 'Juniper Junos (NETCONF)'],
|
||||
[RPC_CLIENT_CISCO_IOS, 'Cisco IOS (SSH)'],
|
||||
[RPC_CLIENT_OPENGEAR, 'Opengear (SSH)'],
|
||||
[RPC_CLIENT_SNAPROUTE_FLEXSWITCH, 'SnapRoute FlexSwitch (SSH)'],
|
||||
]
|
||||
|
||||
|
||||
|
@ -260,10 +260,43 @@ class OpengearSSH(SSHClient):
|
||||
'modules': [],
|
||||
}
|
||||
|
||||
class FlexSwitchSSH(SSHClient):
|
||||
"""
|
||||
SSH client for FlexSwitch devices
|
||||
"""
|
||||
default_credentials = {
|
||||
'username': 'root',
|
||||
'password': 'snaproute',
|
||||
}
|
||||
def get_lldp_neighbors(self):
|
||||
print 'flexswitch get lldp'
|
||||
'''
|
||||
try:
|
||||
stdin, stdout, stderr = self.ssh.exec_command()
|
||||
rpc_reply = self.manager.dispatch('get-lldp-neighbors-information')
|
||||
lldp_neighbors_raw = xmltodict.parse(rpc_reply.xml)['rpc-reply']['lldp-neighbors-information']['lldp-neighbor-information']
|
||||
|
||||
result = []
|
||||
for neighbor_raw in lldp_neighbors_raw:
|
||||
neighbor = dict()
|
||||
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
|
||||
try:
|
||||
neighbor['remote-interface'] = neighbor_raw['lldp-remote-port-description']
|
||||
except KeyError:
|
||||
# Older versions of Junos report on interface ID instead of description
|
||||
neighbor['remote-interface'] = neighbor_raw.get('lldp-remote-port-id')
|
||||
neighbor['chassis-id'] = neighbor_raw.get('lldp-remote-chassis-id')
|
||||
result.append(neighbor)
|
||||
|
||||
return result
|
||||
'''
|
||||
|
||||
# For mapping platform -> NC client
|
||||
RPC_CLIENTS = {
|
||||
'juniper-junos': JunosNC,
|
||||
'cisco-ios': IOSSSH,
|
||||
'opengear': OpengearSSH,
|
||||
'snaproute-flexswitch': FlexSwitchSSH,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user