mardi 6 octobre 2015

Boto: how to ssh into multiple EC2 instances and start long-running process

I have a script that logs into an existing Amazon EC2 instance and starts a python process using sshclient_from_instance like so:

ssh_client = sshclient_from_instance(instance,
                                 ssh_key_file='path/to/my/pem',
                                 user_name='ubuntu')
status, stdout, stderr = ssh_client.run('python myscript.py')

My problem is that the last line waits until it receives the status, stdout, stderr objects back from the EC2 instance. My myscript.py running on the EC2 instance takes several hours, and I'd like to start 20 of them on different instances in a loop.

Right now I've been killing the boto kernel manually and then restarting it for the next instance, but I can't help but wonder if there isn't a way to get out of that last line and loop over my boto script 20 times.




Aucun commentaire:

Enregistrer un commentaire