From eafde59a3ed028d460e1b449cf50e16f032c94fa Mon Sep 17 00:00:00 2001 From: liuyamin Date: Thu, 17 May 2018 14:48:54 +0800 Subject: [PATCH] Add the parameter service-id for service cleanup command There isn't service_id param in cinderclient. We have this param in cinder, so add this param in the cinderclient. Change-Id: I579741595f91802bcf117029889567f234b5b14c Closes-bug: #1771721 --- cinderclient/tests/unit/v3/test_shell.py | 6 ++++-- cinderclient/v3/shell.py | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cinderclient/tests/unit/v3/test_shell.py b/cinderclient/tests/unit/v3/test_shell.py index 84ca4cbb0..16af0c2a4 100644 --- a/cinderclient/tests/unit/v3/test_shell.py +++ b/cinderclient/tests/unit/v3/test_shell.py @@ -1264,13 +1264,15 @@ class ShellTest(utils.TestCase): 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') + '--resource-id uuid --resource-type Volume ' + '--service-id 1') expected = {'cluster_name': 'clustername', 'host': 'hostname', 'binary': 'binaryname', 'is_up': 'false', 'disabled': 'true', 'resource_id': 'uuid', - 'resource_type': 'Volume'} + 'resource_type': 'Volume', + 'service_id': 1} self.assert_called('POST', '/workers/cleanup', body=expected) diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py index f012cc8d3..8445d2469 100644 --- a/cinderclient/v3/shell.py +++ b/cinderclient/v3/shell.py @@ -1080,12 +1080,19 @@ def do_cluster_disable(cs, args): @utils.arg('--resource-type', metavar='', default=None, choices=('Volume', 'Snapshot'), help='Type of resource to cleanup.') +@utils.arg('--service-id', + metavar='', + type=int, + default=None, + help='The service id field from the DB, not the uuid of the' + ' service. Default=None.') def do_work_cleanup(cs, args): """Request cleanup of services with optional filtering.""" filters = dict(cluster_name=args.cluster, host=args.host, binary=args.binary, is_up=args.is_up, disabled=args.disabled, resource_id=args.resource_id, - resource_type=args.resource_type) + resource_type=args.resource_type, + service_id=args.service_id) filters = {k: v for k, v in filters.items() if v is not None}