[cs615asa] status checks for Amazon EC2 instances

Nicholas Bevacqua nbevacqu at stevens.edu
Sat Mar 29 06:45:19 EDT 2014


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))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.stevens.edu/mailman/private/cs615asa/attachments/20140329/8d609f5b/attachment.html>


More information about the cs615asa mailing list