You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by se...@apache.org on 2015/03/10 09:09:28 UTC
libcloud git commit: Allow filtering in AWS list_iamges
Repository: libcloud
Updated Branches:
refs/heads/trunk 733e7abfd -> ab629e3cd
Allow filtering in AWS list_iamges
Signed-off-by: Sebastien Goasguen <ru...@gmail.com>
This closes #456
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/ab629e3c
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/ab629e3c
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/ab629e3c
Branch: refs/heads/trunk
Commit: ab629e3cdadef0e5f6d4174babfc8a680d7f4f67
Parents: 733e7ab
Author: Katriel Traum <ka...@google.com>
Authored: Mon Feb 16 15:14:52 2015 +0200
Committer: Sebastien Goasguen <ru...@gmail.com>
Committed: Tue Mar 10 09:08:52 2015 +0100
----------------------------------------------------------------------
CHANGES.rst | 4 ++++
libcloud/compute/drivers/ec2.py | 12 +++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ab629e3c/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index d6fd8d6..93802ca 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -66,6 +66,10 @@ Compute
(LIBCLOUD-671, GITHUB-468)
[Mateusz Korszun]
+- Allow Filtering in EC2 list_images() driver
+ (GITHUB-456, LIBCLOUD-667)
+ [Katriel Traum]
+
DNS
~~~
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ab629e3c/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index 030313a..0e8ae85 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -2046,7 +2046,7 @@ class BaseEC2NodeDriver(NodeDriver):
return sizes
def list_images(self, location=None, ex_image_ids=None, ex_owner=None,
- ex_executableby=None):
+ ex_executableby=None, ex_filters=None):
"""
List all images
@inherits: :class:`NodeDriver.list_images`
@@ -2068,6 +2068,10 @@ class BaseEC2NodeDriver(NodeDriver):
images with public launch permissions.
Valid values: all|self|aws id
+ Ex_filters parameter is used to filter the list of
+ images that should be returned. Only images matchind
+ the filter will be returned.
+
:param ex_image_ids: List of ``NodeImage.id``
:type ex_image_ids: ``list`` of ``str``
@@ -2077,6 +2081,9 @@ class BaseEC2NodeDriver(NodeDriver):
:param ex_executableby: Executable by
:type ex_executableby: ``str``
+ :param ex_filters: Filter by
+ :type ex_filters: ``dict``
+
:rtype: ``list`` of :class:`NodeImage`
"""
params = {'Action': 'DescribeImages'}
@@ -2092,6 +2099,9 @@ class BaseEC2NodeDriver(NodeDriver):
index += 1
params.update({'ImageId.%s' % (index): image_id})
+ if ex_filters:
+ params.update(self._build_filters(ex_filters))
+
images = self._to_images(
self.connection.request(self.path, params=params).object
)