Allow search on containers

Implements search_containers, which can take a JMESPath expression or
a dict of container attributes to filter containers in.

Story: #2003694
Task: #26338

Change-Id: If348e20f14292660044b215a54a7adc66c37671e
This commit is contained in:
Samuel de Medeiros Queiroz 2018-09-07 06:33:25 -03:00
parent f22b9a88db
commit a967956e47
2 changed files with 23 additions and 0 deletions

View File

@ -7267,6 +7267,23 @@ class OpenStackCloud(_normalize.Normalizer):
data = self._object_store_client.get('/', params=dict(format='json'))
return self._get_and_munchify(None, data)
def search_containers(self, name=None, filters=None):
"""Search containers.
:param string name: container name.
:param filters: a dict containing additional filters to use.
OR
A string containing a jmespath expression for further filtering.
Example:: "[?last_name==`Smith`] | [?other.gender]==`Female`]"
:returns: a list of ``munch.Munch`` containing the containers.
:raises: ``OpenStackCloudException``: if something goes wrong during
the OpenStack API call.
"""
containers = self.list_containers()
return _utils._filter_list(containers, name, filters)
def get_container(self, name, skip_cache=False):
"""Get metadata about a container.

View File

@ -0,0 +1,6 @@
---
features:
- |
Containers are now searchable both with a JMESPath expression or a dict of
container attributes via the
``openstack.connection.Connection.search_containers`` function.