3232from .constants import NETMIKO_TO_NAPALM_STATIC
3333from .exceptions import OnboardException
3434
35+ logger = logging .getLogger ("rq.worker" )
36+ logger .setLevel (logging .DEBUG )
37+
3538PLUGIN_SETTINGS = settings .PLUGINS_CONFIG ["netbox_onboarding" ]
3639
3740
@@ -144,7 +147,7 @@ def check_reachability(self):
144147 OnboardException('fail-connect'):
145148 When device unreachable
146149 """
147- logging .info ("CHECK: IP %s:%s" , self .hostname , self .port )
150+ logger .info ("CHECK: IP %s:%s" , self .hostname , self .port )
148151
149152 try :
150153 sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
@@ -169,32 +172,32 @@ def guess_netmiko_device_type(self):
169172 }
170173
171174 try :
172- logging .info ("INFO guessing device type: %s" , self .hostname )
175+ logger .info ("INFO guessing device type: %s" , self .hostname )
173176 guesser = SSHDetect (** remote_device )
174177 guessed_device_type = guesser .autodetect ()
175- logging .info ("INFO guessed device type: %s" , guessed_device_type )
178+ logger .info ("INFO guessed device type: %s" , guessed_device_type )
176179
177180 except NetMikoAuthenticationException as err :
178- logging .error ("ERROR %s" , err )
181+ logger .error ("ERROR %s" , err )
179182 raise OnboardException (reason = "fail-login" , message = f"ERROR: { str (err )} " )
180183
181184 except (NetMikoTimeoutException , SSHException ) as err :
182- logging .error ("ERROR: %s" , str (err ))
185+ logger .error ("ERROR: %s" , str (err ))
183186 raise OnboardException (reason = "fail-connect" , message = f"ERROR: { str (err )} " )
184187
185188 except Exception as err :
186- logging .error ("ERROR: %s" , str (err ))
189+ logger .error ("ERROR: %s" , str (err ))
187190 raise OnboardException (reason = "fail-general" , message = f"ERROR: { str (err )} " )
188191
189- logging .info ("INFO device type is: %s" , guessed_device_type )
192+ logger .info ("INFO device type is: %s" , guessed_device_type )
190193
191194 return guessed_device_type
192195
193196 def set_napalm_driver_name (self ):
194197 """Sets napalm driver name."""
195198 if not self .napalm_driver :
196199 netmiko_device_type = self .guess_netmiko_device_type ()
197- logging .info ("Guessed Netmiko Device Type: %s" , netmiko_device_type )
200+ logger .info ("Guessed Netmiko Device Type: %s" , netmiko_device_type )
198201
199202 self .netmiko_device_type = netmiko_device_type
200203
@@ -234,7 +237,7 @@ def get_onboarding_facts(self):
234237
235238 self .check_reachability ()
236239
237- logging .info ("COLLECT: device information %s" , self .hostname )
240+ logger .info ("COLLECT: device information %s" , self .hostname )
238241
239242 try :
240243 # Get Napalm Driver with Netmiko if needed
@@ -257,10 +260,10 @@ def get_onboarding_facts(self):
257260
258261 napalm_device .open ()
259262
260- logging .info ("COLLECT: device facts" )
263+ logger .info ("COLLECT: device facts" )
261264 self .facts = napalm_device .get_facts ()
262265
263- logging .info ("COLLECT: device interface IPs" )
266+ logger .info ("COLLECT: device interface IPs" )
264267 self .ip_ifs = napalm_device .get_interfaces_ip ()
265268
266269 try :
@@ -270,7 +273,7 @@ def get_onboarding_facts(self):
270273 self .onboarding_class = driver_addon_class .onboarding_class
271274 self .driver_addon_result = driver_addon_class .ext_result
272275 except ImportError as exc :
273- logging .info ("No onboarding extension found for driver %s" , self .napalm_driver )
276+ logger .info ("No onboarding extension found for driver %s" , self .napalm_driver )
274277
275278 except ConnectionException as exc :
276279 raise OnboardException (reason = "fail-login" , message = exc .args [0 ])
0 commit comments