From 1b8c3c8cb90c03881e0a648f247a186fe4b494de Mon Sep 17 00:00:00 2001 From: lin-hua-cheng Date: Fri, 19 Dec 2014 16:15:13 -0800 Subject: [PATCH] Updated service name to be optional in CLI Service name is optional in the API, updating the CLI for consistency. Change-Id: I94f0eb248a39d2f59edd00a5f90125a5c42525ed Closes-Bug: #1393977 Closes-Bug: #1404073 --- keystoneclient/tests/v2_0/test_shell.py | 17 ++++++++++++++--- keystoneclient/v2_0/shell.py | 4 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/keystoneclient/tests/v2_0/test_shell.py b/keystoneclient/tests/v2_0/test_shell.py index 57bbe9d01..7cfed8012 100644 --- a/keystoneclient/tests/v2_0/test_shell.py +++ b/keystoneclient/tests/v2_0/test_shell.py @@ -268,14 +268,25 @@ class ShellTests(utils.TestCase): self.run_command('tenant-delete 2') self.assert_called('DELETE', '/tenants/2') - def test_service_create(self): + def test_service_create_with_required_arguments_only(self): self.stub_url('POST', ['OS-KSADM', 'services'], json={'OS-KSADM:service': {}}) - self.run_command('service-create --name service1 --type compute') + self.run_command('service-create --type compute') + self.assert_called('POST', '/OS-KSADM/services') + json = {"OS-KSADM:service": {"type": "compute", + "name": None, + "description": None}} + self.assertRequestBodyIs(json=json) + + def test_service_create_with_all_arguments(self): + self.stub_url('POST', ['OS-KSADM', 'services'], + json={'OS-KSADM:service': {}}) + self.run_command('service-create --type compute ' + '--name service1 --description desc1') self.assert_called('POST', '/OS-KSADM/services') json = {"OS-KSADM:service": {"type": "compute", "name": "service1", - "description": None}} + "description": "desc1"}} self.assertRequestBodyIs(json=json) def test_service_get(self): diff --git a/keystoneclient/v2_0/shell.py b/keystoneclient/v2_0/shell.py index a2cb1abd2..9920555a0 100755 --- a/keystoneclient/v2_0/shell.py +++ b/keystoneclient/v2_0/shell.py @@ -248,11 +248,11 @@ def do_tenant_delete(kc, args): kc.tenants.delete(tenant) -@utils.arg('--name', metavar='', required=True, - help='Name of new service (must be unique).') @utils.arg('--type', metavar='', required=True, help='Service type (one of: identity, compute, network, ' 'image, object-store, or other service identifier string).') +@utils.arg('--name', metavar='', + help='Name of new service (must be unique).') @utils.arg('--description', metavar='', help='Description of service.') def do_service_create(kc, args):