[cs615asa] status checks for Amazon EC2 instances
Nicholas Bevacqua
nbevacqu at stevens.edu
Sat Mar 29 15:23:26 EDT 2014
OK, thanks. My other idea was to have a subprocess in the background
constantly try to connect to port 22 and to eventually just give up after a
certain number of tries.
Sincerely,
Nicholas Bevacqua
On Mar 29, 2014 11:10 AM, "John Scire" <jscire at stevens.edu> wrote:
> The way we did it to make sure that the instance was at least somewhat
> ready to connect to was by grepping the very first line of output for the
> hostname used to ssh into the instance (we are using perl). We also have
> some sleep calls, but as soon as the hostname is set up, its a good
> indication that you should be able to connect. Although, sometimes the
> instance still may not be 100% connectable even with this, as ive gotten
> connection refused errors sometimes even when the hostname was up. So we
> also created an ssh test subroutine that tries to connect to the instance
> along with a sleep call in case of failure.
>
> Thanks,
> John Scire
>
> Nicholas Bevacqua <nbevacqu at stevens.edu> wrote:
>
> Hello Everyone,
>
> One issue I have had when working with EC2 instances is that an instance
> state of running does not mean that you can connect to that instance. In
> the web UI, you can see the status checks and will know when they are done.
>
> Unfortunately, I was unable to find any easy way to check this information
> programatically. Using the python library boto, I was able to check the
> instance and system state as shown below. This is not perfect, however, and
> I have needed to add additional sleep calls at the end to ensure there are
> no issues.
>
> Is there some parameter in the instance information that is query-able
> that tells us that status checks are complete (2/2)? I can already find out
> if the instance is running or still pending, but status checks are unknown
> to me.
>
> Thanks.
>
> Sincerely,
> Nicholas Bevacqua
>
>
> ------------------------------------------------------------------------------------------
>
> initializationTimedOut = 0
> doneInitializingInstance = False
> while initializationTimedOut < 5*60: # 5 minutes
> if doneInitializingInstance:
> info("system initialized")
> break
> instance_statuses_list = conn.get_all_instance_status(instance_ids = [
> instance.id])
> if(len(instance_statuses_list) == 1):
> currentSystemStatus = instance_statuses_list[0].system_status
> currentInstanceStatus = instance_statuses_list[0].instance_status
> info("system status: '%s' instance status: '%s'" %
> (currentSystemStatus, currentInstanceStatus))
> if currentSystemStatus == 'Status:initializing' or
> currentInstanceStatus == 'Status:initializing':
> info("waiting for system initialization to finish")
> time.sleep(20)
> initializationTimedOut += 20
> instance.update()
> else:
> info("!system status: '%s' instance status: '%s'" %
> (currentSystemStatus, currentInstanceStatus))
> time.sleep(20)
> doneInitializingInstance = True
> else:
> fatal("unable to get system status. # instances found when
> searching for status is "+len(instance_statuses_list))
>
>
>
> _______________________________________________
> cs615asa mailing list
> cs615asa at lists.stevens.edu
> https://lists.stevens.edu/mailman/listinfo/cs615asa
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.stevens.edu/mailman/private/cs615asa/attachments/20140329/9107cbc7/attachment.html>
More information about the cs615asa
mailing list