take_action() method from command.Command shouldn't return

command.Command and command.Showone are base classes implemented
in cliff framework. Showone extends Command to allow take_action()
to return data to be formatted using a user-selectable formatter.
Most of the classes which are extended from Command in
openstackclient/identity/v3/ in some cases return data or return
nothing where it is not necessary, this commit fixes most of them.

Change-Id: I84c72ea4d6680f8bdbef5449316dd9a8af8c8286
Closes-Bug: 1550892
This commit is contained in:
Mohan Muppidi 2016-02-28 09:43:44 +00:00
parent 2819450be5
commit 3d7430463c
16 changed files with 18 additions and 43 deletions

View File

@ -60,7 +60,6 @@ class DeleteConsumer(command.Command):
consumer = utils.find_resource(
identity_client.oauth1.consumers, parsed_args.consumer)
identity_client.oauth1.consumers.delete(consumer.id)
return
class ListConsumer(command.Lister):
@ -107,7 +106,6 @@ class SetConsumer(command.Command):
consumer = identity_client.oauth1.consumers.update(
consumer.id, **kwargs)
return
class ShowConsumer(command.ShowOne):

View File

@ -84,7 +84,6 @@ class DeleteCredential(command.Command):
def take_action(self, parsed_args):
identity_client = self.app.client_manager.identity
identity_client.credentials.delete(parsed_args.credential)
return
class ListCredential(command.Lister):
@ -155,8 +154,6 @@ class SetCredential(command.Command):
blob=parsed_args.data,
project=project)
return
class ShowCredential(command.ShowOne):
"""Show credential command"""

View File

@ -100,7 +100,6 @@ class DeleteDomain(command.Command):
domain = utils.find_resource(identity_client.domains,
parsed_args.domain)
identity_client.domains.delete(domain.id)
return
class ListDomain(command.Lister):
@ -168,7 +167,6 @@ class SetDomain(command.Command):
sys.stdout.write("Domain not updated, no arguments present")
return
identity_client.domains.update(domain.id, **kwargs)
return
class ShowDomain(command.ShowOne):

View File

@ -109,7 +109,6 @@ class DeleteEndpoint(command.Command):
endpoint_id = utils.find_resource(identity_client.endpoints,
parsed_args.endpoint).id
identity_client.endpoints.delete(endpoint_id)
return
class ListEndpoint(command.Lister):
@ -221,7 +220,6 @@ class SetEndpoint(command.Command):
if parsed_args.service:
service = common.find_service(identity_client, parsed_args.service)
service_id = service.id
enabled = None
if parsed_args.enabled:
enabled = True
@ -237,8 +235,6 @@ class SetEndpoint(command.Command):
enabled=enabled
)
return
class ShowEndpoint(command.ShowOne):
"""Display endpoint details"""

View File

@ -83,7 +83,6 @@ class DeleteProtocol(command.Command):
identity_client = self.app.client_manager.identity
identity_client.federation.protocols.delete(
parsed_args.identity_provider, parsed_args.federation_protocol)
return
class ListProtocols(command.Lister):

View File

@ -182,7 +182,6 @@ class DeleteGroup(command.Command):
group,
parsed_args.domain)
identity_client.groups.delete(group_obj.id)
return
class ListGroup(command.Lister):
@ -322,7 +321,6 @@ class SetGroup(command.Command):
sys.stderr.write("Group not updated, no arguments present")
return
identity_client.groups.update(group.id, **kwargs)
return
class ShowGroup(command.ShowOne):

View File

@ -102,7 +102,6 @@ class DeleteIdentityProvider(command.Command):
identity_client = self.app.client_manager.identity
identity_client.federation.identity_providers.delete(
parsed_args.identity_provider)
return
class ListIdentityProvider(command.Lister):

View File

@ -121,7 +121,6 @@ class DeleteMapping(command.Command):
identity_client = self.app.client_manager.identity
identity_client.federation.mappings.delete(parsed_args.mapping)
return
class ListMapping(command.Lister):

View File

@ -69,7 +69,6 @@ class DeletePolicy(command.Command):
def take_action(self, parsed_args):
identity_client = self.app.client_manager.identity
identity_client.policies.delete(parsed_args.policy)
return
class ListPolicy(command.Lister):
@ -139,7 +138,6 @@ class SetPolicy(command.Command):
sys.stdout.write('Policy not updated, no arguments present \n')
return
identity_client.policies.update(parsed_args.policy, **kwargs)
return
class ShowPolicy(command.ShowOne):

View File

