Skip to content

Commit 26a55de

Browse files
sxmatchostackbrian
andcommitted
Add support for Block Storage API mv 3.60
Change I1f43c37c2266e43146637beadc027ccf6dec017e adds time-comparison filtering to the volume list calls (summary and detail) in the Block Storage API microversion 3.60. The current cinderclient filter support will pass these filters correctly, so the only change needed on the client side is to bump the MAX_VERSION so that the client can make calls to mv 3.60. Co-authored-by: Brian Rosmaita <rosmaita.fossdev@gmail.com> Change-Id: Ib4b7cbc7e527c0524336e139e127f19accfb7568 Partially-Implements: bp support-to-query-cinder-resources-filter-by-time-comparison-operators
1 parent 7e8d5ca commit 26a55de

4 files changed

Lines changed: 91 additions & 18 deletions

File tree

cinderclient/api_versions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# key is a deprecated version and value is an alternative version.
3030
DEPRECATED_VERSIONS = {"2": "3"}
3131
DEPRECATED_VERSION = "2.0"
32-
MAX_VERSION = "3.59"
32+
MAX_VERSION = "3.60"
3333
MIN_VERSION = "3.0"
3434

3535
_SUBSTITUTIONS = {}

cinderclient/tests/unit/v3/test_shell.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,24 @@ def test_list_filters(self, resource, query_url):
149149
u'list --filters name=abc --filters size=1',
150150
'expected':
151151
'/volumes/detail?name=abc&size=1'},
152+
{'command':
153+
u'list --filters created_at=lt:2020-01-15T00:00:00',
154+
'expected':
155+
'/volumes/detail?created_at=lt%3A2020-01-15T00%3A00%3A00'},
156+
{'command':
157+
u'list --filters updated_at=gte:2020-02-01T00:00:00,'
158+
u'lt:2020-03-01T00:00:00',
159+
'expected':
160+
'/volumes/detail?updated_at=gte%3A2020-02-01T00%3A00%3A00%2C'
161+
'lt%3A2020-03-01T00%3A00%3A00'},
162+
{'command':
163+
u'list --filters updated_at=gte:2020-02-01T00:00:00,'
164+
u'lt:2020-03-01T00:00:00 --filters created_at='
165+
u'lt:2020-01-15T00:00:00',
166+
'expected':
167+
'/volumes/detail?created_at=lt%3A2020-01-15T00%3A00%3A00'
168+
'&updated_at=gte%3A2020-02-01T00%3A00%3A00%2C'
169+
'lt%3A2020-03-01T00%3A00%3A00'},
152170
# testcases for list group
153171
{'command':
154172
'group-list --filters name=456',

doc/source/cli/details.rst

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,24 +2749,66 @@ Lists all volumes.
27492749
``--tenant [<tenant>]``
27502750
Display information from single tenant (Admin only).
27512751

2752+
.. _cinder-list-filters-usage:
2753+
27522754
``--filters [<key=value> [<key=value> ...]]``
2753-
Filter
2754-
key
2755-
and
2756-
value
2757-
pairs.
2758-
Please
2759-
use
2760-
'cinder
2761-
list-filters'
2762-
to
2763-
check
2764-
enabled
2765-
filters
2766-
from
2767-
server,
2768-
Default=None. (Supported by API version 3.33 and
2769-
later)
2755+
Filter key and value pairs.
2756+
Please use the ``cinder list-filters`` command to check enabled filters
2757+
from server.
2758+
Default=None.
2759+
(Supported by API version 3.33 and later)
2760+
2761+
**Time Comparison Filters**
2762+
2763+
Beginning with API version 3.60, you can apply time comparison filtering
2764+
to the ``created_at`` and ``updated at`` fields. Time must be
2765+
expressed in ISO 8601 format: CCYY-MM-DDThh:mm:ss±hh:mm. The
2766+
±hh:mm value, if included, returns the time zone as an offset from
2767+
UTC.
2768+
2769+
To use time comparison filtering, use the standard ``key=value`` syntax
2770+
for the ``--filters`` option. The allowable keys are:
2771+
2772+
* ``created_at``
2773+
* ``updated_at``
2774+
2775+
The value is a *time comparison statement*, which is specified as follows:
2776+
a comparison operator, followed immediately by a colon (``:``), followed
2777+
immediately by a time expressed in ISO 8601 format. You can filter by a
2778+
*time range* by appending a comma (``,``) followed a second time
2779+
comparison statement.
2780+
2781+
Six *comparison operators* are supported:
2782+
2783+
* ``gt`` (greater than) - return results more recent than the specified
2784+
time
2785+
* ``gte`` (greater than or equal) - return any results matching the
2786+
specified time and also any more recent results
2787+
* ``eq`` (equal) - return any results matching the specified time
2788+
exactly
2789+
* ``neq`` (not equal) - return any results that do not match the
2790+
specified time
2791+
* ``lt`` (less than) - return results older than the specified time
2792+
* ``lte`` (less than or equal) - return any results matching the
2793+
specified time and also any older results
2794+
2795+
**Examples**
2796+
2797+
To filter the response to volumes created before 15 January 2020:
2798+
2799+
.. code-block:: console
2800+
2801+
cinder list --filters created_at=lt:2020-01-15T00:00:00
2802+
2803+
To filter the response to those volumes updated in February 2020:
2804+
2805+
.. code-block:: console
2806+
2807+
cinder list --filters updated_at=gte:2020-02-01T00:00:00,lt:2020-03-01T00:00:00
2808+
2809+
See the `Block Storage API v3 Reference
2810+
<https://docs.openstack.org/api-ref/block-storage/v3/index.html>`_ for
2811+
more information.
27702812

27712813
.. _cinder_list-extensions:
27722814

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
features:
3+
- |
4+
When communicating with the Block Storage API version 3.60 and higher,
5+
you can apply time comparison filtering to the volume list command
6+
on the ``created_at`` or ``updated_at`` fields. Time must be
7+
expressed in ISO 8601 format: CCYY-MM-DDThh:mm:ss±hh:mm. The
8+
±hh:mm value, if included, returns the time zone as an offset from
9+
UTC.
10+
11+
See the `Block Storage service (cinder) command-line client
12+
<https://docs.openstack.org/python-cinderclient/latest/cli/details.html#cinder-list-filters-usage>`_
13+
documentation for usage details.

0 commit comments

Comments
 (0)