【问题标题】:Getting AWS AMI properties获取 AWS AMI 属性
【发布时间】:2012-08-17 19:14:49
【问题描述】:

我有一个 AMI 列表,我通过创建 boto 连接获得:

conn_eu = boto.ec2.connect_to_region('eu-west-1')
images = conn_eu.get_all_images(owners=['me'])

我希望能够查看这些 AMI 的属性。属性,例如它们的描述、名称和图像 ID。

【问题讨论】:

    标签: python amazon-ec2 boto ec2-ami


    【解决方案1】:

    这里是每个Print all properties of a Python Classboto.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

    【讨论】:

      【解决方案2】:

      看了image.py之后,我意识到我可以这样做: image.id 获取图片id 和 image.description 获取图像描述

      【讨论】:

        猜你喜欢
        • 2023-01-31
        • 2019-01-07
        • 2012-01-18
        • 1970-01-01
        • 2019-05-08
        • 1970-01-01
        • 2017-08-04
        • 1970-01-01
        • 2019-03-10
        相关资源
        最近更新 更多