@ -153,7 +153,6 @@ class DeleteProject(command.Command):
project_obj = utils.find_resource(identity_client.projects,
project)
identity_client.projects.delete(project_obj.id)
return
class ListProject(command.Lister):
@ -267,8 +266,8 @@ class SetProject(command.Command):
and not parsed_args.property
and not parsed_args.disable):
return
project = common.find_project(identity_client, parsed_args.project,
project = common.find_project(identity_client,
parsed_args.project,
parsed_args.domain)
kwargs = {}
@ -284,7 +283,6 @@ class SetProject(command.Command):
kwargs.update(parsed_args.property)
identity_client.projects.update(project.id, **kwargs)
return
class ShowProject(command.ShowOne):

View File

@ -75,7 +75,6 @@ class DeleteRegion(command.Command):
identity_client = self.app.client_manager.identity
identity_client.regions.delete(parsed_args.region)
return
class ListRegion(command.Lister):
@ -135,7 +134,6 @@ class SetRegion(command.Command):
if not parsed_args.parent_region and not parsed_args.description:
return
kwargs = {}
if parsed_args.description:
kwargs['description'] = parsed_args.description
@ -143,7 +141,6 @@ class SetRegion(command.Command):
kwargs['parent_region'] = parsed_args.parent_region
identity_client.regions.update(parsed_args.region, **kwargs)
return
class ShowRegion(command.ShowOne):

View File

@ -123,7 +123,6 @@ class AddRole(command.Command):
if (not parsed_args.user and not parsed_args.domain
and not parsed_args.group and not parsed_args.project):
return
role = utils.find_resource(
identity_client.roles,
parsed_args.role,
@ -138,7 +137,6 @@ class AddRole(command.Command):
return
identity_client.roles.grant(role.id, **kwargs)
return
class CreateRole(command.ShowOne):
@ -197,7 +195,6 @@ class DeleteRole(command.Command):
role,
)
identity_client.roles.delete(role_obj.id)
return
class ListRole(command.Lister):
@ -318,8 +315,10 @@ class RemoveRole(command.Command):
if (not parsed_args.user and not parsed_args.domain
and not parsed_args.group and not parsed_args.project):
sys.stderr.write("Incorrect set of arguments "
"provided. See openstack --help for more "
"details\n")
return
role = utils.find_resource(
identity_client.roles,
parsed_args.role,
@ -331,9 +330,7 @@ class RemoveRole(command.Command):
sys.stderr.write("Role not removed, incorrect set of arguments \
provided. See openstack --help for more details\n")
return
identity_client.roles.revoke(role.id, **kwargs)
return
class SetRole(command.Command):
@ -357,15 +354,16 @@ class SetRole(command.Command):
identity_client = self.app.client_manager.identity
if not parsed_args.name:
sys.stderr.write("Incorrect set of arguments "
"provided. See openstack --help for more "
"details\n")
return
role = utils.find_resource(
identity_client.roles,
parsed_args.role,
)
identity_client.roles.update(role.id, name=parsed_args.name)
return
class ShowRole(command.ShowOne):

View File

@ -16,6 +16,7 @@
"""Identity v3 Service action implementations"""
import six
import sys
from openstackclient.common import command
from openstackclient.common import utils
@ -91,7 +92,6 @@ class DeleteService(command.Command):
service = common.find_service(identity_client, parsed_args.service)
identity_client.services.delete(service.id)
return
class ListService(command.Lister):
@ -166,10 +166,12 @@ class SetService(command.Command):
and not parsed_args.description
and not parsed_args.enable
and not parsed_args.disable):
sys.stderr.write("Incorrect set of arguments "
"provided. See openstack --help for more "
"details\n")
return
service = common.find_service(identity_client, parsed_args.service)
service = common.find_service(identity_client,
parsed_args.service)
kwargs = {}
if parsed_args.type:
kwargs['type'] = parsed_args.type
@ -186,7 +188,6 @@ class SetService(command.Command):
service.id,
**kwargs
)
return
class ShowService(command.ShowOne):

View File

@ -96,7 +96,6 @@ class DeleteServiceProvider(command.Command):
service_client = self.app.client_manager.identity
service_client.federation.service_providers.delete(
parsed_args.service_provider)
return
class ListServiceProvider(command.Lister):

View File

@ -194,4 +194,3 @@ class RevokeToken(command.Command):
identity_client = self.app.client_manager.identity
identity_client.tokens.revoke_token(parsed_args.token)
return

View File

@ -17,6 +17,7 @@
import copy
import six
import sys
from keystoneauth1 import exceptions as ks_exc
@ -162,7 +163,6 @@ class DeleteUser(command.Command):
user_obj = utils.find_resource(identity_client.users,
user)
identity_client.users.delete(user_obj.id)
return
class ListUser(command.Lister):
@ -334,13 +334,15 @@ class SetUser(command.Command):
and not parsed_args.description
and not parsed_args.enable
and not parsed_args.disable):
sys.stderr.write("Incorrect set of arguments "
"provided. See openstack --help for more "
"details\n")
return
user = utils.find_resource(
identity_client.users,
parsed_args.user,
)
kwargs = {}
if parsed_args.name:
kwargs['name'] = parsed_args.name
@ -362,7 +364,6 @@ class SetUser(command.Command):
kwargs['enabled'] = False
identity_client.users.update(user.id, **kwargs)
return
class SetPasswordUser(command.Command):