diff options
author | Cao Shufeng <caosf.fnst@cn.fujitsu.com> | 2016-08-30 09:47:17 -0400 |
---|---|---|
committer | Cao ShuFeng <caosf.fnst@cn.fujitsu.com> | 2016-09-01 01:45:05 +0000 |
commit | 23aa30f02517d6335c191a3a893ab70c70193a36 (patch) | |
tree | eea753f762f91aed1239d085eece7472a6c45456 | |
parent | 4f794410f1912090b85ec6332ea82feca8b60634 (diff) | |
download | python-cinderclient-23aa30f02517d6335c191a3a893ab70c70193a36.tar.gz |
Wrap cluster related function with api_version
Cluster related functions only support 3.11 microversion
or higher. So it should be wrapped like like one[1],
otherwise these fuctions may be exposed to lib users with
old microversion.
[1]: https://github.com/openstack/python-cinderclient/blob/master/cinderclient/v3/services.py#L82
Change-Id: I20d508c2694cf7e052d709548b9709df0561e2c3
-rw-r--r-- | cinderclient/tests/unit/v3/test_clusters.py | 11 | ||||
-rw-r--r-- | cinderclient/v3/clusters.py | 4 |
2 files changed, 14 insertions, 1 deletions
diff --git a/cinderclient/tests/unit/v3/test_clusters.py b/cinderclient/tests/unit/v3/test_clusters.py index 9b788e7..c2045b6 100644 --- a/cinderclient/tests/unit/v3/test_clusters.py +++ b/cinderclient/tests/unit/v3/test_clusters.py @@ -13,12 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. +from cinderclient import api_versions +from cinderclient import exceptions as exc from cinderclient.tests.unit import utils from cinderclient.tests.unit.v3 import fakes import ddt -cs = fakes.FakeClient() +cs = fakes.FakeClient(api_version=api_versions.APIVersion('3.7')) @ddt.ddt @@ -55,6 +57,13 @@ class ClusterTest(utils.TestCase): self._check_fields_present(lst, detailed) @ddt.data(True, False) + def test_clusters_list_pre_version(self, detailed): + pre_cs = fakes.FakeClient(api_version= + api_versions.APIVersion('3.6')) + self.assertRaises(exc.VersionNotFoundForAPIMethod, + pre_cs.clusters.list, detailed=detailed) + + @ddt.data(True, False) def test_cluster_list_name(self, detailed): lst = cs.clusters.list(name='cluster1@lvmdriver-1', detailed=detailed) diff --git a/cinderclient/v3/clusters.py b/cinderclient/v3/clusters.py index 96f7497..bc50010 100644 --- a/cinderclient/v3/clusters.py +++ b/cinderclient/v3/clusters.py @@ -16,6 +16,7 @@ """ Interface to clusters API """ +from cinderclient import api_versions from cinderclient import base @@ -35,6 +36,7 @@ class ClusterManager(base.ManagerWithFind): url = "%s?%s" % (url, "&".join(filters)) return url + @api_versions.wraps("3.7") def list(self, name=None, binary=None, is_up=None, disabled=None, num_hosts=None, num_down_hosts=None, detailed=False): """Clustered Service list. @@ -53,6 +55,7 @@ class ClusterManager(base.ManagerWithFind): num_down_hosts=num_down_hosts) return self._list(url, 'clusters') + @api_versions.wraps("3.7") def show(self, name, binary=None): """Clustered Service show. @@ -64,6 +67,7 @@ class ClusterManager(base.ManagerWithFind): return self.resource_class(self, body['cluster'], loaded=True, resp=resp) + @api_versions.wraps("3.7") def update(self, name, binary, disabled, disabled_reason=None): """Enable or disable a clustered service. |