diff options
| author | Mitsuhiro Tanino <mitsuhiro.tanino@hds.com> | 2015-01-02 16:25:17 -0500 |
|---|---|---|
| committer | Mitsuhiro Tanino <mitsuhiro.tanino@hds.com> | 2015-01-05 16:04:43 -0500 |
| commit | 1d38426680f8bd5cc4d8d35aa7c02ec6ba8bf4ef (patch) | |
| tree | ac5541c1f53ff60cdb60425741ed49761363a098 /cinderclient | |
| parent | 59177814a45b067cc47259817f8d9ff96e8d104b (diff) | |
| download | python-cinderclient-1d38426680f8bd5cc4d8d35aa7c02ec6ba8bf4ef.tar.gz | |
Add command to show pool information for backends
An admin-api extension to show pool info was supported at commit
https://review.openstack.org/#/c/119938/.
This change adds a command to show pool information for backends
using the admin-api. This change also closes the gap for end users.
Partial-Bug: 1403902
Change-Id: I20e0828c5403b73bc44d07eebf08e2aa2deb428a
Diffstat (limited to 'cinderclient')
| -rw-r--r-- | cinderclient/tests/v2/fakes.py | 10 | ||||
| -rw-r--r-- | cinderclient/tests/v2/test_shell.py | 8 | ||||
| -rw-r--r-- | cinderclient/tests/v2/test_volumes.py | 8 | ||||
| -rw-r--r-- | cinderclient/v2/shell.py | 18 | ||||
| -rw-r--r-- | cinderclient/v2/volumes.py | 12 |
5 files changed, 56 insertions, 0 deletions
diff --git a/cinderclient/tests/v2/fakes.py b/cinderclient/tests/v2/fakes.py index 18dc305..e224c3c 100644 --- a/cinderclient/tests/v2/fakes.py +++ b/cinderclient/tests/v2/fakes.py @@ -954,3 +954,13 @@ class FakeHTTPClient(base_client.HTTPClient): def post_os_reenable_replica_1234(self, **kw): return (202, {}, {}) + + def get_scheduler_stats_get_pools(self, **kw): + return (200, {}, { + "pools": [ + {"name": "test1@backend1#pool", + "capabilities": { + "pool_name": "pool", + "volume_backend_name": "backend", + "storage_protocol": "iSCSI"}}] + }) diff --git a/cinderclient/tests/v2/test_shell.py b/cinderclient/tests/v2/test_shell.py index 9aceed6..b0b49ce 100644 --- a/cinderclient/tests/v2/test_shell.py +++ b/cinderclient/tests/v2/test_shell.py @@ -550,3 +550,11 @@ class ShellTest(utils.TestCase): 'k2': 'v2'}}} self.run_command('snapshot-create 1234 --metadata k1=v1 k2=v2') self.assert_called_anytime('POST', '/snapshots', partial_body=expected) + + def test_get_pools(self): + self.run_command('get-pools') + self.assert_called('GET', '/scheduler-stats/get_pools') + + def test_get_pools_detail(self): + self.run_command('get-pools --detail') + self.assert_called('GET', '/scheduler-stats/get_pools?detail=True') diff --git a/cinderclient/tests/v2/test_volumes.py b/cinderclient/tests/v2/test_volumes.py index beda5fa..2ad289d 100644 --- a/cinderclient/tests/v2/test_volumes.py +++ b/cinderclient/tests/v2/test_volumes.py @@ -215,3 +215,11 @@ class VolumesTest(utils.TestCase): cs.volumes.reenable(v) cs.assert_called('POST', '/volumes/1234/action', {'os-reenable-replica': None}) + + def test_get_pools(self): + cs.volumes.get_pools('') + cs.assert_called('GET', '/scheduler-stats/get_pools') + + def test_get_pools_detail(self): + cs.volumes.get_pools('--detail') + cs.assert_called('GET', '/scheduler-stats/get_pools?detail=True') diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index a0f6977..99ad245 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -1948,3 +1948,21 @@ def do_cgsnapshot_delete(cs, args): if failure_count == len(args.cgsnapshot): raise exceptions.CommandError("Unable to delete any of specified " "cgsnapshots.") + + +@utils.arg('--detail', + action='store_true', + help='Show detailed information about pools.') +@utils.service_type('volumev2') +def do_get_pools(cs, args): + """Show pool information for backends. Admin only.""" + pools = cs.volumes.get_pools(args.detail) + infos = dict() + infos.update(pools._info) + + for info in infos['pools']: + backend = dict() + backend['name'] = info['name'] + if args.detail: + backend.update(info['capabilities']) + utils.print_dict(backend) diff --git a/cinderclient/v2/volumes.py b/cinderclient/v2/volumes.py index 59853ad..7fc1267 100644 --- a/cinderclient/v2/volumes.py +++ b/cinderclient/v2/volumes.py @@ -160,6 +160,10 @@ class Volume(base.Resource): """Sync the secondary volume with primary for a relationship.""" self.manager.reenable(volume) + def get_pools(self, detail): + """Show pool information for backends.""" + self.manager.get_pools(detail) + class VolumeManager(base.ManagerWithFind): """Manage :class:`Volume` resources.""" @@ -519,3 +523,11 @@ class VolumeManager(base.ManagerWithFind): def reenable(self, volume): """Sync the secondary volume with primary for a relationship.""" return self._action('os-reenable-replica', volume, None) + + def get_pools(self, detail): + """Show pool information for backends.""" + query_string = "" + if detail: + query_string = "?detail=True" + + return self._get('/scheduler-stats/get_pools%s' % query_string, None) |
