Get a list of all images (but only ami, not aki or ari)

1,298 views
Skip to first unread message

Neverland

unread,
Dec 17, 2009, 6:01:45 AM12/17/09
to boto-users
Hello,

it is easy to get a list of all images in a region via:

liste_images = conn_region.get_all_images()

But this needs a lot of time because all images (ami, aki and ari) are
fetched.

Is it possible to fetch only the ami images?

Best Regards,
Christian

Mitchell Garnaat

unread,
Dec 17, 2009, 7:11:06 AM12/17/09
to boto-...@googlegroups.com
No, unfortunately the EC2 API provides no ability to filter the returned list on the server side.  The only option is to get all of the results and then filter on the client-side.

Mitch


--

You received this message because you are subscribed to the Google Groups "boto-users" group.
To post to this group, send email to boto-...@googlegroups.com.
To unsubscribe from this group, send email to boto-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/boto-users?hl=en.



Neverland

unread,
Jan 4, 2010, 11:58:31 AM1/4/10
to boto-users
Hello,

when I try to get a list of all images in an EC2 region via
get_all_images() with boto 1.9b inside GAE, I have this error:

<unknown>:23781:38: unclosed token
Traceback (most recent call last):
File "/base/python_lib/versions/1/google/appengine/ext/webapp/
__init__.py", line 507, in __call__
handler.get(*groups)
File "/base/data/home/apps/koalacloud/2.338932317309084728/
koala.py", line 1888, in get
liste_images = conn_region.get_all_images()
File "/base/data/home/apps/koalacloud/2.338932317309084728/boto/ec2/
connection.py", line 119, in get_all_images
return self.get_list('DescribeImages', params, [('item', Image)])
File "/base/data/home/apps/koalacloud/2.338932317309084728/boto/
connection.py", line 610, in get_list
xml.sax.parseString(body, h)
File "/base/python_dist/lib/python2.5/xml/sax/__init__.py", line 49,
in parseString
parser.parse(inpsrc)
File "/base/python_dist/lib/python2.5/xml/sax/expatreader.py", line
107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/base/python_dist/lib/python2.5/xml/sax/xmlreader.py", line
125, in parse
self.close()
File "/base/python_dist/lib/python2.5/xml/sax/expatreader.py", line
217, in close
self.feed("", isFinal = 1)
File "/base/python_dist/lib/python2.5/xml/sax/expatreader.py", line
211, in feed
self._err_handler.fatalError(exc)
File "/base/python_dist/lib/python2.5/xml/sax/handler.py", line 38,
in fatalError
raise exception
SAXParseException: <unknown>:23781:38: unclosed token

I think the list of images at EC2 is too long and GAE stops fetching
it. With Eucalyptus (I have only 10 images there) it's no problem to
fetch the list of images.

Has anybody here an idea how to get around a problem?

Best Regards,
Christian

Mitchell Garnaat

unread,
Jan 4, 2010, 12:08:13 PM1/4/10
to boto-...@googlegroups.com
I'm not having any problem getting the list outside of GAE.  However, the list is HUGE and there is no paging mechanism and no way to filter results on the server side so I can imagine that it might be hitting some limit in GAE.  If that's the case, I'm afraid I am not aware of any workarounds but perhaps some other GAE users will know of something.

Mitch


Best Regards,
  Christian

Neverland

unread,
Jan 4, 2010, 6:47:33 PM1/4/10
to boto-users
It is definitively a GAE issue and not a boto problem.

In my oppinion it is also not a good idea of amazon lacking the


ability to filter the returned
list on the server side.

Christian

kevin.d...@datalogix.com

unread,
May 8, 2015, 12:58:45 PM5/8/15
to boto-...@googlegroups.com
Stale post, but found in recent search.

Check out http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html for the filter options.

Using this filter, I was able to capture only the AMIs owned by my account:

    images = ec2_connection.get_all_images(
        filters={
            'image_type': 'machine',
            'owner_id': '123456789',
        },
    )

Without the owner_id filter, the returned count was 41,000+

Without the owner_id, there were 41,000+ amis returned.
Reply all
Reply to author
Forward
0 new messages