Merge "Wrap cluster related function with api_version"

This commit is contained in:
Jenkins 2016-09-01 04:01:05 +00:00 committed by Gerrit Code Review
commit 29099bbc68
2 changed files with 14 additions and 1 deletions

View File

@ -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',

View File

@ -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.