@@ -251,12 +251,10 @@ Sometimes, different hosts require different configuration like user names and p
251
251
252
252
host_config = {' host1' : {' user' : ' user1' , ' password' : ' pass' ,
253
253
' port' : 2222 ,
254
- ' private_key' : load_private_key(
255
- ' my_key.pem' )},
254
+ ' private_key' : ' my_key.pem' },
256
255
' host2' : {' user' : ' user2' , ' password' : ' pass' ,
257
256
' port' : 2223 ,
258
- ' private_key' : load_private_key(
259
- open (' my_other_key.pem' ))},
257
+ ' private_key' : ' my_other_key.pem' },
260
258
}
261
259
hosts = host_config.keys()
262
260
@@ -268,7 +266,8 @@ In the above example, ``host1`` will use user name ``user1`` and private key fro
268
266
269
267
.. note ::
270
268
271
- Proxy host cannot be provided via per-host configuration at this time.
269
+ Proxy host configuration is per `ParallelSSHClient ` and cannot be provided via per-host configuration.
270
+ Multiple clients can be used to make use of multiple proxy hosts.
272
271
273
272
Per-Host Command substitution
274
273
******************************
@@ -282,7 +281,7 @@ Number of ``host_args`` items should be at least as many as number of hosts.
282
281
Any Python string format specification characters may be used in command string.
283
282
284
283
285
- In the following example, first host in hosts list will use cmd ``host1_cmd `` second host ``host2_cmd `` and so on
284
+ In the following example, first host in hosts list will use cmd ``host1_cmd `` second host ``host2_cmd `` and so on:
286
285
287
286
.. code-block :: python
288
287
@@ -294,22 +293,40 @@ Command can also have multiple arguments to be substituted.
294
293
295
294
.. code-block :: python
296
295
297
- output = client.run_command(' %s %s ' ,
298
- host_args = ((' host1_cmd1' , ' host1_cmd2' ),
299
- (' host2_cmd1' , ' host2_cmd2' ),
300
- (' host3_cmd1' , ' host3_cmd2' ),))
296
+ output = client.run_command(
297
+ ' %s %s ' ,
298
+ host_args = ((' host1_cmd1' , ' host1_cmd2' ),
299
+ (' host2_cmd1' , ' host2_cmd2' ),
300
+ (' host3_cmd1' , ' host3_cmd2' ),))
301
+
302
+ This expands to the following per host commands:
303
+
304
+ .. code-block :: bash
305
+
306
+ host1: ' host1_cmd1 host1_cmd2'
307
+ host2: ' host2_cmd1 host2_cmd2'
308
+ host3: ' host3_cmd1 host3_cmd2'
301
309
302
310
A list of dictionaries can also be used as ``host_args `` for named argument substitution.
303
311
304
- In the following example, first host in host list will use cmd ``host-index-0 ``, second host ``host-index-1 `` and so on.
312
+ In the following example, first host in host list will use cmd ``echo command-1 ``, second host ``echo command-2 `` and so on.
305
313
306
314
.. code-block :: python
307
315
308
- host_args = [{' cmd' : ' host-index -%s ' % (i,)}
316
+ host_args = [{' cmd' : ' echo command -%s ' % (i,)}
309
317
for i in range (len (client.hosts))]
310
318
output = client.run_command(' %(cmd)s ' , host_args = host_args)
311
319
312
320
321
+ This expands to the following per host commands:
322
+
323
+ .. code-block :: bash
324
+
325
+ host1: ' echo command-0'
326
+ host2: ' echo command-1'
327
+ host3: ' echo command-2'
328
+
329
+
313
330
Run command features and options
314
331
*********************************
315
332
0 commit comments