@@ -83,6 +83,7 @@ def __init__( # pylint: disable=R0913
83
83
password (str): Device password (if unspecified, NAPALM_PASSWORD settings variable will be used)
84
84
secret (str): Device secret password (if unspecified, NAPALM_ARGS["secret"] settings variable will be used)
85
85
napalm_driver (str): Napalm driver name to use to onboard network device
86
+ optional_args (dict): Optional arguments passed to NAPALM and Netmiko
86
87
87
88
Raises:
88
89
OnboardException('fail-config'):
@@ -96,7 +97,14 @@ def __init__( # pylint: disable=R0913
96
97
self .password = password
97
98
self .secret = secret
98
99
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" )
100
108
101
109
self .facts = None
102
110
self .ip_ifs = None
@@ -226,19 +234,21 @@ def get_onboarding_facts(self):
226
234
227
235
driver = get_network_driver (self .napalm_driver )
228
236
229
- optional_args = self .optional_args .copy ()
237
+ # Create NAPALM optional arguments
238
+ napalm_optional_args = self .optional_args .copy ()
239
+
230
240
if self .port :
231
- optional_args ["port" ] = self .port
241
+ napalm_optional_args ["port" ] = self .port
232
242
233
243
if self .secret :
234
- optional_args ["secret" ] = self .secret
244
+ napalm_optional_args ["secret" ] = self .secret
235
245
236
246
napalm_device = driver (
237
247
hostname = self .hostname ,
238
248
username = self .username ,
239
249
password = self .password ,
240
250
timeout = self .timeout ,
241
- optional_args = optional_args ,
251
+ optional_args = napalm_optional_args ,
242
252
)
243
253
244
254
napalm_device .open ()
0 commit comments