Support volume summary command
This patch added volume summary command support. Change-Id: I7cf6e149b9ce9cae21818c60146e6db9cc2904bd
This commit is contained in:
@@ -557,6 +557,15 @@ class FakeHTTPClient(fake_v2.FakeHTTPClient):
|
|||||||
'levels': {'prefix3': 'WARNING', 'prefix4': 'ERROR'}}]
|
'levels': {'prefix3': 'WARNING', 'prefix4': 'ERROR'}}]
|
||||||
return (200, {}, {'log_levels': levels})
|
return (200, {}, {'log_levels': levels})
|
||||||
|
|
||||||
|
def get_volumes_summary(self, **kw):
|
||||||
|
return 200, {}, {"volume-summary": {'total_size': 5,
|
||||||
|
'total_count': 5,
|
||||||
|
'metadata': {
|
||||||
|
"test_key": ["test_value"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# resource filters
|
# resource filters
|
||||||
#
|
#
|
||||||
|
@@ -204,6 +204,10 @@ class ShellTest(utils.TestCase):
|
|||||||
# NOTE(jdg): we default to detail currently
|
# NOTE(jdg): we default to detail currently
|
||||||
self.assert_called('GET', '/volumes/detail')
|
self.assert_called('GET', '/volumes/detail')
|
||||||
|
|
||||||
|
def test_summary(self):
|
||||||
|
self.run_command('--os-volume-api-version 3.12 summary')
|
||||||
|
self.assert_called('GET', '/volumes/summary')
|
||||||
|
|
||||||
def test_list_with_group_id_before_3_10(self):
|
def test_list_with_group_id_before_3_10(self):
|
||||||
self.assertRaises(exceptions.UnsupportedAttribute,
|
self.assertRaises(exceptions.UnsupportedAttribute,
|
||||||
self.run_command,
|
self.run_command,
|
||||||
|
@@ -94,6 +94,14 @@ class VolumesTest(utils.TestCase):
|
|||||||
cs.assert_called('POST', '/volumes', body=expected)
|
cs.assert_called('POST', '/volumes', body=expected)
|
||||||
self._assert_request_id(vol)
|
self._assert_request_id(vol)
|
||||||
|
|
||||||
|
@ddt.data((False, '/volumes/summary'),
|
||||||
|
(True, '/volumes/summary?all_tenants=True'))
|
||||||
|
def test_volume_summary(self, all_tenants_input):
|
||||||
|
all_tenants, url = all_tenants_input
|
||||||
|
cs = fakes.FakeClient(api_versions.APIVersion('3.12'))
|
||||||
|
cs.volumes.summary(all_tenants=all_tenants)
|
||||||
|
cs.assert_called('GET', url)
|
||||||
|
|
||||||
def test_volume_list_manageable(self):
|
def test_volume_list_manageable(self):
|
||||||
cs = fakes.FakeClient(api_versions.APIVersion('3.8'))
|
cs = fakes.FakeClient(api_versions.APIVersion('3.8'))
|
||||||
cs.volumes.list_manageable('host1', detailed=False)
|
cs.volumes.list_manageable('host1', detailed=False)
|
||||||
|
@@ -600,6 +600,27 @@ def do_metadata(cs, args):
|
|||||||
reverse=True))
|
reverse=True))
|
||||||
|
|
||||||
|
|
||||||
|
@api_versions.wraps('3.12')
|
||||||
|
@utils.arg('--all-tenants',
|
||||||
|
dest='all_tenants',
|
||||||
|
metavar='<0|1>',
|
||||||
|
nargs='?',
|
||||||
|
type=int,
|
||||||
|
const=1,
|
||||||
|
default=utils.env('ALL_TENANTS', default=0),
|
||||||
|
help='Shows details for all tenants. Admin only.')
|
||||||
|
def do_summary(cs, args):
|
||||||
|
"""Get volumes summary."""
|
||||||
|
all_tenants = args.all_tenants
|
||||||
|
info = cs.volumes.summary(all_tenants)
|
||||||
|
|
||||||
|
formatters = ['total_size', 'total_count']
|
||||||
|
if cs.api_version >= api_versions.APIVersion("3.36"):
|
||||||
|
formatters.append('metadata')
|
||||||
|
|
||||||
|
utils.print_dict(info['volume-summary'], formatters=formatters)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.11')
|
@api_versions.wraps('3.11')
|
||||||
def do_group_type_list(cs, args):
|
def do_group_type_list(cs, args):
|
||||||
"""Lists available 'group types'. (Admin only will see private types)"""
|
"""Lists available 'group types'. (Admin only will see private types)"""
|
||||||
|
@@ -124,6 +124,14 @@ class VolumeManager(volumes.VolumeManager):
|
|||||||
return self._action('revert', volume,
|
return self._action('revert', volume,
|
||||||
info={'snapshot_id': base.getid(snapshot.id)})
|
info={'snapshot_id': base.getid(snapshot.id)})
|
||||||
|
|
||||||
|
def summary(self, all_tenants):
|
||||||
|
"""Get volumes summary."""
|
||||||
|
url = "/volumes/summary"
|
||||||
|
if all_tenants:
|
||||||
|
url += "?all_tenants=True"
|
||||||
|
_, body = self.api.client.get(url)
|
||||||
|
return body
|
||||||
|
|
||||||
@api_versions.wraps("3.0")
|
@api_versions.wraps("3.0")
|
||||||
def delete_metadata(self, volume, keys):
|
def delete_metadata(self, volume, keys):
|
||||||
"""Delete specified keys from volumes metadata.
|
"""Delete specified keys from volumes metadata.
|
||||||
|
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Support get volume summary command in V3.12.
|
Reference in New Issue
Block a user