-
Notifications
You must be signed in to change notification settings - Fork 0
/
device.py
37 lines (29 loc) · 942 Bytes
/
device.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# device.py
from netmiko import SSHDetect, exceptions
def detect_device(ip, username, password, enable_password):
"""
Get device type
Args:
ip: IP of the device to detect.
username: Username to authenticate with.
password: Password to authenticate with.
enable_password: Enable password to authenticate with.
Returns:
best_match: The best match for the device type.
"""
try:
device = {
"device_type": "autodetect",
"host": ip,
"username": username,
"password": password,
"global_delay_factor": 4,
"banner_timeout": 1000,
"conn_timeout": 1000,
"secret": enable_password,
}
guesser = SSHDetect(**device)
best_match = guesser.autodetect()
return best_match
except exceptions.NetmikoAuthenticationException as e:
return False