@@ -83,6 +83,7 @@ def __init__( # pylint: disable=R0913
8383 password (str): Device password (if unspecified, NAPALM_PASSWORD settings variable will be used)
8484 secret (str): Device secret password (if unspecified, NAPALM_ARGS["secret"] settings variable will be used)
8585 napalm_driver (str): Napalm driver name to use to onboard network device
86+ optional_args (dict): Optional arguments passed to NAPALM and Netmiko
8687
8788 Raises:
8889 OnboardException('fail-config'):
@@ -96,7 +97,14 @@ def __init__( # pylint: disable=R0913
9697 self .password = password
9798 self .secret = secret
9899 self .napalm_driver = napalm_driver
99- self .optional_args = optional_args
100+
101+ # Netmiko and NAPALM expects optional_args to be a dictionary.
102+ if isinstance (optional_args , dict ):
103+ self .optional_args = optional_args
104+ elif optional_args is None :
105+ self .optional_args = {}
106+ else :
107+ raise OnboardException (reason = "fail-general" , message = "Optional arguments should be None or a dict" )
100108
101109 self .facts = None
102110 self .ip_ifs = None
@@ -226,19 +234,21 @@ def get_onboarding_facts(self):
226234
227235 driver = get_network_driver (self .napalm_driver )
228236
229- optional_args = self .optional_args .copy ()
237+ # Create NAPALM optional arguments
238+ napalm_optional_args = self .optional_args .copy ()
239+
230240 if self .port :
231- optional_args ["port" ] = self .port
241+ napalm_optional_args ["port" ] = self .port
232242
233243 if self .secret :
234- optional_args ["secret" ] = self .secret
244+ napalm_optional_args ["secret" ] = self .secret
235245
236246 napalm_device = driver (
237247 hostname = self .hostname ,
238248 username = self .username ,
239249 password = self .password ,
240250 timeout = self .timeout ,
241- optional_args = optional_args ,
251+ optional_args = napalm_optional_args ,
242252 )
243253
244254 napalm_device .open ()
0 commit comments