@@ -74,6 +74,7 @@ def __init__(self) -> None:
74
74
self ._password = None
75
75
self ._key_file = None
76
76
self ._sudo = False
77
+ self ._known_hosts = None
77
78
self ._session_sem = None
78
79
self ._stop = False
79
80
self ._conn = None
@@ -94,6 +95,7 @@ def config_help(self) -> dict:
94
95
"key_file" : "private key location" ,
95
96
"reset_cmd" : "command to reset the remote SUT" ,
96
97
"sudo" : "use sudo to access to root shell (default: 0)" ,
98
+ "known_hosts" : "path to custom known_hosts file (optional)" ,
97
99
}
98
100
99
101
async def _reset (self , iobuffer : IOBuffer = None ) -> None :
@@ -161,6 +163,7 @@ def setup(self, **kwargs: dict) -> None:
161
163
self ._user = kwargs .get ("user" , "root" )
162
164
self ._password = kwargs .get ("password" , None )
163
165
self ._key_file = kwargs .get ("key_file" , None )
166
+ self ._known_hosts = kwargs .get ("known_hosts" , None )
164
167
165
168
try :
166
169
self ._port = int (kwargs .get ("port" , "22" ))
@@ -196,13 +199,15 @@ async def communicate(self, iobuffer: IOBuffer = None) -> None:
196
199
host = self ._host ,
197
200
port = self ._port ,
198
201
username = self ._user ,
199
- client_keys = [priv_key ])
202
+ client_keys = [priv_key ],
203
+ known_hosts = self ._known_hosts )
200
204
else :
201
205
self ._conn = await asyncssh .connect (
202
206
host = self ._host ,
203
207
port = self ._port ,
204
208
username = self ._user ,
205
- password = self ._password )
209
+ password = self ._password ,
210
+ known_hosts = self ._known_hosts )
206
211
207
212
# read maximum number of sessions and limit `run_command`
208
213
# concurrent calls to that by using a semaphore
@@ -225,7 +230,8 @@ async def stop(self, iobuffer: IOBuffer = None) -> None:
225
230
self ._stop = True
226
231
try :
227
232
if self ._channels :
228
- self ._logger .info ("Killing %d process(es)" , len (self ._channels ))
233
+ self ._logger .info ("Killing %d process(es)" ,
234
+ len (self ._channels ))
229
235
230
236
for proc in self ._channels :
231
237
proc .kill ()
0 commit comments