Skip to content

Commit

Permalink
Merge pull request #135 from networktocode/mzb-guessed-device-none
Browse files Browse the repository at this point in the history
Correctly handle onboarding exception when no device type is guessed
  • Loading branch information
mzbroch authored Mar 18, 2021
2 parents 63b746c + fcb4b88 commit 2eca893
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions netbox_onboarding/netdev_keeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import importlib
import logging
import socket

from dcim.models import Platform
from django.conf import settings
from napalm import get_network_driver
from napalm.base.exceptions import ConnectionException, CommandErrorException
Expand All @@ -25,8 +25,6 @@
from netmiko.ssh_exception import NetMikoTimeoutException
from paramiko.ssh_exception import SSHException

from dcim.models import Platform

from netbox_onboarding.onboarding.onboarding import StandaloneOnboarding
from .constants import NETMIKO_TO_NAPALM_STATIC
from .exceptions import OnboardException
Expand Down Expand Up @@ -178,7 +176,12 @@ def guess_netmiko_device_type(self):
logger.error("ERROR: %s", str(err))
raise OnboardException(reason="fail-general", message=f"ERROR: {str(err)}")

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

return guessed_device_type

Expand Down

0 comments on commit 2eca893

Please sign in to comment.