amazon web services - EC2 instance creation and polling until state is 'running' using boto library -


i want create new spot instance using boto library , run commands on using fabric. i'm using below code

instance = reservations[0].instances[0] status = instance.update() tries = 40 i=0 while status == 'pending':   log.info("status of instance: [ " + job_instance_id + " ] pending")   time.sleep(10)   status = instance.update()   i=i+1   if > tries:     break log.info("status of instance [ " + job_instance_id + " ] " + status) if status == 'running':   log.info("adding tag")   instance.add_tag("name", "test_tag")   public_dns_name = instance.public_dns_name   log.info("host name : " + public_dns_name)   init_instance(public_dns_name) 

in init_instance i'm running commands using fabric. these commands fail "unable connect host" error. works fine without issues. can please let me know why fail sometimes? how can handle this? keep polling untill state of instance changes 'running' , run commands via ssh after instance state moves 'running'


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -