阅读背景:

使用Boto确定AWS AMI是否可用

来源:互联网 

I am using Boto to create an AMI of one of my EC2 boxes, and then I would like to spin up more boxes with that AMI, but the run_instances command is barking that my AMI is not available yet.

我正在使用Boto创建一个我的EC2盒子的AMI,然后我想用那个AMI旋转更多的盒子,但是run_instances命令却在咆哮我的AMI还没有。

How can I use boto to query aws to find out when my ami is ready?

如何使用boto查询aws以找出我的ami何时准备好?

The EC2 connection supports a method to get_image

EC2连接支持get_image的方法

But the Image does not have any sort of status attribute

但是Image没有任何状态属性

3 个解决方案

#1


5  

a quick dir of Image led me to Image.state with values like "pending" and "available"

一个快速的Image目录带我到Image.state,其值为“pending”和“available”

#2


2  

In addition to "pending" and "available" there is also the "failed" state. This is the full set of AMI states available.

除了“待定”和“可用”之外,还存在“失败”状态。这是可用的全套AMI状态。

#3


0  

I used the above method but it took a little while for me to figure it out. Not a python person but here is what I did. Hope it helps someone.

我使用了上面的方法,但我花了一点时间才弄明白。不是蟒蛇人,但这就是我所做的。希望它可以帮到某人。

#EC2 Connection
conn = boto.ec2.connect()

image_status = conn.get_all_images(image_ids='ami-XXX')[0]
image_state = image_status.state
print image_state

分享到: