How to retrieve AMI platform?

心不动则不痛 提交于 2019-12-12 05:53:20

问题


How do I retrieve platform (windows, Linux/Unix) value for an instance/AMI? AWS Console shows the platform value for an AMI.

I have dumped the dict property on the AMI object but it does not show the correct platform?


回答1:


There is an attribute of the Image object called platform. This attribute will have a value of windows if the image is a Windows image or None if it is Linux. For example:

import boto.ec2
c = boto.ec2.connect_to_region('us-east-1')
images = c.get_all_images(owners='self')
for image in images:
    if image.platform == 'windows':
        print('Image {} is a Windows Image'.format(image.id))
    else:
        print('Image {} is a Linux Image'.format(image.id))


来源:https://stackoverflow.com/questions/29175894/how-to-retrieve-ami-platform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!