Merge "Add cluster support in manage listings"
This commit is contained in:
commit
24e46d116a
@ -693,6 +693,11 @@ class ShellTest(utils.TestCase):
|
|||||||
'manageable-list fakehost --detailed False')
|
'manageable-list fakehost --detailed False')
|
||||||
self.assert_called('GET', '/manageable_volumes?host=fakehost')
|
self.assert_called('GET', '/manageable_volumes?host=fakehost')
|
||||||
|
|
||||||
|
def test_volume_manageable_list_cluster(self):
|
||||||
|
self.run_command('--os-volume-api-version 3.17 '
|
||||||
|
'manageable-list --cluster dest')
|
||||||
|
self.assert_called('GET', '/manageable_volumes/detail?cluster=dest')
|
||||||
|
|
||||||
def test_snapshot_manageable_list(self):
|
def test_snapshot_manageable_list(self):
|
||||||
self.run_command('--os-volume-api-version 3.8 '
|
self.run_command('--os-volume-api-version 3.8 '
|
||||||
'snapshot-manageable-list fakehost')
|
'snapshot-manageable-list fakehost')
|
||||||
@ -708,6 +713,36 @@ class ShellTest(utils.TestCase):
|
|||||||
'snapshot-manageable-list fakehost --detailed False')
|
'snapshot-manageable-list fakehost --detailed False')
|
||||||
self.assert_called('GET', '/manageable_snapshots?host=fakehost')
|
self.assert_called('GET', '/manageable_snapshots?host=fakehost')
|
||||||
|
|
||||||
|
def test_snapshot_manageable_list_cluster(self):
|
||||||
|
self.run_command('--os-volume-api-version 3.17 '
|
||||||
|
'snapshot-manageable-list --cluster dest')
|
||||||
|
self.assert_called('GET', '/manageable_snapshots/detail?cluster=dest')
|
||||||
|
|
||||||
|
@ddt.data('', 'snapshot-')
|
||||||
|
def test_manageable_list_cluster_before_3_17(self, prefix):
|
||||||
|
self.assertRaises(exceptions.UnsupportedAttribute,
|
||||||
|
self.run_command,
|
||||||
|
'--os-volume-api-version 3.16 '
|
||||||
|
'%smanageable-list --cluster dest' % prefix)
|
||||||
|
|
||||||
|
@mock.patch('cinderclient.shell.CinderClientArgumentParser.error')
|
||||||
|
@ddt.data('', 'snapshot-')
|
||||||
|
def test_manageable_list_mutual_exclusion(self, prefix, error_mock):
|
||||||
|
error_mock.side_effect = SystemExit
|
||||||
|
self.assertRaises(SystemExit,
|
||||||
|
self.run_command,
|
||||||
|
'--os-volume-api-version 3.17 '
|
||||||
|
'%smanageable-list fakehost --cluster dest' % prefix)
|
||||||
|
|
||||||
|
@mock.patch('cinderclient.shell.CinderClientArgumentParser.error')
|
||||||
|
@ddt.data('', 'snapshot-')
|
||||||
|
def test_manageable_list_missing_required(self, prefix, error_mock):
|
||||||
|
error_mock.side_effect = SystemExit
|
||||||
|
self.assertRaises(SystemExit,
|
||||||
|
self.run_command,
|
||||||
|
'--os-volume-api-version 3.17 '
|
||||||
|
'%smanageable-list' % prefix)
|
||||||
|
|
||||||
def test_list_messages(self):
|
def test_list_messages(self):
|
||||||
self.run_command('--os-volume-api-version 3.3 message-list')
|
self.run_command('--os-volume-api-version 3.3 message-list')
|
||||||
self.assert_called('GET', '/messages')
|
self.assert_called('GET', '/messages')
|
||||||
|
@ -1139,10 +1139,20 @@ def do_manage(cs, args):
|
|||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.8')
|
@api_versions.wraps('3.8')
|
||||||
@utils.arg('host',
|
# NOTE(geguileo): host is positional but optional in order to maintain backward
|
||||||
metavar='<host>',
|
# compatibility even with mutually exclusive arguments. If version is < 3.16
|
||||||
help='Cinder host on which to list manageable volumes; '
|
# then only host positional argument will be possible, and since the
|
||||||
'takes the form: host@backend-name#pool')
|
# exclusive_arg group has required=True it will be required even if it's
|
||||||
|
# optional.
|
||||||
|
@utils.exclusive_arg('source', 'host', required=True, nargs='?',
|
||||||
|
metavar='<host>',
|
||||||
|
help='Cinder host on which to list manageable volumes; '
|
||||||
|
'takes the form: host@backend-name#pool')
|
||||||
|
@utils.exclusive_arg('source', '--cluster', required=True,
|
||||||
|
metavar='CLUSTER',
|
||||||
|
help='Cinder cluster on which to list manageable '
|
||||||
|
'volumes; takes the form: cluster@backend-name#pool',
|
||||||
|
start_version='3.17')
|
||||||
@utils.arg('--detailed',
|
@utils.arg('--detailed',
|
||||||
metavar='<detailed>',
|
metavar='<detailed>',
|
||||||
default=True,
|
default=True,
|
||||||
@ -1174,9 +1184,11 @@ def do_manageable_list(cs, args):
|
|||||||
"""Lists all manageable volumes."""
|
"""Lists all manageable volumes."""
|
||||||
# pylint: disable=function-redefined
|
# pylint: disable=function-redefined
|
||||||
detailed = strutils.bool_from_string(args.detailed)
|
detailed = strutils.bool_from_string(args.detailed)
|
||||||
|
cluster = getattr(args, 'cluster', None)
|
||||||
volumes = cs.volumes.list_manageable(host=args.host, detailed=detailed,
|
volumes = cs.volumes.list_manageable(host=args.host, detailed=detailed,
|
||||||
marker=args.marker, limit=args.limit,
|
marker=args.marker, limit=args.limit,
|
||||||
offset=args.offset, sort=args.sort)
|
offset=args.offset, sort=args.sort,
|
||||||
|
cluster=cluster)
|
||||||
columns = ['reference', 'size', 'safe_to_manage']
|
columns = ['reference', 'size', 'safe_to_manage']
|
||||||
if detailed:
|
if detailed:
|
||||||
columns.extend(['reason_not_safe', 'cinder_id', 'extra_info'])
|
columns.extend(['reason_not_safe', 'cinder_id', 'extra_info'])
|
||||||
@ -1601,10 +1613,19 @@ def do_service_list(cs, args):
|
|||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.8')
|
@api_versions.wraps('3.8')
|
||||||
@utils.arg('host',
|
# NOTE(geguileo): host is positional but optional in order to maintain backward
|
||||||
metavar='<host>',
|
# compatibility even with mutually exclusive arguments. If version is < 3.16
|
||||||
help='Cinder host on which to list manageable snapshots; '
|
# then only host positional argument will be possible, and since the
|
||||||
'takes the form: host@backend-name#pool')
|
# exclusive_arg group has required=True it will be required even if it's
|
||||||
|
# optional.
|
||||||
|
@utils.exclusive_arg('source', 'host', required=True, nargs='?',
|
||||||
|
metavar='<host>',
|
||||||
|
help='Cinder host on which to list manageable snapshots; '
|
||||||
|
'takes the form: host@backend-name#pool')
|
||||||
|
@utils.exclusive_arg('source', '--cluster', required=True,
|
||||||
|
help='Cinder cluster on which to list manageable '
|
||||||
|
'snapshots; takes the form: cluster@backend-name#pool',
|
||||||
|
start_version='3.17')
|
||||||
@utils.arg('--detailed',
|
@utils.arg('--detailed',
|
||||||
metavar='<detailed>',
|
metavar='<detailed>',
|
||||||
default=True,
|
default=True,
|
||||||
@ -1636,12 +1657,14 @@ def do_snapshot_manageable_list(cs, args):
|
|||||||
"""Lists all manageable snapshots."""
|
"""Lists all manageable snapshots."""
|
||||||
# pylint: disable=function-redefined
|
# pylint: disable=function-redefined
|
||||||
detailed = strutils.bool_from_string(args.detailed)
|
detailed = strutils.bool_from_string(args.detailed)
|
||||||
|
cluster = getattr(args, 'cluster', None)
|
||||||
snapshots = cs.volume_snapshots.list_manageable(host=args.host,
|
snapshots = cs.volume_snapshots.list_manageable(host=args.host,
|
||||||
detailed=detailed,
|
detailed=detailed,
|
||||||
marker=args.marker,
|
marker=args.marker,
|
||||||
limit=args.limit,
|
limit=args.limit,
|
||||||
offset=args.offset,
|
offset=args.offset,
|
||||||
sort=args.sort)
|
sort=args.sort,
|
||||||
|
cluster=cluster)
|
||||||
columns = ['reference', 'size', 'safe_to_manage', 'source_reference']
|
columns = ['reference', 'size', 'safe_to_manage', 'source_reference']
|
||||||
if detailed:
|
if detailed:
|
||||||
columns.extend(['reason_not_safe', 'cinder_id', 'extra_info'])
|
columns.extend(['reason_not_safe', 'cinder_id', 'extra_info'])
|
||||||
|
@ -65,10 +65,11 @@ class Snapshot(base.Resource):
|
|||||||
description=description, metadata=metadata)
|
description=description, metadata=metadata)
|
||||||
|
|
||||||
def list_manageable(self, host, detailed=True, marker=None, limit=None,
|
def list_manageable(self, host, detailed=True, marker=None, limit=None,
|
||||||
offset=None, sort=None):
|
offset=None, sort=None, cluster=None):
|
||||||
return self.manager.list_manageable(host, detailed=detailed,
|
return self.manager.list_manageable(host, detailed=detailed,
|
||||||
marker=marker, limit=limit,
|
marker=marker, limit=limit,
|
||||||
offset=offset, sort=sort)
|
offset=offset, sort=sort,
|
||||||
|
cluster=cluster)
|
||||||
|
|
||||||
def unmanage(self, snapshot):
|
def unmanage(self, snapshot):
|
||||||
"""Unmanage a snapshot."""
|
"""Unmanage a snapshot."""
|
||||||
@ -212,11 +213,12 @@ class SnapshotManager(base.ManagerWithFind):
|
|||||||
}
|
}
|
||||||
return self._create('/os-snapshot-manage', body, 'snapshot')
|
return self._create('/os-snapshot-manage', body, 'snapshot')
|
||||||
|
|
||||||
@api_versions.wraps("3.8")
|
@api_versions.wraps('3.8')
|
||||||
def list_manageable(self, host, detailed=True, marker=None, limit=None,
|
def list_manageable(self, host, detailed=True, marker=None, limit=None,
|
||||||
offset=None, sort=None):
|
offset=None, sort=None, cluster=None):
|
||||||
|
search_opts = {'cluster': cluster} if cluster else {'host': host}
|
||||||
url = self._build_list_url("manageable_snapshots", detailed=detailed,
|
url = self._build_list_url("manageable_snapshots", detailed=detailed,
|
||||||
search_opts={'host': host}, marker=marker,
|
search_opts=search_opts, marker=marker,
|
||||||
limit=limit, offset=offset, sort=sort)
|
limit=limit, offset=offset, sort=sort)
|
||||||
return self._list(url, "manageable-snapshots")
|
return self._list(url, "manageable-snapshots")
|
||||||
|
|
||||||
|
@ -261,11 +261,12 @@ class VolumeManager(volumes.VolumeManager):
|
|||||||
body['volume']['cluster'] = cluster
|
body['volume']['cluster'] = cluster
|
||||||
return self._create('/os-volume-manage', body, 'volume')
|
return self._create('/os-volume-manage', body, 'volume')
|
||||||
|
|
||||||
@api_versions.wraps("3.8")
|
@api_versions.wraps('3.8')
|
||||||
def list_manageable(self, host, detailed=True, marker=None, limit=None,
|
def list_manageable(self, host, detailed=True, marker=None, limit=None,
|
||||||
offset=None, sort=None):
|
offset=None, sort=None, cluster=None):
|
||||||
|
search_opts = {'cluster': cluster} if cluster else {'host': host}
|
||||||
url = self._build_list_url("manageable_volumes", detailed=detailed,
|
url = self._build_list_url("manageable_volumes", detailed=detailed,
|
||||||
search_opts={'host': host}, marker=marker,
|
search_opts=search_opts, marker=marker,
|
||||||
limit=limit, offset=offset, sort=sort)
|
limit=limit, offset=offset, sort=sort)
|
||||||
return self._list(url, "manageable-volumes")
|
return self._list(url, "manageable-volumes")
|
||||||
|
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Cinder ``manageable-list`` and ``snapshot-manageable-list`` commands now
|
||||||
|
accept ``--cluster`` argument to specify the backend we want to list for
|
||||||
|
microversion 3.17 and higher. This argument and the ``host`` positional
|
||||||
|
argument are mutually exclusive.
|
Loading…
Reference in New Issue
Block a user