diff options
| author | Gorka Eguileor <geguileo@redhat.com> | 2016-08-26 13:56:18 +0200 |
|---|---|---|
| committer | Gorka Eguileor <geguileo@redhat.com> | 2017-10-03 11:03:28 +0200 |
| commit | 45eb51eb995240120f437bb5ac61ccee22f9dc6b (patch) | |
| tree | 0f2f3737482506c56186f38b610319996a8632c0 /cinderclient/tests/unit/v3 | |
| parent | 1a4176ad87da88a39e4bd04e2c55e8109215d591 (diff) | |
| download | python-cinderclient-45eb51eb995240120f437bb5ac61ccee22f9dc6b.tar.gz | |
Add service cleanup command
Cinder volume services will perform cleanup on start, but when we have
multiple volume services grouped in a cluster, we may want to trigger
cleanup of services that are down.
This patch adds command `work-cleanup` to trigger server cleanups and
prints service nodes that will be cleaned and those that didn't have an
alternative service in the cluster to do the cleanup.
This command will only work on servers supporting API version 3.24 or
higher.
New command:
cinder work-cleanup [--cluster <cluster-name>] [--host <hostname>]
[--binary <binary>]
[--is-up <True|true|False|false>]
[--disabled <True|true|False|false>]
[--resource-id <resource-id>]
[--resource-type <Volume|Snapshot>]
Specs: https://specs.openstack.org/openstack/cinder-specs/specs/newton/ha-aa-cleanup.html
Change-Id: I1c33ffbffcb14f34ee2bda9042e706937b1147d7
Depends-On: If336b6569b171846954ed6eb73f5a4314c6c7e2e
Implements: blueprint cinder-volume-active-active-support
Diffstat (limited to 'cinderclient/tests/unit/v3')
| -rw-r--r-- | cinderclient/tests/unit/v3/fakes.py | 11 | ||||
| -rw-r--r-- | cinderclient/tests/unit/v3/test_shell.py | 20 |
2 files changed, 31 insertions, 0 deletions
diff --git a/cinderclient/tests/unit/v3/fakes.py b/cinderclient/tests/unit/v3/fakes.py index 9fd614a..ca17036 100644 --- a/cinderclient/tests/unit/v3/fakes.py +++ b/cinderclient/tests/unit/v3/fakes.py @@ -563,6 +563,17 @@ class FakeHTTPClient(fake_v2.FakeHTTPClient): } } + def post_workers_cleanup(self, **kw): + response = { + 'cleaning': [{'id': '1', 'cluster_name': 'cluster1', + 'host': 'host1', 'binary': 'binary'}, + {'id': '3', 'cluster_name': 'cluster1', + 'host': 'host3', 'binary': 'binary'}], + 'unavailable': [{'id': '2', 'cluster_name': 'cluster2', + 'host': 'host2', 'binary': 'binary'}], + } + return 200, {}, response + # # resource filters # diff --git a/cinderclient/tests/unit/v3/test_shell.py b/cinderclient/tests/unit/v3/test_shell.py index 8d362e8..4f7b48f 100644 --- a/cinderclient/tests/unit/v3/test_shell.py +++ b/cinderclient/tests/unit/v3/test_shell.py @@ -1168,3 +1168,23 @@ class ShellTest(utils.TestCase): '--name foo --description bar --bootable ' '--volume-type baz --availability-zone az ' '--metadata k1=v1 k2=v2') + + def test_worker_cleanup_before_3_24(self): + self.assertRaises(SystemExit, + self.run_command, + 'work-cleanup fakehost') + + def test_worker_cleanup(self): + self.run_command('--os-volume-api-version 3.24 ' + 'work-cleanup --cluster clustername --host hostname ' + '--binary binaryname --is-up false --disabled true ' + '--resource-id uuid --resource-type Volume') + expected = {'cluster_name': 'clustername', + 'host': 'hostname', + 'binary': 'binaryname', + 'is_up': 'false', + 'disabled': 'true', + 'resource_id': 'uuid', + 'resource_type': 'Volume'} + + self.assert_called('POST', '/workers/cleanup', body=expected) |
