Merge "snapshot-list now supports filtering by tenant"
This commit is contained in:
@@ -475,6 +475,16 @@ class ShellTest(utils.TestCase):
|
||||
mock_print_list.assert_called_once_with(mock.ANY, columns,
|
||||
sortby_index=None)
|
||||
|
||||
def test_snapshot_list_filter_tenant_with_all_tenants(self):
|
||||
self.run_command('snapshot-list --all-tenants=1 --tenant 123')
|
||||
self.assert_called('GET',
|
||||
'/snapshots/detail?all_tenants=1&project_id=123')
|
||||
|
||||
def test_snapshot_list_filter_tenant_without_all_tenants(self):
|
||||
self.run_command('snapshot-list --tenant 123')
|
||||
self.assert_called('GET',
|
||||
'/snapshots/detail?all_tenants=1&project_id=123')
|
||||
|
||||
def test_rename(self):
|
||||
# basic rename with positional arguments
|
||||
self.run_command('rename 1234 new-name')
|
||||
|
@@ -665,10 +665,17 @@ def do_image_metadata(cs, args):
|
||||
'form of <key>[:<asc|desc>]. '
|
||||
'Valid keys: %s. '
|
||||
'Default=None.') % ', '.join(base.SORT_KEY_VALUES)))
|
||||
@utils.arg('--tenant',
|
||||
type=str,
|
||||
dest='tenant',
|
||||
nargs='?',
|
||||
metavar='<tenant>',
|
||||
help='Display information from single tenant (Admin only).')
|
||||
@utils.service_type('volumev2')
|
||||
def do_snapshot_list(cs, args):
|
||||
"""Lists all snapshots."""
|
||||
all_tenants = int(os.environ.get("ALL_TENANTS", args.all_tenants))
|
||||
all_tenants = (1 if args.tenant else
|
||||
int(os.environ.get("ALL_TENANTS", args.all_tenants)))
|
||||
|
||||
if args.display_name is not None:
|
||||
args.name = args.display_name
|
||||
@@ -678,6 +685,7 @@ def do_snapshot_list(cs, args):
|
||||
'display_name': args.name,
|
||||
'status': args.status,
|
||||
'volume_id': args.volume_id,
|
||||
'project_id': args.tenant,
|
||||
}
|
||||
|
||||
snapshots = cs.volume_snapshots.list(search_opts=search_opts,
|
||||
|
Reference in New Issue
Block a user