summaryrefslogtreecommitdiff
path: root/openstackclient/identity
diff options
context:
space:
mode:
authorMarco Fargetta <marco.fargetta@ct.infn.it>2015-03-04 17:24:07 +0100
committerSteve Martinelli <stevemar@ca.ibm.com>2015-03-30 11:53:17 -0400
commit6a9d6af225097969eacd376c7af298d906e40d95 (patch)
treecc856329d7a24f8ccdd5d6bc6384b272e6af0b56 /openstackclient/identity
parent33313eac5a2fc5817b55a27a0a4d66a62c49d114 (diff)
downloadpython-openstackclient-6a9d6af225097969eacd376c7af298d906e40d95.tar.gz
Add support to remote_id
The federation APIs for the identity providers introduce a new parameter for every identity provider, named remote_ids, which contains a list of entity ID associated with. This parameter can be provided during the creation of the identity provider and can be updated at any time. For more information look at the blueprint: https://blueprints.launchpad.net/keystone/+spec/idp-id-registration This patch add the support to this new parameter in the command line by inserting the option "--remote-id" in the following commands: - "identity provider create" - "identity provider set" Additionally, the values can be read from a file, specified by "--remote-id-file", containing an entity id per line. Change-Id: Ie93340ee57e54128daa70d8a7bd0a9975ff7eef4 Depends-On: I12a262c55b5f6b5cc7007865edf30f14269da537 Implements: blueprint idp-id-registration
Diffstat (limited to 'openstackclient/identity')
-rw-r--r--openstackclient/identity/v3/identity_provider.py68
1 files changed, 61 insertions, 7 deletions
diff --git a/openstackclient/identity/v3/identity_provider.py b/openstackclient/identity/v3/identity_provider.py
index 691446da..80965800 100644
--- a/openstackclient/identity/v3/identity_provider.py
+++ b/openstackclient/identity/v3/identity_provider.py
@@ -35,6 +35,20 @@ class CreateIdentityProvider(show.ShowOne):
metavar='<name>',
help='New identity provider name (must be unique)'
)
+ identity_remote_id_provider = parser.add_mutually_exclusive_group()
+ identity_remote_id_provider.add_argument(
+ '--remote-id',
+ metavar='<remote-id>',
+ action='append',
+ help='Remote IDs to associate with the Identity Provider '
+ '(repeat to provide multiple values)'
+ )
+ identity_remote_id_provider.add_argument(
+ '--remote-id-file',
+ metavar='<file-name>',
+ help='Name of a file that contains many remote IDs to associate '
+ 'with the identity provider, one per line'
+ )
parser.add_argument(
'--description',
metavar='<description>',
@@ -59,8 +73,17 @@ class CreateIdentityProvider(show.ShowOne):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
identity_client = self.app.client_manager.identity
+ if parsed_args.remote_id_file:
+ file_content = utils.read_blob_file_contents(
+ parsed_args.remote_id_file)
+ remote_ids = file_content.splitlines()
+ remote_ids = list(map(str.strip, remote_ids))
+ else:
+ remote_ids = (parsed_args.remote_id
+ if parsed_args.remote_id else None)
idp = identity_client.federation.identity_providers.create(
id=parsed_args.identity_provider_id,
+ remote_ids=remote_ids,
description=parsed_args.description,
enabled=parsed_args.enabled)
@@ -119,6 +142,20 @@ class SetIdentityProvider(command.Command):
metavar='<identity-provider>',
help='Identity provider to modify',
)
+ identity_remote_id_provider = parser.add_mutually_exclusive_group()
+ identity_remote_id_provider.add_argument(
+ '--remote-id',
+ metavar='<remote-id>',
+ action='append',
+ help='Remote IDs to associate with the Identity Provider '
+ '(repeat to provide multiple values)'
+ )
+ identity_remote_id_provider.add_argument(
+ '--remote-id-file',
+ metavar='<file-name>',
+ help='Name of a file that contains many remote IDs to associate '
+ 'with the identity provider, one per line'
+ )
enable_identity_provider = parser.add_mutually_exclusive_group()
enable_identity_provider.add_argument(
'--enable',
@@ -136,16 +173,33 @@ class SetIdentityProvider(command.Command):
self.log.debug('take_action(%s)', parsed_args)
federation_client = self.app.client_manager.identity.federation
- if parsed_args.enable is True:
- enabled = True
- elif parsed_args.disable is True:
- enabled = False
- else:
- self.log.error("No changes requested")
+ # Basic argument checking
+ if (not parsed_args.enable and not parsed_args.disable and not
+ parsed_args.remote_id and not parsed_args.remote_id_file):
+ self.log.error('No changes requested')
return (None, None)
+ # Always set remote_ids if either is passed in
+ if parsed_args.remote_id_file:
+ file_content = utils.read_blob_file_contents(
+ parsed_args.remote_id_file)
+ remote_ids = file_content.splitlines()
+ remote_ids = list(map(str.strip, remote_ids))
+ elif parsed_args.remote_id:
+ remote_ids = parsed_args.remote_id
+
+ # Setup keyword args for the client
+ kwargs = {}
+ if parsed_args.enable:
+ kwargs['enabled'] = True
+ if parsed_args.disable:
+ kwargs['enabled'] = False
+ if parsed_args.remote_id_file or parsed_args.remote_id:
+ kwargs['remote_ids'] = remote_ids
+
identity_provider = federation_client.identity_providers.update(
- parsed_args.identity_provider, enabled=enabled)
+ parsed_args.identity_provider, **kwargs)
+
identity_provider._info.pop('links', None)
return zip(*sorted(six.iteritems(identity_provider._info)))