remove unnecessary conditionals
In several places we had else branches where a reasonable default would do the job. This makes the code a mean cleaer and easier to read. Change-Id: I231e09aab85fd32b8300bc33c48d0899b728b96e
This commit is contained in:
parent
fd8b284164
commit
00eeb3593c
openstackclient/identity/v3
@ -137,11 +137,11 @@ class CreateGroup(show.ShowOne):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('take_action(%s)', parsed_args)
|
self.log.debug('take_action(%s)', parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
|
domain = None
|
||||||
if parsed_args.domain:
|
if parsed_args.domain:
|
||||||
domain = common.find_domain(identity_client,
|
domain = common.find_domain(identity_client,
|
||||||
parsed_args.domain).id
|
parsed_args.domain).id
|
||||||
else:
|
|
||||||
domain = None
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
group = identity_client.groups.create(
|
group = identity_client.groups.create(
|
||||||
@ -228,11 +228,10 @@ class ListGroup(lister.Lister):
|
|||||||
self.log.debug('take_action(%s)', parsed_args)
|
self.log.debug('take_action(%s)', parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
|
domain = None
|
||||||
if parsed_args.domain:
|
if parsed_args.domain:
|
||||||
domain = common.find_domain(identity_client,
|
domain = common.find_domain(identity_client,
|
||||||
parsed_args.domain).id
|
parsed_args.domain).id
|
||||||
else:
|
|
||||||
domain = None
|
|
||||||
|
|
||||||
if parsed_args.user:
|
if parsed_args.user:
|
||||||
user = utils.find_resource(
|
user = utils.find_resource(
|
||||||
|
@ -80,11 +80,10 @@ class CreateProject(show.ShowOne):
|
|||||||
self.log.debug('take_action(%s)', parsed_args)
|
self.log.debug('take_action(%s)', parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
|
domain = None
|
||||||
if parsed_args.domain:
|
if parsed_args.domain:
|
||||||
domain = common.find_domain(identity_client,
|
domain = common.find_domain(identity_client,
|
||||||
parsed_args.domain).id
|
parsed_args.domain).id
|
||||||
else:
|
|
||||||
domain = None
|
|
||||||
|
|
||||||
enabled = True
|
enabled = True
|
||||||
if parsed_args.disable:
|
if parsed_args.disable:
|
||||||
|
@ -92,23 +92,20 @@ class CreateTrust(show.ShowOne):
|
|||||||
self.log.debug('take_action(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
|
project_domain = None
|
||||||
if parsed_args.project_domain:
|
if parsed_args.project_domain:
|
||||||
project_domain = common.find_domain(identity_client,
|
project_domain = common.find_domain(identity_client,
|
||||||
parsed_args.project_domain).id
|
parsed_args.project_domain).id
|
||||||
else:
|
|
||||||
project_domain = None
|
|
||||||
|
|
||||||
|
trustor_domain = None
|
||||||
if parsed_args.trustor_domain:
|
if parsed_args.trustor_domain:
|
||||||
trustor_domain = common.find_domain(identity_client,
|
trustor_domain = common.find_domain(identity_client,
|
||||||
parsed_args.trustor_domain).id
|
parsed_args.trustor_domain).id
|
||||||
else:
|
|
||||||
trustor_domain = None
|
|
||||||
|
|
||||||
|
trustee_domain = None
|
||||||
if parsed_args.trustee_domain:
|
if parsed_args.trustee_domain:
|
||||||
trustee_domain = common.find_domain(identity_client,
|
trustee_domain = common.find_domain(identity_client,
|
||||||
parsed_args.trustee_domain).id
|
parsed_args.trustee_domain).id
|
||||||
else:
|
|
||||||
trustee_domain = None
|
|
||||||
|
|
||||||
# NOTE(stevemar): Find the two users, project and roles that
|
# NOTE(stevemar): Find the two users, project and roles that
|
||||||
# are necessary for making a trust usable, the API dictates that
|
# are necessary for making a trust usable, the API dictates that
|
||||||
|
@ -94,19 +94,17 @@ class CreateUser(show.ShowOne):
|
|||||||
self.log.debug('take_action(%s)', parsed_args)
|
self.log.debug('take_action(%s)', parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
|
project_id = None
|
||||||
if parsed_args.project:
|
if parsed_args.project:
|
||||||
project_id = utils.find_resource(
|
project_id = utils.find_resource(
|
||||||
identity_client.projects,
|
identity_client.projects,
|
||||||
parsed_args.project,
|
parsed_args.project,
|
||||||
).id
|
).id
|
||||||
else:
|
|
||||||
project_id = None
|
|
||||||
|
|
||||||
|
domain_id = None
|
||||||
if parsed_args.domain:
|
if parsed_args.domain:
|
||||||
domain_id = common.find_domain(identity_client,
|
domain_id = common.find_domain(identity_client,
|
||||||
parsed_args.domain).id
|
parsed_args.domain).id
|
||||||
else:
|
|
||||||
domain_id = None
|
|
||||||
|
|
||||||
enabled = True
|
enabled = True
|
||||||
if parsed_args.disable:
|
if parsed_args.disable:
|
||||||
@ -211,11 +209,10 @@ class ListUser(lister.Lister):
|
|||||||
self.log.debug('take_action(%s)', parsed_args)
|
self.log.debug('take_action(%s)', parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
|
domain = None
|
||||||
if parsed_args.domain:
|
if parsed_args.domain:
|
||||||
domain = common.find_domain(identity_client,
|
domain = common.find_domain(identity_client,
|
||||||
parsed_args.domain).id
|
parsed_args.domain).id
|
||||||
else:
|
|
||||||
domain = None
|
|
||||||
|
|
||||||
if parsed_args.group:
|
if parsed_args.group:
|
||||||
group = utils.find_resource(
|
group = utils.find_resource(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user