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
This commit is contained in:
parent
4f794410f1
commit
23aa30f025
cinderclient
@ -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
|
||||
@ -54,6 +56,13 @@ class ClusterTest(utils.TestCase):
|
||||
self._assert_request_id(lst)
|
||||
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',
|
||||
|
@ -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.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user