summaryrefslogtreecommitdiff
path: root/openstackclient/identity/v2_0
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/identity/v2_0')
-rw-r--r--openstackclient/identity/v2_0/catalog.py22
-rw-r--r--openstackclient/identity/v2_0/ec2creds.py37
-rw-r--r--openstackclient/identity/v2_0/endpoint.py54
-rw-r--r--openstackclient/identity/v2_0/project.py59
-rw-r--r--openstackclient/identity/v2_0/role.py35
-rw-r--r--openstackclient/identity/v2_0/role_assignment.py22
-rw-r--r--openstackclient/identity/v2_0/service.py26
-rw-r--r--openstackclient/identity/v2_0/token.py3
-rw-r--r--openstackclient/identity/v2_0/user.py65
9 files changed, 206 insertions, 117 deletions
diff --git a/openstackclient/identity/v2_0/catalog.py b/openstackclient/identity/v2_0/catalog.py
index 05d0e9ae..bea97cce 100644
--- a/openstackclient/identity/v2_0/catalog.py
+++ b/openstackclient/identity/v2_0/catalog.py
@@ -47,7 +47,6 @@ class ListCatalog(command.Lister):
_description = _("List services in the service catalog")
def take_action(self, parsed_args):
-
# Trigger auth if it has not happened yet
auth_ref = self.app.client_manager.auth_ref
if not auth_ref:
@@ -57,13 +56,19 @@ class ListCatalog(command.Lister):
data = auth_ref.service_catalog.catalog
columns = ('Name', 'Type', 'Endpoints')
- return (columns,
- (utils.get_dict_properties(
- s, columns,
+ return (
+ columns,
+ (
+ utils.get_dict_properties(
+ s,
+ columns,
formatters={
'Endpoints': EndpointsColumn,
},
- ) for s in data))
+ )
+ for s in data
+ ),
+ )
class ShowCatalog(command.ShowOne):
@@ -79,7 +84,6 @@ class ShowCatalog(command.ShowOne):
return parser
def take_action(self, parsed_args):
-
# Trigger auth if it has not happened yet
auth_ref = self.app.client_manager.auth_ref
if not auth_ref:
@@ -89,8 +93,10 @@ class ShowCatalog(command.ShowOne):
data = None
for service in auth_ref.service_catalog.catalog:
- if (service.get('name') == parsed_args.service or
- service.get('type') == parsed_args.service):
+ if (
+ service.get('name') == parsed_args.service
+ or service.get('type') == parsed_args.service
+ ):
data = service.copy()
data['endpoints'] = EndpointsColumn(data['endpoints'])
if 'endpoints_links' in data:
diff --git a/openstackclient/identity/v2_0/ec2creds.py b/openstackclient/identity/v2_0/ec2creds.py
index f712bf45..94d68330 100644
--- a/openstackclient/identity/v2_0/ec2creds.py
+++ b/openstackclient/identity/v2_0/ec2creds.py
@@ -77,9 +77,7 @@ class CreateEC2Creds(command.ShowOne):
info.update(creds._info)
if 'tenant_id' in info:
- info.update(
- {'project_id': info.pop('tenant_id')}
- )
+ info.update({'project_id': info.pop('tenant_id')})
return zip(*sorted(info.items()))
@@ -120,14 +118,19 @@ class DeleteEC2Creds(command.Command):
identity_client.ec2.delete(user, access_key)
except Exception as e:
result += 1
- LOG.error(_("Failed to delete EC2 credentials with "
- "access key '%(access_key)s': %(e)s"),
- {'access_key': access_key, 'e': e})
+ LOG.error(
+ _(
+ "Failed to delete EC2 credentials with "
+ "access key '%(access_key)s': %(e)s"
+ ),
+ {'access_key': access_key, 'e': e},
+ )
if result > 0:
total = len(parsed_args.access_keys)
- msg = (_("%(result)s of %(total)s EC2 keys failed "
- "to delete.") % {'result': result, 'total': total})
+ msg = _(
+ "%(result)s of %(total)s EC2 keys failed " "to delete."
+ ) % {'result': result, 'total': total}
raise exceptions.CommandError(msg)
@@ -159,11 +162,17 @@ class ListEC2Creds(command.Lister):
column_headers = ('Access', 'Secret', 'Project ID', 'User ID')
data = identity_client.ec2.list(user)
- return (column_headers,
- (utils.get_item_properties(
- s, columns,
+ return (
+ column_headers,
+ (
+ utils.get_item_properties(
+ s,
+ columns,
formatters={},
- ) for s in data))
+ )
+ for s in data
+ ),
+ )
class ShowEC2Creds(command.ShowOne):
@@ -201,8 +210,6 @@ class ShowEC2Creds(command.ShowOne):
info.update(creds._info)
if 'tenant_id' in info:
- info.update(
- {'project_id': info.pop('tenant_id')}
- )
+ info.update({'project_id': info.pop('tenant_id')})
return zip(*sorted(info.items()))
diff --git a/openstackclient/identity/v2_0/endpoint.py b/openstackclient/identity/v2_0/endpoint.py
index 57906ddf..2b9970a6 100644
--- a/openstackclient/identity/v2_0/endpoint.py
+++ b/openstackclient/identity/v2_0/endpoint.py
@@ -69,7 +69,8 @@ class CreateEndpoint(command.ShowOne):
service.id,
parsed_args.publicurl,
parsed_args.adminurl,
- parsed_args.internalurl,)
+ parsed_args.internalurl,
+ )
info = {}
info.update(endpoint._info)
@@ -100,14 +101,19 @@ class DeleteEndpoint(command.Command):
identity_client.endpoints.delete(endpoint)
except Exception as e:
result += 1
- LOG.error(_("Failed to delete endpoint with "
- "ID '%(endpoint)s': %(e)s"),
- {'endpoint': endpoint, 'e': e})
+ LOG.error(
+ _(
+ "Failed to delete endpoint with "
+ "ID '%(endpoint)s': %(e)s"
+ ),
+ {'endpoint': endpoint, 'e': e},
+ )
if result > 0:
total = len(parsed_args.endpoints)
- msg = (_("%(result)s of %(total)s endpoints failed "
- "to delete.") % {'result': result, 'total': total})
+ msg = _(
+ "%(result)s of %(total)s endpoints failed " "to delete."
+ ) % {'result': result, 'total': total}
raise exceptions.CommandError(msg)
@@ -127,8 +133,15 @@ class ListEndpoint(command.Lister):
def take_action(self, parsed_args):
identity_client = self.app.client_manager.identity
if parsed_args.long:
- columns = ('ID', 'Region', 'Service Name', 'Service Type',
- 'PublicURL', 'AdminURL', 'InternalURL')
+ columns = (
+ 'ID',
+ 'Region',
+ 'Service Name',
+ 'Service Type',
+ 'PublicURL',
+ 'AdminURL',
+ 'InternalURL',
+ )
else:
columns = ('ID', 'Region', 'Service Name', 'Service Type')
data = identity_client.endpoints.list()
@@ -137,11 +150,17 @@ class ListEndpoint(command.Lister):
service = common.find_service(identity_client, ep.service_id)
ep.service_name = service.name
ep.service_type = service.type
- return (columns,
- (utils.get_item_properties(
- s, columns,
+ return (
+ columns,
+ (
+ utils.get_item_properties(
+ s,
+ columns,
formatters={},
- ) for s in data))
+ )
+ for s in data
+ ),
+ )
class ShowEndpoint(command.ShowOne):
@@ -152,8 +171,10 @@ class ShowEndpoint(command.ShowOne):
parser.add_argument(
'endpoint_or_service',
metavar='<endpoint>',
- help=_('Endpoint to display (endpoint ID, service ID,'
- ' service name, service type)'),
+ help=_(
+ 'Endpoint to display (endpoint ID, service ID,'
+ ' service name, service type)'
+ ),
)
return parser
@@ -166,8 +187,9 @@ class ShowEndpoint(command.ShowOne):
match = ep
service = common.find_service(identity_client, ep.service_id)
if match is None:
- service = common.find_service(identity_client,
- parsed_args.endpoint_or_service)
+ service = common.find_service(
+ identity_client, parsed_args.endpoint_or_service
+ )
for ep in data:
if ep.service_id == service.id:
match = ep
diff --git a/openstackclient/identity/v2_0/project.py b/openstackclient/identity/v2_0/project.py
index f431c021..e2f378db 100644
--- a/openstackclient/identity/v2_0/project.py
+++ b/openstackclient/identity/v2_0/project.py
@@ -60,8 +60,10 @@ class CreateProject(command.ShowOne):
'--property',
metavar='<key=value>',
action=parseractions.KeyValueAction,
- help=_('Add a property to <name> '
- '(repeat option to set multiple properties)'),
+ help=_(
+ 'Add a property to <name> '
+ '(repeat option to set multiple properties)'
+ ),
)
parser.add_argument(
'--or-show',
@@ -128,14 +130,19 @@ class DeleteProject(command.Command):
identity_client.tenants.delete(project_obj.id)
except Exception as e:
errors += 1
- LOG.error(_("Failed to delete project with "
- "name or ID '%(project)s': %(e)s"),
- {'project': project, 'e': e})
+ LOG.error(
+ _(
+ "Failed to delete project with "
+ "name or ID '%(project)s': %(e)s"
+ ),
+ {'project': project, 'e': e},
+ )
if errors > 0:
total = len(parsed_args.projects)
- msg = (_("%(errors)s of %(total)s projects failed "
- "to delete.") % {'errors': errors, 'total': total})
+ msg = _(
+ "%(errors)s of %(total)s projects failed " "to delete."
+ ) % {'errors': errors, 'total': total}
raise exceptions.CommandError(msg)
@@ -153,9 +160,11 @@ class ListProject(command.Lister):
parser.add_argument(
'--sort',
metavar='<key>[:<direction>]',
- help=_('Sort output by selected keys and directions (asc or desc) '
- '(default: asc), repeat this option to specify multiple '
- 'keys and directions.'),
+ help=_(
+ 'Sort output by selected keys and directions (asc or desc) '
+ '(default: asc), repeat this option to specify multiple '
+ 'keys and directions.'
+ ),
)
return parser
@@ -167,11 +176,17 @@ class ListProject(command.Lister):
data = self.app.client_manager.identity.tenants.list()
if parsed_args.sort:
data = utils.sort_items(data, parsed_args.sort)
- return (columns,
- (utils.get_item_properties(
- s, columns,
+ return (
+ columns,
+ (
+ utils.get_item_properties(
+ s,
+ columns,
formatters={},
- ) for s in data))
+ )
+ for s in data
+ ),
+ )
class SetProject(command.Command):
@@ -209,8 +224,10 @@ class SetProject(command.Command):
'--property',
metavar='<key=value>',
action=parseractions.KeyValueAction,
- help=_('Set a project property '
- '(repeat option to set multiple properties)'),
+ help=_(
+ 'Set a project property '
+ '(repeat option to set multiple properties)'
+ ),
)
return parser
@@ -268,8 +285,8 @@ class ShowProject(command.ShowOne):
except ks_exc.Forbidden:
auth_ref = self.app.client_manager.auth_ref
if (
- parsed_args.project == auth_ref.project_id or
- parsed_args.project == auth_ref.project_name
+ parsed_args.project == auth_ref.project_id
+ or parsed_args.project == auth_ref.project_name
):
# Ask for currently auth'ed project so return it
info = {
@@ -316,8 +333,10 @@ class UnsetProject(command.Command):
metavar='<key>',
action='append',
default=[],
- help=_('Unset a project property '
- '(repeat option to unset multiple properties)'),
+ help=_(
+ 'Unset a project property '
+ '(repeat option to unset multiple properties)'
+ ),
)
return parser
diff --git a/openstackclient/identity/v2_0/role.py b/openstackclient/identity/v2_0/role.py
index 5c53fbcd..931957bd 100644
--- a/openstackclient/identity/v2_0/role.py
+++ b/openstackclient/identity/v2_0/role.py
@@ -133,14 +133,20 @@ class DeleteRole(command.Command):
identity_client.roles.delete(role_obj.id)
except Exception as e:
errors += 1
- LOG.error(_("Failed to delete role with "
- "name or ID '%(role)s': %(e)s"),
- {'role': role, 'e': e})
+ LOG.error(
+ _(
+ "Failed to delete role with "
+ "name or ID '%(role)s': %(e)s"
+ ),
+ {'role': role, 'e': e},
+ )
if errors > 0:
total = len(parsed_args.roles)
- msg = (_("%(errors)s of %(total)s roles failed "
- "to delete.") % {'errors': errors, 'total': total})
+ msg = _("%(errors)s of %(total)s roles failed " "to delete.") % {
+ 'errors': errors,
+ 'total': total,
+ }
raise exceptions.CommandError(msg)
@@ -153,11 +159,17 @@ class ListRole(command.Lister):
columns = ('ID', 'Name')
data = identity_client.roles.list()
- return (columns,
- (utils.get_item_properties(
- s, columns,
+ return (
+ columns,
+ (
+ utils.get_item_properties(
+ s,
+ columns,
formatters={},
- ) for s in data))
+ )
+ for s in data
+ ),
+ )
class RemoveRole(command.Command):
@@ -192,10 +204,7 @@ class RemoveRole(command.Command):
parsed_args.project,
)
user = utils.find_resource(identity_client.users, parsed_args.user)
- identity_client.roles.remove_user_role(
- user.id,
- role.id,
- project.id)
+ identity_client.roles.remove_user_role(user.id, role.id, project.id)
class ShowRole(command.ShowOne):
diff --git a/openstackclient/identity/v2_0/role_assignment.py b/openstackclient/identity/v2_0/role_assignment.py
index 8236bbfc..c3d492e2 100644
--- a/openstackclient/identity/v2_0/role_assignment.py
+++ b/openstackclient/identity/v2_0/role_assignment.py
@@ -51,7 +51,7 @@ class ListRoleAssignment(command.Lister):
action="store_true",
dest='authproject',
help='Only list assignments for the project to which the '
- 'authenticated user\'s token is scoped',
+ 'authenticated user\'s token is scoped',
)
return parser
@@ -70,8 +70,7 @@ class ListRoleAssignment(command.Lister):
elif parsed_args.authuser:
if auth_ref:
user = utils.find_resource(
- identity_client.users,
- auth_ref.user_id
+ identity_client.users, auth_ref.user_id
)
project = None
@@ -83,8 +82,7 @@ class ListRoleAssignment(command.Lister):
elif parsed_args.authproject:
if auth_ref:
project = utils.find_resource(
- identity_client.projects,
- auth_ref.project_id
+ identity_client.projects, auth_ref.project_id
)
# If user or project is not specified, we would ideally list all
@@ -107,8 +105,14 @@ class ListRoleAssignment(command.Lister):
user_role.user = user.id
user_role.project = project.id
- return (columns,
- (utils.get_item_properties(
- s, columns,
+ return (
+ columns,
+ (
+ utils.get_item_properties(
+ s,
+ columns,
formatters={},
- ) for s in data))
+ )
+ for s in data
+ ),
+ )
diff --git a/openstackclient/identity/v2_0/service.py b/openstackclient/identity/v2_0/service.py
index afc0b3d7..15203e69 100644
--- a/openstackclient/identity/v2_0/service.py
+++ b/openstackclient/identity/v2_0/service.py
@@ -90,14 +90,19 @@ class DeleteService(command.Command):
identity_client.services.delete(service.id)
except Exception as e:
result += 1
- LOG.error(_("Failed to delete service with "
- "name or ID '%(service)s': %(e)s"),
- {'service': service, 'e': e})
+ LOG.error(
+ _(
+ "Failed to delete service with "
+ "name or ID '%(service)s': %(e)s"
+ ),
+ {'service': service, 'e': e},
+ )
if result > 0:
total = len(parsed_args.services)
- msg = (_("%(result)s of %(total)s services failed "
- "to delete.") % {'result': result, 'total': total})
+ msg = _(
+ "%(result)s of %(total)s services failed " "to delete."
+ ) % {'result': result, 'total': total}
raise exceptions.CommandError(msg)
@@ -115,7 +120,6 @@ class ListService(command.Lister):
return parser
def take_action(self, parsed_args):
-
if parsed_args.long:
columns = ('ID', 'Name', 'Type', 'Description')
else:
@@ -151,15 +155,17 @@ class ShowService(command.ShowOne):
if parsed_args.catalog:
endpoints = auth_ref.service_catalog.get_endpoints(
- service_type=parsed_args.service)
- for (service, service_endpoints) in endpoints.items():
+ service_type=parsed_args.service
+ )
+ for service, service_endpoints in endpoints.items():
if service_endpoints:
info = {"type": service}
info.update(service_endpoints[0])
return zip(*sorted(info.items()))
- msg = _("No service catalog with a type, name or ID of '%s' "
- "exists.") % (parsed_args.service)
+ msg = _(
+ "No service catalog with a type, name or ID of '%s' " "exists."
+ ) % (parsed_args.service)
raise exceptions.CommandError(msg)
else:
service = common.find_service(identity_client, parsed_args.service)
diff --git a/openstackclient/identity/v2_0/token.py b/openstackclient/identity/v2_0/token.py
index 205e15d3..8759df8d 100644
--- a/openstackclient/identity/v2_0/token.py
+++ b/openstackclient/identity/v2_0/token.py
@@ -35,7 +35,8 @@ class IssueToken(command.ShowOne):
auth_ref = self.app.client_manager.auth_ref
if not auth_ref:
raise exceptions.AuthorizationFailure(
- "Only an authorized user may issue a new token.")
+ "Only an authorized user may issue a new token."
+ )
data = {}
if auth_ref.auth_token:
diff --git a/openstackclient/identity/v2_0/user.py b/openstackclient/identity/v2_0/user.py
index 8dac093e..7bcbc451 100644
--- a/openstackclient/identity/v2_0/user.py
+++ b/openstackclient/identity/v2_0/user.py
@@ -122,8 +122,12 @@ class CreateUser(command.ShowOne):
parsed_args.password = utils.get_password(self.app.stdin)
if not parsed_args.password:
- LOG.warning(_("No password was supplied, authentication will fail "
- "when a user does not have a password."))
+ LOG.warning(
+ _(
+ "No password was supplied, authentication will fail "
+ "when a user does not have a password."
+ )
+ )
try:
user = identity_client.users.create(
@@ -147,9 +151,7 @@ class CreateUser(command.ShowOne):
# the returned resource has 'tenantId'. Sigh.
# We're using project_id now inside OSC so there.
if 'tenantId' in user._info:
- user._info.update(
- {'project_id': user._info.pop('tenantId')}
- )
+ user._info.update({'project_id': user._info.pop('tenantId')})
info = {}
info.update(user._info)
@@ -182,14 +184,20 @@ class DeleteUser(command.Command):
identity_client.users.delete(user_obj.id)
except Exception as e:
errors += 1
- LOG.error(_("Failed to delete user with "
- "name or ID '%(user)s': %(e)s"),
- {'user': user, 'e': e})
+ LOG.error(
+ _(
+ "Failed to delete user with "
+ "name or ID '%(user)s': %(e)s"
+ ),
+ {'user': user, 'e': e},
+ )
if errors > 0:
total = len(parsed_args.users)
- msg = (_("%(errors)s of %(total)s users failed "
- "to delete.") % {'errors': errors, 'total': total})
+ msg = _("%(errors)s of %(total)s users failed " "to delete.") % {
+ 'errors': errors,
+ 'total': total,
+ }
raise exceptions.CommandError(msg)
@@ -246,7 +254,8 @@ class ListUser(command.Lister):
# Just forget it if there's any trouble
pass
formatters['tenantId'] = functools.partial(
- ProjectColumn, project_cache=project_cache)
+ ProjectColumn, project_cache=project_cache
+ )
else:
columns = column_headers = ('ID', 'Name')
data = identity_client.users.list(tenant_id=project)
@@ -267,12 +276,18 @@ class ListUser(command.Lister):
d._info['tenantId'] = d._info.pop('tenant_id')
d._add_details(d._info)
- return (column_headers,
- (utils.get_item_properties(
- s, columns,
+ return (
+ column_headers,
+ (
+ utils.get_item_properties(
+ s,
+ columns,
mixed_case_fields=('tenantId',),
formatters=formatters,
- ) for s in data))
+ )
+ for s in data
+ ),
+ )
class SetUser(command.Command):
@@ -331,8 +346,12 @@ class SetUser(command.Command):
parsed_args.password = utils.get_password(self.app.stdin)
if '' == parsed_args.password:
- LOG.warning(_("No password was supplied, authentication will fail "
- "when a user does not have a password."))
+ LOG.warning(
+ _(
+ "No password was supplied, authentication will fail "
+ "when a user does not have a password."
+ )
+ )
user = utils.find_resource(
identity_client.users,
@@ -394,8 +413,8 @@ class ShowUser(command.ShowOne):
except ks_exc.Forbidden:
auth_ref = self.app.client_manager.auth_ref
if (
- parsed_args.user == auth_ref.user_id or
- parsed_args.user == auth_ref.username
+ parsed_args.user == auth_ref.user_id
+ or parsed_args.user == auth_ref.username
):
# Ask for currently auth'ed project so return it
info = {
@@ -409,12 +428,8 @@ class ShowUser(command.ShowOne):
raise
if 'tenantId' in info:
- info.update(
- {'project_id': info.pop('tenantId')}
- )
+ info.update({'project_id': info.pop('tenantId')})
if 'tenant_id' in info:
- info.update(
- {'project_id': info.pop('tenant_id')}
- )
+ info.update({'project_id': info.pop('tenant_id')})
return zip(*sorted(info.items()))