From 3f046e209ffd5729b73dd97a91a5b6cbcdc47ecb Mon Sep 17 00:00:00 2001 From: scottda Date: Wed, 2 Mar 2016 06:55:39 -0700 Subject: [PATCH] Api_version_request.matches does not accept a string or None According to the Cinder devref: https://github.com/openstack/cinder/blob/master/doc/source/devref/api_microversion_dev.rst) you should be able to use the following pattern: def index(self, req): req_version = req.api_version_request if req_version.matches("3.1", "3.5"): ....stuff.... elif req_version.matches("3.6", "3.10"): ....other stuff.... elif req_version > api_version_request.APIVersionRequest("3.10"): ....more stuff..... However, the api_version_request.matches() function will not accept a string, it requires an api_version_request object. This changes the doc to implement an api_version_request object to use this pattern. Closes-Bug: #1550337 Change-Id: I14a943b21e9e98dd848c0c292ca1a1ae941cb98b --- doc/source/api_microversion_dev.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/source/api_microversion_dev.rst b/doc/source/api_microversion_dev.rst index 2572328b9f05..2c62a8f96a13 100644 --- a/doc/source/api_microversion_dev.rst +++ b/doc/source/api_microversion_dev.rst @@ -281,9 +281,14 @@ used to modify behavior based on its value:: req_version = req.api_version_request - if req_version.matches("2.1", "2.5"): + req1_min = api_version_request.APIVersionRequest("2.1") + req1_max = api_version_request.APIVersionRequest("2.5") + req2_min = api_version_request.APIVersionRequest("2.6") + req2_max = api_version_request.APIVersionRequest("2.10") + + if req_version.matches(req1_min, req1_max): ....stuff.... - elif req_version.matches("2.6", "2.10"): + elif req_version.matches(req2min, req2_max): ....other stuff.... elif req_version > api_version_request.APIVersionRequest("2.10"): ....more stuff.....