Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Boto to get ec2 instance status

I'm using instace.update() to get the status, which returns stopped, running or ...

But there is another status in the ec2 web interface which also shows it's initializing or ... 2/2 checks passed.

Is there a way to get the status of initializing?..

like image 596
user2836163 Avatar asked Dec 11 '13 17:12

user2836163


2 Answers

EDIT:

status=conn.get_all_instance_status(instance_ids=i-****) print status[0].system_status.details
or
print status[0].system_status.details["reachability"]

============================================================
OLDER:

This might help you. It tell status about all the instances, you can use simple 'if' for filtering an instance.

import boto;
ec2=boto.connect_ec2()
instances= ec2.get_only_instances()
for instance in instances:
    print instance.tags['Name'] , " is ", instance.state
like image 145
Sumit Murari Avatar answered Oct 25 '22 03:10

Sumit Murari


That information comes from the DescribeInstanceStatus request and is available in boto via the get_all_instance_status method. See:

http://docs.pythonboto.org/en/latest/ref/ec2.html#boto.ec2.connection.EC2Connection.get_all_instance_status

for details.

like image 22
garnaat Avatar answered Oct 25 '22 02:10

garnaat