获取AWS AMI属性

3
我有一个AMI列表,是通过创建Boto连接得到的:
conn_eu = boto.ec2.connect_to_region('eu-west-1')
images = conn_eu.get_all_images(owners=['me'])

我希望能够查看这些Amazon机器映像(AMI)的属性,例如它们的描述、名称和映像ID。
2个回答

2
以下是根据 Print all properties of a Python Class 列出的 boto.ec2.image.Image 对象所有属性内容:
from boto.ec2 import connect_to_region
ec2_connection = connect_to_region("us-west-2",
          aws_access_key_id="...",
          aws_secret_access_key="...")
images = ec2_connection.get_all_images(image_ids=["ami-xxxxxxxxx"])
for k in vars(images[0]).keys():
       print "{0}".format(k)

(或者,如果想同时打印值,可以使用以下方式):
for k,v in vars(images[0]).iteritems():
       print "{0}:{1}".format(k,v)

root_device_type ramdisk_id id owner_alias billing_products tags platform state location type virtualization_type sriov_net_support architecture description block_device_mapping kernel_id owner_id is_public instance_lifecycle creationDate name hypervisor region item connection root_device_name ownerId product_codes

根设备类型 RAM磁盘ID ID 所有者别名 计费产品 标签 平台 状态 位置 类型 虚拟化类型 SR-IOV网络支持 架构 描述 块设备映射 内核ID 所有者ID 是否公共 实例生命周期 创建日期 名称 虚拟机监视器 区域 项 连接 根设备名称 所有者ID 产品代码

2

在查看了image.py之后,我意识到只需执行以下操作即可:
使用 image.id 获取镜像ID
使用 image.description 获取镜像描述


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接