Skip to content

Commit 2eca893

Browse files
authored
Merge pull request #135 from networktocode/mzb-guessed-device-none
Correctly handle onboarding exception when no device type is guessed
2 parents 63b746c + fcb4b88 commit 2eca893

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

netbox_onboarding/netdev_keeper.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import importlib
1616
import logging
1717
import socket
18-
18+
from dcim.models import Platform
1919
from django.conf import settings
2020
from napalm import get_network_driver
2121
from napalm.base.exceptions import ConnectionException, CommandErrorException
@@ -25,8 +25,6 @@
2525
from netmiko.ssh_exception import NetMikoTimeoutException
2626
from paramiko.ssh_exception import SSHException
2727

28-
from dcim.models import Platform
29-
3028
from netbox_onboarding.onboarding.onboarding import StandaloneOnboarding
3129
from .constants import NETMIKO_TO_NAPALM_STATIC
3230
from .exceptions import OnboardException
@@ -178,7 +176,12 @@ def guess_netmiko_device_type(self):
178176
logger.error("ERROR: %s", str(err))
179177
raise OnboardException(reason="fail-general", message=f"ERROR: {str(err)}")
180178

181-
logger.info("INFO device type is: %s", guessed_device_type)
179+
else:
180+
if guessed_device_type is None:
181+
logger.error("ERROR: Could not detect device type with SSHDetect")
182+
raise OnboardException(
183+
reason="fail-general", message="ERROR: Could not detect device type with SSHDetect"
184+
)
182185

183186
return guessed_device_type
184187

0 commit comments

Comments
 (0)