2121from .choices import OnboardingFailChoices
2222from .choices import OnboardingStatusChoices
2323from .exceptions import OnboardException
24+ from .models import OnboardingDevice
2425from .models import OnboardingTask
2526from .onboard import OnboardingManager
2627
2930
3031
3132@job ("default" )
32- def onboard_device (task_id , credentials ): # pylint: disable=R0915
33+ def onboard_device (task_id , credentials ): # pylint: disable=too-many-statements
3334 """Process a single OnboardingTask instance."""
3435 username = credentials .username
3536 password = credentials .password
@@ -44,6 +45,12 @@ def onboard_device(task_id, credentials): # pylint: disable=R0915
4445 try :
4546 if ot .ip_address :
4647 onboarded_device = Device .objects .get (primary_ip4__address__net_host = ot .ip_address )
48+
49+ if OnboardingDevice .objects .filter (device = onboarded_device , enabled = False ):
50+ ot .status = OnboardingStatusChoices .STATUS_SKIPPED
51+
52+ return dict (ok = True )
53+
4754 except Device .DoesNotExist as exc :
4855 logger .info ("Getting device with IP lookup failed: %s" , str (exc ))
4956 except Device .MultipleObjectsReturned as exc :
@@ -80,7 +87,7 @@ def onboard_device(task_id, credentials): # pylint: disable=R0915
8087 ot .save ()
8188 onboarding_status = False
8289
83- except Exception as exc : # pylint: disable=W0703
90+ except Exception as exc : # pylint: disable=broad-except
8491 if onboarded_device :
8592 ot .created_device = onboarded_device
8693
0 commit comments