Skip to content

Commit

Permalink
Add netmiko_os and napalm_os
Browse files Browse the repository at this point in the history
  • Loading branch information
liorf committed Mar 14, 2017
1 parent c30cc45 commit cfaea4b
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions nsot_sync/drivers/device_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,16 @@ class DeviceScannerDriver(BaseDriver):
'required': False,
},
{
'name': 'os',
'name': 'napalm_os',
'resource_name': 'Device',
'description': 'Operating System',
'description': 'Operating System saved for napalm tools.',
'display': True,
'required': False,
},
{
'name': 'netmiko_os',
'resource_name': 'Device',
'description': 'Operating System saved for netmiko tools.',
'display': True,
'required': False,
},
Expand Down Expand Up @@ -77,6 +84,13 @@ class DeviceScannerDriver(BaseDriver):
'display': True,
'required': False,
},
{
'name': 'hostname',
'resource_name': 'Device',
'description': 'The hostname',
'display': True,
'required': False,
},
]

def __init__(self, max_threads, scan_vlan, snmp_community, snmp_version, update_creds, *args, **kwargs):
Expand Down Expand Up @@ -212,25 +226,26 @@ def scan(self, ip):

device = find_device_in_ipam(ip, self.devices, self.logger)
# TODO - Add more attributes here
# Add napalm_os
if device_type == 'arista_eos':
os = 'eos'
napalm_os = 'eos'
elif device_type == 'cisco_ios':
os = 'ios'
napalm_os = 'ios'
elif device_type == 'cisco_nxos':
os = 'nxos'
napalm_os = 'nxos'
else:
os = 'unknown'
napalm_os = 'unknown'
if not device:
self.logger.info('%s - Not exist in IPAM', ip)
attributes = {'address': ip, 'last_reachable': str(st), 'device_type': device_type, 'hostname': str(hostname), 'os': os}
attributes = {'address': ip, 'last_reachable': str(st), 'netmiko_os': device_type, 'hostname': str(hostname), 'napalm_os': napalm_os}
device = {'hostname': str(hostname),
'attributes': attributes}
else:
self.logger.info('%s - Exist in IPAM', ip)
device['attributes']['device_type'] = device_type
device['attributes']['netmiko_os'] = device_type
device['attributes']['last_reachable'] = str(st)
device['attributes']['hostname'] = str(hostname)
device['attributes']['os'] = str(os)
device['attributes']['napalm_os'] = str(napalm_os)
device['hostname'] = hostname
self.devices_to_update.append(device)
except NetMikoAuthenticationException as e:
Expand Down

0 comments on commit cfaea4b

Please sign in to comment.