@@ -11,18 +11,23 @@ def netmiko_send_commands(task: Task, commands: list()) -> Result:
1111
1212 :returns: nornir Result object
1313 """
14+ try :
15+ secret = task .host .connection_options ["netmiko" ]["extras" ]["secret" ]
16+ except KeyError :
17+ secret = None
18+
1419 device_params = {
1520 "host" : task .host .hostname ,
1621 "device_type" : device_mapper (os_type = task .host .platform , proto = "netmiko" ),
1722 "port" : task .host .port ,
1823 "username" : task .host .username ,
1924 "password" : task .host .password ,
20- "secret" : task .host .connection_options ["netmiko" ]["extras" ].get ("secret" , None ),
25+ "secret" : secret ,
26+ "ssh_config_file" : task .nornir .config .ssh .config_file or None ,
2127 }
28+ output = str ()
2229
2330 with ConnectHandler (** device_params ) as conn :
24- output = str ()
25-
2631 for command in commands :
2732 output += conn .send_command (command )
2833
@@ -37,13 +42,19 @@ def netmiko_send_config(task: Task, commands: list()) -> Result:
3742
3843 :returns: nornir Result object
3944 """
45+ try :
46+ secret = task .host .connection_options ["netmiko" ]["extras" ]["secret" ]
47+ except KeyError :
48+ secret = None
49+
4050 device_params = {
4151 "host" : task .host .hostname ,
4252 "device_type" : device_mapper (os_type = task .host .platform , proto = "netmiko" ),
4353 "port" : task .host .port ,
4454 "username" : task .host .username ,
4555 "password" : task .host .password ,
46- "secret" : task .host .connection_options ["netmiko" ]["extras" ].get ("secret" , None ),
56+ "secret" : secret ,
57+ "ssh_config_file" : task .nornir .config .ssh .config_file or None ,
4758 }
4859
4960 with ConnectHandler (** device_params ) as conn :
0 commit comments