Fix i18n support problems in identity

Change-Id: I3b48d17850343051239b5b69e8b890dba32d3ac8
Partial-bug: #1574965
This commit is contained in:
Tang Chen 2016-06-05 10:58:48 +08:00
parent dd0fe3d94e
commit 5293bb103e
25 changed files with 364 additions and 319 deletions

View File

@ -89,7 +89,7 @@ class ShowCatalog(command.ShowOne):
break break
if not data: if not data:
self.app.log.error('service %s not found\n' % self.app.log.error(_('service %s not found\n') %
parsed_args.service) parsed_args.service)
return ([], []) return ([], [])

View File

@ -81,7 +81,8 @@ class DeleteEndpoint(command.Command):
parser.add_argument( parser.add_argument(
'endpoint', 'endpoint',
metavar='<endpoint-id>', metavar='<endpoint-id>',
help=_('Endpoint ID to delete')) help=_('Endpoint ID to delete'),
)
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):

View File

@ -88,7 +88,7 @@ class CreateProject(command.ShowOne):
identity_client.tenants, identity_client.tenants,
parsed_args.name, parsed_args.name,
) )
self.log.info('Returning existing project %s', project.name) self.log.info(_('Returning existing project %s'), project.name)
else: else:
raise e raise e
@ -231,7 +231,8 @@ class ShowProject(command.ShowOne):
parser.add_argument( parser.add_argument(
'project', 'project',
metavar='<project>', metavar='<project>',
help=_('Project to display (name or ID)')) help=_('Project to display (name or ID)'),
)
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
@ -295,9 +296,9 @@ class UnsetProject(command.Command):
metavar='<key>', metavar='<key>',
action='append', action='append',
default=[], default=[],
required=True,
help=_('Unset a project property ' help=_('Unset a project property '
'(repeat option to unset multiple properties)'), '(repeat option to unset multiple properties)'),
required=True,
) )
return parser return parser
@ -308,7 +309,7 @@ class UnsetProject(command.Command):
parsed_args.project, parsed_args.project,
) )
if not parsed_args.property: if not parsed_args.property:
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))
else: else:
kwargs = project._info kwargs = project._info
for key in parsed_args.property: for key in parsed_args.property:

View File

@ -95,7 +95,7 @@ class CreateRole(command.ShowOne):
identity_client.roles, identity_client.roles,
parsed_args.role_name, parsed_args.role_name,
) )
self.log.info('Returning existing role %s', role.name) self.log.info(_('Returning existing role %s'), role.name)
else: else:
raise e raise e
@ -136,12 +136,12 @@ class ListRole(command.Lister):
parser.add_argument( parser.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
help='Filter roles by <project> (name or ID)', help=_('Filter roles by <project> (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--user', '--user',
metavar='<user>', metavar='<user>',
help='Filter roles by <user> (name or ID)', help=_('Filter roles by <user> (name or ID)'),
) )
return parser return parser

View File

@ -104,7 +104,7 @@ class CreateUser(command.ShowOne):
identity_client.users, identity_client.users,
parsed_args.name, parsed_args.name,
) )
self.log.info('Returning existing user %s', user.name) self.log.info(_('Returning existing user %s'), user.name)
else: else:
raise e raise e
@ -159,7 +159,8 @@ class ListUser(command.Lister):
'--long', '--long',
action='store_true', action='store_true',
default=False, default=False,
help=_('List additional fields in output')) help=_('List additional fields in output'),
)
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):

View File

@ -84,7 +84,7 @@ class ShowCatalog(command.ShowOne):
break break
if not data: if not data:
self.app.log.error('service %s not found\n' % self.app.log.error(_('service %s not found\n') %
parsed_args.service) parsed_args.service)
return ([], []) return ([], [])

View File

@ -20,6 +20,7 @@ import sys
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class CreateConsumer(command.ShowOne): class CreateConsumer(command.ShowOne):
@ -30,7 +31,7 @@ class CreateConsumer(command.ShowOne):
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='New consumer description', help=_('New consumer description'),
) )
return parser return parser
@ -51,7 +52,7 @@ class DeleteConsumer(command.Command):
parser.add_argument( parser.add_argument(
'consumer', 'consumer',
metavar='<consumer>', metavar='<consumer>',
help='Consumer to delete', help=_('Consumer to delete'),
) )
return parser return parser
@ -83,12 +84,12 @@ class SetConsumer(command.Command):
parser.add_argument( parser.add_argument(
'consumer', 'consumer',
metavar='<consumer>', metavar='<consumer>',
help='Consumer to modify', help=_('Consumer to modify'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='New consumer description', help=_('New consumer description'),
) )
return parser return parser
@ -101,7 +102,7 @@ class SetConsumer(command.Command):
kwargs['description'] = parsed_args.description kwargs['description'] = parsed_args.description
if not len(kwargs): if not len(kwargs):
sys.stdout.write('Consumer not updated, no arguments present\n') sys.stdout.write(_('Consumer not updated, no arguments present\n'))
return return
consumer = identity_client.oauth1.consumers.update( consumer = identity_client.oauth1.consumers.update(
@ -116,7 +117,7 @@ class ShowConsumer(command.ShowOne):
parser.add_argument( parser.add_argument(
'consumer', 'consumer',
metavar='<consumer>', metavar='<consumer>',
help='Consumer to display', help=_('Consumer to display'),
) )
return parser return parser

View File

@ -19,6 +19,7 @@ import six
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class CreateCredential(command.ShowOne): class CreateCredential(command.ShowOne):
@ -29,24 +30,25 @@ class CreateCredential(command.ShowOne):
parser.add_argument( parser.add_argument(
'user', 'user',
metavar='<user>', metavar='<user>',
help='Name or ID of user that owns the credential', help=_('Name or ID of user that owns the credential'),
) )
parser.add_argument( parser.add_argument(
'--type', '--type',
default="cert", default="cert",
metavar='<type>', metavar='<type>',
choices=['ec2', 'cert'], choices=['ec2', 'cert'],
help='New credential type', help=_('New credential type'),
) )
parser.add_argument( parser.add_argument(
'data', 'data',
metavar='<data>', metavar='<data>',
help='New credential data', help=_('New credential data'),
) )
parser.add_argument( parser.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
help='Project name or ID which limits the scope of the credential', help=_('Project name or ID which limits the '
'scope of the credential'),
) )
return parser return parser
@ -77,7 +79,7 @@ class DeleteCredential(command.Command):
parser.add_argument( parser.add_argument(
'credential', 'credential',
metavar='<credential-id>', metavar='<credential-id>',
help='ID of credential to delete', help=_('ID of credential to delete'),
) )
return parser return parser
@ -108,31 +110,32 @@ class SetCredential(command.Command):
parser.add_argument( parser.add_argument(
'credential', 'credential',
metavar='<credential-id>', metavar='<credential-id>',
help='ID of credential to change', help=_('ID of credential to change'),
) )
parser.add_argument( parser.add_argument(
'--user', '--user',
metavar='<user>', metavar='<user>',
required=True, required=True,
help='Name or ID of user that owns the credential', help=_('Name or ID of user that owns the credential'),
) )
parser.add_argument( parser.add_argument(
'--type', '--type',
metavar='<type>', metavar='<type>',
choices=['ec2', 'cert'], choices=['ec2', 'cert'],
required=True, required=True,
help='New credential type', help=_('New credential type'),
) )
parser.add_argument( parser.add_argument(
'--data', '--data',
metavar='<data>', metavar='<data>',
required=True, required=True,
help='New credential data', help=_('New credential data'),
) )
parser.add_argument( parser.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
help='Project name or ID which limits the scope of the credential', help=_('Project name or ID which limits the '
'scope of the credential'),
) )
return parser return parser
@ -163,7 +166,7 @@ class ShowCredential(command.ShowOne):
parser.add_argument( parser.add_argument(
'credential', 'credential',
metavar='<credential-id>', metavar='<credential-id>',
help='ID of credential to display', help=_('ID of credential to display'),
) )
return parser return parser

View File

@ -33,23 +33,23 @@ class CreateDomain(command.ShowOne):
parser.add_argument( parser.add_argument(
'name', 'name',
metavar='<domain-name>', metavar='<domain-name>',
help='New domain name', help=_('New domain name'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='New domain description', help=_('New domain description'),
) )
enable_group = parser.add_mutually_exclusive_group() enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument( enable_group.add_argument(
'--enable', '--enable',
action='store_true', action='store_true',
help='Enable domain (default)', help=_('Enable domain (default)'),
) )
enable_group.add_argument( enable_group.add_argument(
'--disable', '--disable',
action='store_true', action='store_true',
help='Disable domain', help=_('Disable domain'),
) )
parser.add_argument( parser.add_argument(
'--or-show', '--or-show',
@ -75,7 +75,7 @@ class CreateDomain(command.ShowOne):
if parsed_args.or_show: if parsed_args.or_show:
domain = utils.find_resource(identity_client.domains, domain = utils.find_resource(identity_client.domains,
parsed_args.name) parsed_args.name)
self.log.info('Returning existing domain %s', domain.name) self.log.info(_('Returning existing domain %s'), domain.name)
else: else:
raise e raise e
@ -91,7 +91,7 @@ class DeleteDomain(command.Command):
parser.add_argument( parser.add_argument(
'domain', 'domain',
metavar='<domain>', metavar='<domain>',
help='Domain to delete (name or ID)', help=_('Domain to delete (name or ID)'),
) )
return parser return parser
@ -123,28 +123,28 @@ class SetDomain(command.Command):
parser.add_argument( parser.add_argument(
'domain', 'domain',
metavar='<domain>', metavar='<domain>',
help='Domain to modify (name or ID)', help=_('Domain to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<name>', metavar='<name>',
help='New domain name', help=_('New domain name'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='New domain description', help=_('New domain description'),
) )
enable_group = parser.add_mutually_exclusive_group() enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument( enable_group.add_argument(
'--enable', '--enable',
action='store_true', action='store_true',
help='Enable domain', help=_('Enable domain'),
) )
enable_group.add_argument( enable_group.add_argument(
'--disable', '--disable',
action='store_true', action='store_true',
help='Disable domain', help=_('Disable domain'),
) )
return parser return parser
@ -164,7 +164,7 @@ class SetDomain(command.Command):
kwargs['enabled'] = False kwargs['enabled'] = False
if not kwargs: if not kwargs:
sys.stdout.write("Domain not updated, no arguments present\n") sys.stdout.write(_("Domain not updated, no arguments present\n"))
return return
identity_client.domains.update(domain.id, **kwargs) identity_client.domains.update(domain.id, **kwargs)
@ -177,7 +177,7 @@ class ShowDomain(command.ShowOne):
parser.add_argument( parser.add_argument(
'domain', 'domain',
metavar='<domain>', metavar='<domain>',
help='Domain to display (name or ID)', help=_('Domain to display (name or ID)'),
) )
return parser return parser

View File

@ -56,18 +56,14 @@ class CreateEC2Creds(command.ShowOne):
parser.add_argument( parser.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
help=_( help=_('Create credentials in project '
'Create credentials in project ' '(name or ID; default: current authenticated project)'),
'(name or ID; default: current authenticated project)'
),
) )
parser.add_argument( parser.add_argument(
'--user', '--user',
metavar='<user>', metavar='<user>',
help=_( help=_('Create credentials for user '
'Create credentials for user ' '(name or ID; default: current authenticated user)'),
'(name or ID; default: current authenticated user)'
),
) )
common.add_user_domain_option_to_parser(parser) common.add_user_domain_option_to_parser(parser)
common.add_project_domain_option_to_parser(parser) common.add_project_domain_option_to_parser(parser)

View File

@ -20,6 +20,7 @@ import sys
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
from openstackclient.identity import common from openstackclient.identity import common
@ -38,23 +39,23 @@ class CreateEndpoint(command.ShowOne):
parser.add_argument( parser.add_argument(
'service', 'service',
metavar='<service>', metavar='<service>',
help='New endpoint service (name or ID)', help=_('New endpoint service (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'interface', 'interface',
metavar='<interface>', metavar='<interface>',
choices=['admin', 'public', 'internal'], choices=['admin', 'public', 'internal'],
help='New endpoint interface type (admin, public or internal)', help=_('New endpoint interface type (admin, public or internal)'),
) )
parser.add_argument( parser.add_argument(
'url', 'url',
metavar='<url>', metavar='<url>',
help='New endpoint URL', help=_('New endpoint URL'),
) )
parser.add_argument( parser.add_argument(
'--region', '--region',
metavar='<region-id>', metavar='<region-id>',
help='New endpoint region ID', help=_('New endpoint region ID'),
) )
enable_group = parser.add_mutually_exclusive_group() enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument( enable_group.add_argument(
@ -62,13 +63,13 @@ class CreateEndpoint(command.ShowOne):
dest='enabled', dest='enabled',
action='store_true', action='store_true',
default=True, default=True,
help='Enable endpoint (default)', help=_('Enable endpoint (default)'),
) )
enable_group.add_argument( enable_group.add_argument(
'--disable', '--disable',
dest='enabled', dest='enabled',
action='store_false', action='store_false',
help='Disable endpoint', help=_('Disable endpoint'),
) )
return parser return parser
@ -100,7 +101,7 @@ class DeleteEndpoint(command.Command):
parser.add_argument( parser.add_argument(
'endpoint', 'endpoint',
metavar='<endpoint-id>', metavar='<endpoint-id>',
help='Endpoint ID to delete', help=_('Endpoint ID to delete'),
) )
return parser return parser
@ -119,18 +120,18 @@ class ListEndpoint(command.Lister):
parser.add_argument( parser.add_argument(
'--service', '--service',
metavar='<service>', metavar='<service>',
help='Filter by service', help=_('Filter by service'),
) )
parser.add_argument( parser.add_argument(
'--interface', '--interface',
metavar='<interface>', metavar='<interface>',
choices=['admin', 'public', 'internal'], choices=['admin', 'public', 'internal'],
help='Filter by interface type (admin, public or internal)', help=_('Filter by interface type (admin, public or internal)'),
) )
parser.add_argument( parser.add_argument(
'--region', '--region',
metavar='<region-id>', metavar='<region-id>',
help='Filter by region ID', help=_('Filter by region ID'),
) )
return parser return parser
@ -167,41 +168,41 @@ class SetEndpoint(command.Command):
parser.add_argument( parser.add_argument(
'endpoint', 'endpoint',
metavar='<endpoint-id>', metavar='<endpoint-id>',
help='Endpoint ID to modify', help=_('Endpoint ID to modify'),
) )
parser.add_argument( parser.add_argument(
'--region', '--region',
metavar='<region-id>', metavar='<region-id>',
help='New endpoint region ID', help=_('New endpoint region ID'),
) )
parser.add_argument( parser.add_argument(
'--interface', '--interface',
metavar='<interface>', metavar='<interface>',
choices=['admin', 'public', 'internal'], choices=['admin', 'public', 'internal'],
help='New endpoint interface type (admin, public or internal)', help=_('New endpoint interface type (admin, public or internal)'),
) )
parser.add_argument( parser.add_argument(
'--url', '--url',
metavar='<url>', metavar='<url>',
help='New endpoint URL', help=_('New endpoint URL'),
) )
parser.add_argument( parser.add_argument(
'--service', '--service',
metavar='<service>', metavar='<service>',
help='New endpoint service (name or ID)', help=_('New endpoint service (name or ID)'),
) )
enable_group = parser.add_mutually_exclusive_group() enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument( enable_group.add_argument(
'--enable', '--enable',
dest='enabled', dest='enabled',
action='store_true', action='store_true',
help='Enable endpoint', help=_('Enable endpoint'),
) )
enable_group.add_argument( enable_group.add_argument(
'--disable', '--disable',
dest='disabled', dest='disabled',
action='store_true', action='store_true',
help='Disable endpoint', help=_('Disable endpoint'),
) )
return parser return parser
@ -213,7 +214,7 @@ class SetEndpoint(command.Command):
if (not parsed_args.interface and not parsed_args.url if (not parsed_args.interface and not parsed_args.url
and not parsed_args.service and not parsed_args.region and not parsed_args.service and not parsed_args.region
and not parsed_args.enabled and not parsed_args.disabled): and not parsed_args.enabled and not parsed_args.disabled):
sys.stdout.write("Endpoint not updated, no arguments present\n") sys.stdout.write(_("Endpoint not updated, no arguments present\n"))
return return
service_id = None service_id = None
@ -244,8 +245,8 @@ class ShowEndpoint(command.ShowOne):
parser.add_argument( parser.add_argument(
'endpoint', 'endpoint',
metavar='<endpoint>', metavar='<endpoint>',
help='Endpoint to display (endpoint ID, service ID,' help=_('Endpoint to display (endpoint ID, service ID,'
' service name, service type)', ' service name, service type)'),
) )
return parser return parser

View File

@ -18,6 +18,7 @@ import six
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class CreateProtocol(command.ShowOne): class CreateProtocol(command.ShowOne):
@ -28,19 +29,22 @@ class CreateProtocol(command.ShowOne):
parser.add_argument( parser.add_argument(
'federation_protocol', 'federation_protocol',
metavar='<name>', metavar='<name>',
help='New federation protocol name (must be unique per identity ' help=_('New federation protocol name (must be unique '
' provider)') 'per identity provider)'),
)
parser.add_argument( parser.add_argument(
'--identity-provider', '--identity-provider',
metavar='<identity-provider>', metavar='<identity-provider>',
required=True, required=True,
help='Identity provider that will support the new federation ' help=_('Identity provider that will support the new federation '
' protocol (name or ID) (required)') ' protocol (name or ID) (required)'),
)
parser.add_argument( parser.add_argument(
'--mapping', '--mapping',
metavar='<mapping>', metavar='<mapping>',
required=True, required=True,
help='Mapping that is to be used (name or ID) (required)') help=_('Mapping that is to be used (name or ID) (required)'),
)
return parser return parser
@ -69,13 +73,15 @@ class DeleteProtocol(command.Command):
parser.add_argument( parser.add_argument(
'federation_protocol', 'federation_protocol',
metavar='<federation-protocol>', metavar='<federation-protocol>',
help='Federation protocol to delete (name or ID)') help=_('Federation protocol to delete (name or ID)'),
)
parser.add_argument( parser.add_argument(
'--identity-provider', '--identity-provider',
metavar='<identity-provider>', metavar='<identity-provider>',
required=True, required=True,
help='Identity provider that supports <federation-protocol> ' help=_('Identity provider that supports <federation-protocol> '
'(name or ID) (required)') '(name or ID) (required)'),
)
return parser return parser
@ -94,7 +100,8 @@ class ListProtocols(command.Lister):
'--identity-provider', '--identity-provider',
metavar='<identity-provider>', metavar='<identity-provider>',
required=True, required=True,
help='Identity provider to list (name or ID) (required)') help=_('Identity provider to list (name or ID) (required)'),
)
return parser return parser
@ -118,24 +125,27 @@ class SetProtocol(command.Command):
parser.add_argument( parser.add_argument(
'federation_protocol', 'federation_protocol',
metavar='<name>', metavar='<name>',
help='Federation protocol to modify (name or ID)') help=_('Federation protocol to modify (name or ID)'),
)
parser.add_argument( parser.add_argument(
'--identity-provider', '--identity-provider',
metavar='<identity-provider>', metavar='<identity-provider>',
required=True, required=True,
help='Identity provider that supports <federation-protocol> ' help=_('Identity provider that supports <federation-protocol> '
'(name or ID) (required)') '(name or ID) (required)'),
)
parser.add_argument( parser.add_argument(
'--mapping', '--mapping',
metavar='<mapping>', metavar='<mapping>',
help='Mapping that is to be used (name or ID)') help=_('Mapping that is to be used (name or ID)'),
)
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
identity_client = self.app.client_manager.identity identity_client = self.app.client_manager.identity
if not parsed_args.mapping: if not parsed_args.mapping:
self.app.log.error("No changes requested") self.app.log.error(_("No changes requested"))
return return
protocol = identity_client.federation.protocols.update( protocol = identity_client.federation.protocols.update(
@ -159,13 +169,15 @@ class ShowProtocol(command.ShowOne):
parser.add_argument( parser.add_argument(
'federation_protocol', 'federation_protocol',
metavar='<federation-protocol>', metavar='<federation-protocol>',
help='Federation protocol to display (name or ID)') help=_('Federation protocol to display (name or ID)'),
)
parser.add_argument( parser.add_argument(
'--identity-provider', '--identity-provider',
metavar='<identity-provider>', metavar='<identity-provider>',
required=True, required=True,
help=('Identity provider that supports <federation-protocol> ' help=_('Identity provider that supports <federation-protocol> '
'(name or ID) (required)')) '(name or ID) (required)'),
)
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):

View File

@ -34,12 +34,12 @@ class AddUserToGroup(command.Command):
parser.add_argument( parser.add_argument(
'group', 'group',
metavar='<group>', metavar='<group>',
help='Group to contain <user> (name or ID)', help=_('Group to contain <user> (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'user', 'user',
metavar='<user>', metavar='<user>',
help='User to add to <group> (name or ID)', help=_('User to add to <group> (name or ID)'),
) )
common.add_group_domain_option_to_parser(parser) common.add_group_domain_option_to_parser(parser)
common.add_user_domain_option_to_parser(parser) common.add_user_domain_option_to_parser(parser)
@ -58,11 +58,17 @@ class AddUserToGroup(command.Command):
try: try:
identity_client.users.add_to_group(user_id, group_id) identity_client.users.add_to_group(user_id, group_id)
except Exception: except Exception:
sys.stderr.write("%s not added to group %s\n" % msg = _("%(user)s not added to group %(group)s\n") % {
(parsed_args.user, parsed_args.group)) 'user': parsed_args.user,
'group': parsed_args.group,
}
sys.stderr.write(msg)
else: else:
sys.stdout.write("%s added to group %s\n" % msg = _("%(user)s added to group %(group)s\n") % {
(parsed_args.user, parsed_args.group)) 'user': parsed_args.user,
'group': parsed_args.group,
}
sys.stdout.write(msg)
class CheckUserInGroup(command.Command): class CheckUserInGroup(command.Command):
@ -73,12 +79,12 @@ class CheckUserInGroup(command.Command):
parser.add_argument( parser.add_argument(
'group', 'group',
metavar='<group>', metavar='<group>',
help='Group to check (name or ID)', help=_('Group to check (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'user', 'user',
metavar='<user>', metavar='<user>',
help='User to check (name or ID)', help=_('User to check (name or ID)'),
) )
common.add_group_domain_option_to_parser(parser) common.add_group_domain_option_to_parser(parser)
common.add_user_domain_option_to_parser(parser) common.add_user_domain_option_to_parser(parser)
@ -97,11 +103,17 @@ class CheckUserInGroup(command.Command):
try: try:
identity_client.users.check_in_group(user_id, group_id) identity_client.users.check_in_group(user_id, group_id)
except Exception: except Exception:
sys.stderr.write("%s not in group %s\n" % msg = _("%(user)s not in group %(group)s\n") % {
(parsed_args.user, parsed_args.group)) 'user': parsed_args.user,
'group': parsed_args.group,
}
sys.stderr.write(msg)
else: else:
sys.stdout.write("%s in group %s\n" % msg = _("%(user)s in group %(group)s\n") % {
(parsed_args.user, parsed_args.group)) 'user': parsed_args.user,
'group': parsed_args.group,
}
sys.stdout.write(msg)
class CreateGroup(command.ShowOne): class CreateGroup(command.ShowOne):
@ -112,17 +124,17 @@ class CreateGroup(command.ShowOne):
parser.add_argument( parser.add_argument(
'name', 'name',
metavar='<group-name>', metavar='<group-name>',
help='New group name', help=_('New group name'),
) )
parser.add_argument( parser.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Domain to contain new group (name or ID)', help=_('Domain to contain new group (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='New group description', help=_('New group description'),
) )
parser.add_argument( parser.add_argument(
'--or-show', '--or-show',
@ -149,7 +161,7 @@ class CreateGroup(command.ShowOne):
group = utils.find_resource(identity_client.groups, group = utils.find_resource(identity_client.groups,
parsed_args.name, parsed_args.name,
domain_id=domain) domain_id=domain)
self.log.info('Returning existing group %s', group.name) self.log.info(_('Returning existing group %s'), group.name)
else: else:
raise e raise e
@ -166,11 +178,12 @@ class DeleteGroup(command.Command):
'groups', 'groups',
metavar='<group>', metavar='<group>',
nargs="+", nargs="+",
help='Group(s) to delete (name or ID)') help=_('Group(s) to delete (name or ID)'),
)
parser.add_argument( parser.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Domain containing group(s) (name or ID)', help=_('Domain containing group(s) (name or ID)'),
) )
return parser return parser
@ -192,19 +205,19 @@ class ListGroup(command.Lister):
parser.add_argument( parser.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Filter group list by <domain> (name or ID)', help=_('Filter group list by <domain> (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--user', '--user',
metavar='<user>', metavar='<user>',
help='Filter group list by <user> (name or ID)', help=_('Filter group list by <user> (name or ID)'),
) )
common.add_user_domain_option_to_parser(parser) common.add_user_domain_option_to_parser(parser)
parser.add_argument( parser.add_argument(
'--long', '--long',
action='store_true', action='store_true',
default=False, default=False,
help='List additional fields in output', help=_('List additional fields in output'),
) )
return parser return parser
@ -252,12 +265,12 @@ class RemoveUserFromGroup(command.Command):
parser.add_argument( parser.add_argument(
'group', 'group',
metavar='<group>', metavar='<group>',
help='Group containing <user> (name or ID)', help=_('Group containing <user> (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'user', 'user',
metavar='<user>', metavar='<user>',
help='User to remove from <group> (name or ID)', help=_('User to remove from <group> (name or ID)'),
) )
common.add_group_domain_option_to_parser(parser) common.add_group_domain_option_to_parser(parser)
common.add_user_domain_option_to_parser(parser) common.add_user_domain_option_to_parser(parser)
@ -276,11 +289,17 @@ class RemoveUserFromGroup(command.Command):
try: try:
identity_client.users.remove_from_group(user_id, group_id) identity_client.users.remove_from_group(user_id, group_id)
except Exception: except Exception:
sys.stderr.write("%s not removed from group %s\n" % msg = _("%(user)s not removed from group %(group)s\n") % {
(parsed_args.user, parsed_args.group)) 'user': parsed_args.user,
'group': parsed_args.group,
}
sys.stderr.write(msg)
else: else:
sys.stdout.write("%s removed from group %s\n" % msg = _("%(user)s removed from group %(group)s\n") % {
(parsed_args.user, parsed_args.group)) 'user': parsed_args.user,
'group': parsed_args.group,
}
sys.stdout.write(msg)
class SetGroup(command.Command): class SetGroup(command.Command):
@ -291,20 +310,23 @@ class SetGroup(command.Command):
parser.add_argument( parser.add_argument(
'group', 'group',
metavar='<group>', metavar='<group>',
help='Group to modify (name or ID)') help=_('Group to modify (name or ID)'),
)
parser.add_argument( parser.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Domain containing <group> (name or ID)', help=_('Domain containing <group> (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<name>', metavar='<name>',
help='New group name') help=_('New group name'),
)
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='New group description') help=_('New group description'),
)
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
@ -331,12 +353,12 @@ class ShowGroup(command.ShowOne):
parser.add_argument( parser.add_argument(
'group', 'group',
metavar='<group>', metavar='<group>',
help='Group to display (name or ID)', help=_('Group to display (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Domain containing <group> (name or ID)', help=_('Domain containing <group> (name or ID)'),
) )
return parser return parser

View File

@ -17,6 +17,7 @@ import six
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class CreateIdentityProvider(command.ShowOne): class CreateIdentityProvider(command.ShowOne):
@ -27,26 +28,26 @@ class CreateIdentityProvider(command.ShowOne):
parser.add_argument( parser.add_argument(
'identity_provider_id', 'identity_provider_id',
metavar='<name>', metavar='<name>',
help='New identity provider name (must be unique)' help=_('New identity provider name (must be unique)'),
) )
identity_remote_id_provider = parser.add_mutually_exclusive_group() identity_remote_id_provider = parser.add_mutually_exclusive_group()
identity_remote_id_provider.add_argument( identity_remote_id_provider.add_argument(
'--remote-id', '--remote-id',
metavar='<remote-id>', metavar='<remote-id>',
action='append', action='append',
help='Remote IDs to associate with the Identity Provider ' help=_('Remote IDs to associate with the Identity Provider '
'(repeat option to provide multiple values)' '(repeat option to provide multiple values)'),
) )
identity_remote_id_provider.add_argument( identity_remote_id_provider.add_argument(
'--remote-id-file', '--remote-id-file',
metavar='<file-name>', metavar='<file-name>',
help='Name of a file that contains many remote IDs to associate ' help=_('Name of a file that contains many remote IDs to associate '
'with the identity provider, one per line' 'with the identity provider, one per line'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='New identity provider description', help=_('New identity provider description'),
) )
enable_identity_provider = parser.add_mutually_exclusive_group() enable_identity_provider = parser.add_mutually_exclusive_group()
enable_identity_provider.add_argument( enable_identity_provider.add_argument(
@ -54,13 +55,13 @@ class CreateIdentityProvider(command.ShowOne):
dest='enabled', dest='enabled',
action='store_true', action='store_true',
default=True, default=True,
help='Enable identity provider (default)', help=_('Enable identity provider (default)'),
) )
enable_identity_provider.add_argument( enable_identity_provider.add_argument(
'--disable', '--disable',
dest='enabled', dest='enabled',
action='store_false', action='store_false',
help='Disable the identity provider', help=_('Disable the identity provider'),
) )
return parser return parser
@ -94,7 +95,7 @@ class DeleteIdentityProvider(command.Command):
parser.add_argument( parser.add_argument(
'identity_provider', 'identity_provider',
metavar='<identity-provider>', metavar='<identity-provider>',
help='Identity provider to delete', help=_('Identity provider to delete'),
) )
return parser return parser
@ -126,37 +127,37 @@ class SetIdentityProvider(command.Command):
parser.add_argument( parser.add_argument(
'identity_provider', 'identity_provider',
metavar='<identity-provider>', metavar='<identity-provider>',
help='Identity provider to modify', help=_('Identity provider to modify'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='Set identity provider description', help=_('Set identity provider description'),
) )
identity_remote_id_provider = parser.add_mutually_exclusive_group() identity_remote_id_provider = parser.add_mutually_exclusive_group()
identity_remote_id_provider.add_argument( identity_remote_id_provider.add_argument(
'--remote-id', '--remote-id',
metavar='<remote-id>', metavar='<remote-id>',
action='append', action='append',
help='Remote IDs to associate with the Identity Provider ' help=_('Remote IDs to associate with the Identity Provider '
'(repeat option to provide multiple values)' '(repeat option to provide multiple values)'),
) )
identity_remote_id_provider.add_argument( identity_remote_id_provider.add_argument(
'--remote-id-file', '--remote-id-file',
metavar='<file-name>', metavar='<file-name>',
help='Name of a file that contains many remote IDs to associate ' help=_('Name of a file that contains many remote IDs to associate '
'with the identity provider, one per line' 'with the identity provider, one per line'),
) )
enable_identity_provider = parser.add_mutually_exclusive_group() enable_identity_provider = parser.add_mutually_exclusive_group()
enable_identity_provider.add_argument( enable_identity_provider.add_argument(
'--enable', '--enable',
action='store_true', action='store_true',
help='Enable the identity provider', help=_('Enable the identity provider'),
) )
enable_identity_provider.add_argument( enable_identity_provider.add_argument(
'--disable', '--disable',
action='store_true', action='store_true',
help='Disable the identity provider', help=_('Disable the identity provider'),
) )
return parser return parser
@ -168,7 +169,7 @@ class SetIdentityProvider(command.Command):
not parsed_args.remote_id and not parsed_args.remote_id and
not parsed_args.remote_id_file and not parsed_args.remote_id_file and
not parsed_args.description): not parsed_args.description):
self.log.error('No changes requested') self.log.error(_('No changes requested'))
return (None, None) return (None, None)
# Always set remote_ids if either is passed in # Always set remote_ids if either is passed in
@ -206,7 +207,7 @@ class ShowIdentityProvider(command.ShowOne):
parser.add_argument( parser.add_argument(
'identity_provider', 'identity_provider',
metavar='<identity-provider>', metavar='<identity-provider>',
help='Identity provider to display', help=_('Identity provider to display'),
) )
return parser return parser

View File

@ -22,6 +22,7 @@ import six
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import exceptions from openstackclient.common import exceptions
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class _RulesReader(object): class _RulesReader(object):
@ -69,9 +70,9 @@ class _RulesReader(object):
try: try:
rules = json.loads(blob) rules = json.loads(blob)
except ValueError as e: except ValueError as e:
raise exceptions.CommandError( msg = _("An error occurred when reading rules from file "
'An error occurred when reading ' "%(path)s: %(error)s") % {"path": path, "error": e}
'rules from file %s: %s' % (path, e)) raise exceptions.CommandError(msg)
else: else:
return rules return rules
@ -84,12 +85,12 @@ class CreateMapping(command.ShowOne, _RulesReader):
parser.add_argument( parser.add_argument(
'mapping', 'mapping',
metavar='<name>', metavar='<name>',
help='New mapping name (must be unique)', help=_('New mapping name (must be unique)'),
) )
parser.add_argument( parser.add_argument(
'--rules', '--rules',
metavar='<filename>', required=True, metavar='<filename>', required=True,
help='Filename that contains a set of mapping rules (required)', help=_('Filename that contains a set of mapping rules (required)'),
) )
return parser return parser
@ -113,7 +114,7 @@ class DeleteMapping(command.Command):
parser.add_argument( parser.add_argument(
'mapping', 'mapping',
metavar='<mapping>', metavar='<mapping>',
help='Mapping to delete', help=_('Mapping to delete'),
) )
return parser return parser
@ -145,12 +146,12 @@ class SetMapping(command.Command, _RulesReader):
parser.add_argument( parser.add_argument(
'mapping', 'mapping',
metavar='<name>', metavar='<name>',
help='Mapping to modify', help=_('Mapping to modify'),
) )
parser.add_argument( parser.add_argument(
'--rules', '--rules',
metavar='<filename>', metavar='<filename>',
help='Filename that contains a new set of mapping rules', help=_('Filename that contains a new set of mapping rules'),
) )
return parser return parser
@ -158,7 +159,7 @@ class SetMapping(command.Command, _RulesReader):
identity_client = self.app.client_manager.identity identity_client = self.app.client_manager.identity
if not parsed_args.rules: if not parsed_args.rules:
self.app.log.error("No changes requested") self.app.log.error(_("No changes requested"))
return return
rules = self._read_rules(parsed_args.rules) rules = self._read_rules(parsed_args.rules)
@ -179,7 +180,7 @@ class ShowMapping(command.ShowOne):
parser.add_argument( parser.add_argument(
'mapping', 'mapping',
metavar='<mapping>', metavar='<mapping>',
help='Mapping to display', help=_('Mapping to display'),
) )
return parser return parser

View File

@ -20,6 +20,7 @@ import sys
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class CreatePolicy(command.ShowOne): class CreatePolicy(command.ShowOne):
@ -31,13 +32,13 @@ class CreatePolicy(command.ShowOne):
'--type', '--type',
metavar='<type>', metavar='<type>',
default="application/json", default="application/json",
help='New MIME type of the policy rules file ' help=_('New MIME type of the policy rules file '
'(defaults to application/json)', '(defaults to application/json)'),
) )
parser.add_argument( parser.add_argument(
'rules', 'rules',
metavar='<filename>', metavar='<filename>',
help='New serialized policy rules file', help=_('New serialized policy rules file'),
) )
return parser return parser
@ -62,7 +63,7 @@ class DeletePolicy(command.Command):
parser.add_argument( parser.add_argument(
'policy', 'policy',
metavar='<policy>', metavar='<policy>',
help='Policy to delete', help=_('Policy to delete'),
) )
return parser return parser
@ -80,7 +81,7 @@ class ListPolicy(command.Lister):
'--long', '--long',
action='store_true', action='store_true',
default=False, default=False,
help='List additional fields in output', help=_('List additional fields in output'),
) )
return parser return parser
@ -107,17 +108,17 @@ class SetPolicy(command.Command):
parser.add_argument( parser.add_argument(
'policy', 'policy',
metavar='<policy>', metavar='<policy>',
help='Policy to modify', help=_('Policy to modify'),
) )
parser.add_argument( parser.add_argument(
'--type', '--type',
metavar='<type>', metavar='<type>',
help='New MIME type of the policy rules file', help=_('New MIME type of the policy rules file'),
) )
parser.add_argument( parser.add_argument(
'--rules', '--rules',
metavar='<filename>', metavar='<filename>',
help='New serialized policy rules file', help=_('New serialized policy rules file'),
) )
return parser return parser
@ -135,7 +136,7 @@ class SetPolicy(command.Command):
kwargs['type'] = parsed_args.type kwargs['type'] = parsed_args.type
if not kwargs: if not kwargs:
sys.stdout.write('Policy not updated, no arguments present \n') sys.stdout.write(_('Policy not updated, no arguments present\n'))
return return
identity_client.policies.update(parsed_args.policy, **kwargs) identity_client.policies.update(parsed_args.policy, **kwargs)
@ -148,7 +149,7 @@ class ShowPolicy(command.ShowOne):
parser.add_argument( parser.add_argument(
'policy', 'policy',
metavar='<policy>', metavar='<policy>',
help='Policy to display', help=_('Policy to display'),
) )
return parser return parser

View File

@ -34,40 +34,40 @@ class CreateProject(command.ShowOne):
parser.add_argument( parser.add_argument(
'name', 'name',
metavar='<project-name>', metavar='<project-name>',
help='New project name', help=_('New project name'),
) )
parser.add_argument( parser.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Domain owning the project (name or ID)', help=_('Domain owning the project (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--parent', '--parent',
metavar='<project>', metavar='<project>',
help='Parent of the project (name or ID)', help=_('Parent of the project (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='Project description', help=_('Project description'),
) )
enable_group = parser.add_mutually_exclusive_group() enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument( enable_group.add_argument(
'--enable', '--enable',
action='store_true', action='store_true',
help='Enable project', help=_('Enable project'),
) )
enable_group.add_argument( enable_group.add_argument(
'--disable', '--disable',
action='store_true', action='store_true',
help='Disable project', help=_('Disable project'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Add a property to <name> ' help=_('Add a property to <name> '
'(repeat option to set multiple properties)', '(repeat option to set multiple properties)'),
) )
parser.add_argument( parser.add_argument(
'--or-show', '--or-show',
@ -112,7 +112,7 @@ class CreateProject(command.ShowOne):
project = utils.find_resource(identity_client.projects, project = utils.find_resource(identity_client.projects,
parsed_args.name, parsed_args.name,
domain_id=domain) domain_id=domain)
self.log.info('Returning existing project %s', project.name) self.log.info(_('Returning existing project %s'), project.name)
else: else:
raise e raise e
@ -129,12 +129,12 @@ class DeleteProject(command.Command):
'projects', 'projects',
metavar='<project>', metavar='<project>',
nargs="+", nargs="+",
help='Project(s) to delete (name or ID)', help=_('Project(s) to delete (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Domain owning <project> (name or ID)', help=_('Domain owning <project> (name or ID)'),
) )
return parser return parser
@ -163,18 +163,18 @@ class ListProject(command.Lister):
parser.add_argument( parser.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Filter projects by <domain> (name or ID)', help=_('Filter projects by <domain> (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--user', '--user',
metavar='<user>', metavar='<user>',
help='Filter projects by <user> (name or ID)', help=_('Filter projects by <user> (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--long', '--long',
action='store_true', action='store_true',
default=False, default=False,
help='List additional fields in output', help=_('List additional fields in output'),
) )
return parser return parser
@ -219,40 +219,40 @@ class SetProject(command.Command):
parser.add_argument( parser.add_argument(
'project', 'project',
metavar='<project>', metavar='<project>',
help='Project to modify (name or ID)', help=_('Project to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<name>', metavar='<name>',
help='Set project name', help=_('Set project name'),
) )
parser.add_argument( parser.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Domain owning <project> (name or ID)', help=_('Domain owning <project> (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='Set project description', help=_('Set project description'),
) )
enable_group = parser.add_mutually_exclusive_group() enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument( enable_group.add_argument(
'--enable', '--enable',
action='store_true', action='store_true',
help='Enable project', help=_('Enable project'),
) )
enable_group.add_argument( enable_group.add_argument(
'--disable', '--disable',
action='store_true', action='store_true',
help='Disable project', help=_('Disable project'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Set a property on <project> ' help=_('Set a property on <project> '
'(repeat option to set multiple properties)', '(repeat option to set multiple properties)'),
) )
return parser return parser
@ -293,24 +293,24 @@ class ShowProject(command.ShowOne):
parser.add_argument( parser.add_argument(
'project', 'project',
metavar='<project>', metavar='<project>',
help='Project to display (name or ID)', help=_('Project to display (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Domain owning <project> (name or ID)', help=_('Domain owning <project> (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--parents', '--parents',
action='store_true', action='store_true',
default=False, default=False,
help='Show the project\'s parents as a list', help=_('Show the project\'s parents as a list'),
) )
parser.add_argument( parser.add_argument(
'--children', '--children',
action='store_true', action='store_true',
default=False, default=False,
help='Show project\'s subtree (children) as a list', help=_('Show project\'s subtree (children) as a list'),
) )
return parser return parser

View File

@ -31,23 +31,23 @@ def _add_identity_and_resource_options_to_parser(parser):
domain_or_project.add_argument( domain_or_project.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Include <domain> (name or ID)', help=_('Include <domain> (name or ID)'),
) )
domain_or_project.add_argument( domain_or_project.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
help='Include <project> (name or ID)', help=_('Include <project> (name or ID)'),
) )
user_or_group = parser.add_mutually_exclusive_group() user_or_group = parser.add_mutually_exclusive_group()
user_or_group.add_argument( user_or_group.add_argument(
'--user', '--user',
metavar='<user>', metavar='<user>',
help='Include <user> (name or ID)', help=_('Include <user> (name or ID)'),
) )
user_or_group.add_argument( user_or_group.add_argument(
'--group', '--group',
metavar='<group>', metavar='<group>',
help='Include <group> (name or ID)', help=_('Include <group> (name or ID)'),
) )
common.add_group_domain_option_to_parser(parser) common.add_group_domain_option_to_parser(parser)
common.add_project_domain_option_to_parser(parser) common.add_project_domain_option_to_parser(parser)
@ -112,7 +112,7 @@ class AddRole(command.Command):
parser.add_argument( parser.add_argument(
'role', 'role',
metavar='<role>', metavar='<role>',
help='Role to add to <user> (name or ID)', help=_('Role to add to <user> (name or ID)'),
) )
_add_identity_and_resource_options_to_parser(parser) _add_identity_and_resource_options_to_parser(parser)
return parser return parser
@ -131,9 +131,9 @@ class AddRole(command.Command):
kwargs = _process_identity_and_resource_options( kwargs = _process_identity_and_resource_options(
parsed_args, self.app.client_manager.identity) parsed_args, self.app.client_manager.identity)
if not kwargs: if not kwargs:
sys.stderr.write("Role not added, incorrect set of arguments " sys.stderr.write(_("Role not added, incorrect set of arguments "
"provided. See openstack --help for more " "provided. See openstack --help for more "
"details\n") "details\n"))
return return
identity_client.roles.grant(role.id, **kwargs) identity_client.roles.grant(role.id, **kwargs)
@ -147,7 +147,7 @@ class CreateRole(command.ShowOne):
parser.add_argument( parser.add_argument(
'name', 'name',
metavar='<role-name>', metavar='<role-name>',
help='New role name', help=_('New role name'),
) )
parser.add_argument( parser.add_argument(
'--or-show', '--or-show',
@ -165,7 +165,7 @@ class CreateRole(command.ShowOne):
if parsed_args.or_show: if parsed_args.or_show:
role = utils.find_resource(identity_client.roles, role = utils.find_resource(identity_client.roles,
parsed_args.name) parsed_args.name)
self.log.info('Returning existing role %s', role.name) self.log.info(_('Returning existing role %s'), role.name)
else: else:
raise e raise e
@ -182,7 +182,7 @@ class DeleteRole(command.Command):
'roles', 'roles',
metavar='<role>', metavar='<role>',
nargs="+", nargs="+",
help='Role(s) to delete (name or ID)', help=_('Role(s) to delete (name or ID)'),
) )
return parser return parser
@ -285,9 +285,9 @@ class ListRole(command.Lister):
group_role.group = group.name group_role.group = group.name
group_role.project = project.name group_role.project = project.name
else: else:
sys.stderr.write("Error: If a user or group is specified, either " sys.stderr.write(_("Error: If a user or group is specified, "
"--domain or --project must also be specified to " "either --domain or --project must also be "
"list role grants.\n") "specified to list role grants.\n"))
return ([], []) return ([], [])
return (columns, return (columns,
@ -305,7 +305,7 @@ class RemoveRole(command.Command):
parser.add_argument( parser.add_argument(
'role', 'role',
metavar='<role>', metavar='<role>',
help='Role to remove (name or ID)', help=_('Role to remove (name or ID)'),
) )
_add_identity_and_resource_options_to_parser(parser) _add_identity_and_resource_options_to_parser(parser)
return parser return parser
@ -315,9 +315,8 @@ class RemoveRole(command.Command):
if (not parsed_args.user and not parsed_args.domain if (not parsed_args.user and not parsed_args.domain
and not parsed_args.group and not parsed_args.project): and not parsed_args.group and not parsed_args.project):
sys.stderr.write("Incorrect set of arguments " sys.stderr.write(_("Incorrect set of arguments provided. "
"provided. See openstack --help for more " "See openstack --help for more details\n"))
"details\n")
return return
role = utils.find_resource( role = utils.find_resource(
identity_client.roles, identity_client.roles,
@ -327,8 +326,9 @@ class RemoveRole(command.Command):
kwargs = _process_identity_and_resource_options( kwargs = _process_identity_and_resource_options(
parsed_args, self.app.client_manager.identity) parsed_args, self.app.client_manager.identity)
if not kwargs: if not kwargs:
sys.stderr.write("Role not removed, incorrect set of arguments \ sys.stderr.write(_("Role not removed, incorrect set of arguments "
provided. See openstack --help for more details\n") "provided. See openstack --help for more "
"details\n"))
return return
identity_client.roles.revoke(role.id, **kwargs) identity_client.roles.revoke(role.id, **kwargs)
@ -341,12 +341,12 @@ class SetRole(command.Command):
parser.add_argument( parser.add_argument(
'role', 'role',
metavar='<role>', metavar='<role>',
help='Role to modify (name or ID)', help=_('Role to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<name>', metavar='<name>',
help='Set role name', help=_('Set role name'),
) )
return parser return parser
@ -354,9 +354,8 @@ class SetRole(command.Command):
identity_client = self.app.client_manager.identity identity_client = self.app.client_manager.identity
if not parsed_args.name: if not parsed_args.name:
sys.stderr.write("Incorrect set of arguments " sys.stderr.write(_("Incorrect set of arguments provided. "
"provided. See openstack --help for more " "See openstack --help for more details\n"))
"details\n")
return return
role = utils.find_resource( role = utils.find_resource(
identity_client.roles, identity_client.roles,
@ -374,7 +373,7 @@ class ShowRole(command.ShowOne):
parser.add_argument( parser.add_argument(
'role', 'role',
metavar='<role>', metavar='<role>',
help='Role to display (name or ID)', help=_('Role to display (name or ID)'),
) )
return parser return parser

View File

@ -15,6 +15,7 @@
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
from openstackclient.identity import common from openstackclient.identity import common
@ -27,41 +28,41 @@ class ListRoleAssignment(command.Lister):
'--effective', '--effective',
action="store_true", action="store_true",
default=False, default=False,
help='Returns only effective role assignments', help=_('Returns only effective role assignments'),
) )
parser.add_argument( parser.add_argument(
'--role', '--role',
metavar='<role>', metavar='<role>',
help='Role to filter (name or ID)', help=_('Role to filter (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--names', '--names',
action="store_true", action="store_true",
help='Display names instead of IDs', help=_('Display names instead of IDs'),
) )
user_or_group = parser.add_mutually_exclusive_group() user_or_group = parser.add_mutually_exclusive_group()
user_or_group.add_argument( user_or_group.add_argument(
'--user', '--user',
metavar='<user>', metavar='<user>',
help='User to filter (name or ID)', help=_('User to filter (name or ID)'),
) )
common.add_user_domain_option_to_parser(parser) common.add_user_domain_option_to_parser(parser)
user_or_group.add_argument( user_or_group.add_argument(
'--group', '--group',
metavar='<group>', metavar='<group>',
help='Group to filter (name or ID)', help=_('Group to filter (name or ID)'),
) )
common.add_group_domain_option_to_parser(parser) common.add_group_domain_option_to_parser(parser)
domain_or_project = parser.add_mutually_exclusive_group() domain_or_project = parser.add_mutually_exclusive_group()
domain_or_project.add_argument( domain_or_project.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Domain to filter (name or ID)', help=_('Domain to filter (name or ID)'),
) )
domain_or_project.add_argument( domain_or_project.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
help='Project to filter (name or ID)', help=_('Project to filter (name or ID)'),
) )
common.add_project_domain_option_to_parser(parser) common.add_project_domain_option_to_parser(parser)
common.add_inherited_option_to_parser(parser) common.add_inherited_option_to_parser(parser)

View File

@ -20,6 +20,7 @@ import sys
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
from openstackclient.identity import common from openstackclient.identity import common
@ -31,28 +32,28 @@ class CreateService(command.ShowOne):
parser.add_argument( parser.add_argument(
'type', 'type',
metavar='<type>', metavar='<type>',
help='New service type (compute, image, identity, volume, etc)', help=_('New service type (compute, image, identity, volume, etc)'),
) )
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<name>', metavar='<name>',
help='New service name', help=_('New service name'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='New service description', help=_('New service description'),
) )
enable_group = parser.add_mutually_exclusive_group() enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument( enable_group.add_argument(
'--enable', '--enable',
action='store_true', action='store_true',
help='Enable service (default)', help=_('Enable service (default)'),
) )
enable_group.add_argument( enable_group.add_argument(
'--disable', '--disable',
action='store_true', action='store_true',
help='Disable service', help=_('Disable service'),
) )
return parser return parser
@ -82,7 +83,7 @@ class DeleteService(command.Command):
parser.add_argument( parser.add_argument(
'service', 'service',
metavar='<service>', metavar='<service>',
help='Service to delete (type, name or ID)', help=_('Service to delete (type, name or ID)'),
) )
return parser return parser
@ -103,7 +104,7 @@ class ListService(command.Lister):
'--long', '--long',
action='store_true', action='store_true',
default=False, default=False,
help='List additional fields in output', help=_('List additional fields in output'),
) )
return parser return parser
@ -128,33 +129,33 @@ class SetService(command.Command):
parser.add_argument( parser.add_argument(
'service', 'service',
metavar='<service>', metavar='<service>',
help='Service to update (type, name or ID)', help=_('Service to update (type, name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--type', '--type',
metavar='<type>', metavar='<type>',
help='New service type (compute, image, identity, volume, etc)', help=_('New service type (compute, image, identity, volume, etc)'),
) )
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<service-name>', metavar='<service-name>',
help='New service name', help=_('New service name'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='New service description', help=_('New service description'),
) )
enable_group = parser.add_mutually_exclusive_group() enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument( enable_group.add_argument(
'--enable', '--enable',
action='store_true', action='store_true',
help='Enable service', help=_('Enable service'),
) )
enable_group.add_argument( enable_group.add_argument(
'--disable', '--disable',
action='store_true', action='store_true',
help='Disable service', help=_('Disable service'),
) )
return parser return parser
@ -166,9 +167,8 @@ class SetService(command.Command):
and not parsed_args.description and not parsed_args.description
and not parsed_args.enable and not parsed_args.enable
and not parsed_args.disable): and not parsed_args.disable):
sys.stderr.write("Incorrect set of arguments " sys.stderr.write(_("Incorrect set of arguments provided. "
"provided. See openstack --help for more " "See openstack --help for more details\n"))
"details\n")
return return
service = common.find_service(identity_client, service = common.find_service(identity_client,
parsed_args.service) parsed_args.service)
@ -198,7 +198,7 @@ class ShowService(command.ShowOne):
parser.add_argument( parser.add_argument(
'service', 'service',
metavar='<service>', metavar='<service>',
help='Service to display (type, name or ID)', help=_('Service to display (type, name or ID)'),
) )
return parser return parser

View File

@ -18,6 +18,7 @@ import sys
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class CreateServiceProvider(command.ShowOne): class CreateServiceProvider(command.ShowOne):
@ -28,26 +29,26 @@ class CreateServiceProvider(command.ShowOne):
parser.add_argument( parser.add_argument(
'service_provider_id', 'service_provider_id',
metavar='<name>', metavar='<name>',
help='New service provider name (must be unique)' help=_('New service provider name (must be unique)'),
) )
parser.add_argument( parser.add_argument(
'--auth-url', '--auth-url',
metavar='<auth-url>', metavar='<auth-url>',
required=True, required=True,
help='Authentication URL of remote federated service provider ' help=_('Authentication URL of remote federated service provider '
'(required)', '(required)'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='New service provider description', help=_('New service provider description'),
) )
parser.add_argument( parser.add_argument(
'--service-provider-url', '--service-provider-url',
metavar='<sp-url>', metavar='<sp-url>',
required=True, required=True,
help='A service URL where SAML assertions are being sent ' help=_('A service URL where SAML assertions are being sent '
'(required)', '(required)'),
) )
enable_service_provider = parser.add_mutually_exclusive_group() enable_service_provider = parser.add_mutually_exclusive_group()
@ -56,13 +57,13 @@ class CreateServiceProvider(command.ShowOne):
dest='enabled', dest='enabled',
action='store_true', action='store_true',
default=True, default=True,
help='Enable the service provider (default)', help=_('Enable the service provider (default)'),
) )
enable_service_provider.add_argument( enable_service_provider.add_argument(
'--disable', '--disable',
dest='enabled', dest='enabled',
action='store_false', action='store_false',
help='Disable the service provider', help=_('Disable the service provider'),
) )
return parser return parser
@ -88,7 +89,7 @@ class DeleteServiceProvider(command.Command):
parser.add_argument( parser.add_argument(
'service_provider', 'service_provider',
metavar='<service-provider>', metavar='<service-provider>',
help='Service provider to delete', help=_('Service provider to delete'),
) )
return parser return parser
@ -121,34 +122,35 @@ class SetServiceProvider(command.Command):
parser.add_argument( parser.add_argument(
'service_provider', 'service_provider',
metavar='<service-provider>', metavar='<service-provider>',
help='Service provider to modify', help=_('Service provider to modify'),
) )
parser.add_argument( parser.add_argument(
'--auth-url', '--auth-url',
metavar='<auth-url>', metavar='<auth-url>',
help='New Authentication URL of remote federated service provider', help=_('New Authentication URL of remote '
'federated service provider'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='New service provider description', help=_('New service provider description'),
) )
parser.add_argument( parser.add_argument(
'--service-provider-url', '--service-provider-url',
metavar='<sp-url>', metavar='<sp-url>',
help='New service provider URL, where SAML assertions are sent', help=_('New service provider URL, where SAML assertions are sent'),
) )
enable_service_provider = parser.add_mutually_exclusive_group() enable_service_provider = parser.add_mutually_exclusive_group()
enable_service_provider.add_argument( enable_service_provider.add_argument(
'--enable', '--enable',
action='store_true', action='store_true',
help='Enable the service provider', help=_('Enable the service provider'),
) )
enable_service_provider.add_argument( enable_service_provider.add_argument(
'--disable', '--disable',
action='store_true', action='store_true',
help='Disable the service provider', help=_('Disable the service provider'),
) )
return parser return parser
@ -164,8 +166,8 @@ class SetServiceProvider(command.Command):
if not any((enabled is not None, parsed_args.description, if not any((enabled is not None, parsed_args.description,
parsed_args.service_provider_url, parsed_args.service_provider_url,
parsed_args.auth_url)): parsed_args.auth_url)):
sys.stdout.write("Service Provider not updated, no arguments " sys.stdout.write(_("Service Provider not updated, no arguments "
"present\n") "present\n"))
return (None, None) return (None, None)
service_provider = federation_client.service_providers.update( service_provider = federation_client.service_providers.update(
@ -184,7 +186,7 @@ class ShowServiceProvider(command.ShowOne):
parser.add_argument( parser.add_argument(
'service_provider', 'service_provider',
metavar='<service-provider>', metavar='<service-provider>',
help='Service provider to display', help=_('Service provider to display'),
) )
return parser return parser

View File

@ -20,6 +20,7 @@ import six
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import exceptions from openstackclient.common import exceptions
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
from openstackclient.identity import common from openstackclient.identity import common
@ -31,17 +32,17 @@ class AuthorizeRequestToken(command.ShowOne):
parser.add_argument( parser.add_argument(
'--request-key', '--request-key',
metavar='<request-key>', metavar='<request-key>',
help='Request token to authorize (ID only) (required)', required=True,
required=True help=_('Request token to authorize (ID only) (required)'),
) )
parser.add_argument( parser.add_argument(
'--role', '--role',
metavar='<role>', metavar='<role>',
action='append', action='append',
default=[], default=[],
help='Roles to authorize (name or ID) ' required=True,
'(repeat option to set multiple values, required)', help=_('Roles to authorize (name or ID) '
required=True '(repeat option to set multiple values, required)'),
) )
return parser return parser
@ -72,31 +73,31 @@ class CreateAccessToken(command.ShowOne):
parser.add_argument( parser.add_argument(
'--consumer-key', '--consumer-key',
metavar='<consumer-key>', metavar='<consumer-key>',
help='Consumer key (required)', help=_('Consumer key (required)'),
required=True required=True
) )
parser.add_argument( parser.add_argument(
'--consumer-secret', '--consumer-secret',
metavar='<consumer-secret>', metavar='<consumer-secret>',
help='Consumer secret (required)', help=_('Consumer secret (required)'),
required=True required=True
) )
parser.add_argument( parser.add_argument(
'--request-key', '--request-key',
metavar='<request-key>', metavar='<request-key>',
help='Request token to exchange for access token (required)', help=_('Request token to exchange for access token (required)'),
required=True required=True
) )
parser.add_argument( parser.add_argument(
'--request-secret', '--request-secret',
metavar='<request-secret>', metavar='<request-secret>',
help='Secret associated with <request-key> (required)', help=_('Secret associated with <request-key> (required)'),
required=True required=True
) )
parser.add_argument( parser.add_argument(
'--verifier', '--verifier',
metavar='<verifier>', metavar='<verifier>',
help='Verifier associated with <request-key> (required)', help=_('Verifier associated with <request-key> (required)'),
required=True required=True
) )
return parser return parser
@ -118,26 +119,26 @@ class CreateRequestToken(command.ShowOne):
parser.add_argument( parser.add_argument(
'--consumer-key', '--consumer-key',
metavar='<consumer-key>', metavar='<consumer-key>',
help='Consumer key (required)', help=_('Consumer key (required)'),
required=True required=True
) )
parser.add_argument( parser.add_argument(
'--consumer-secret', '--consumer-secret',
metavar='<consumer-secret>', metavar='<consumer-secret>',
help='Consumer secret (required)', help=_('Consumer secret (required)'),
required=True required=True
) )
parser.add_argument( parser.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
help='Project that consumer wants to access (name or ID)' help=_('Project that consumer wants to access (name or ID)'
' (required)', ' (required)'),
required=True required=True
) )
parser.add_argument( parser.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Domain owning <project> (name or ID)', help=_('Domain owning <project> (name or ID)'),
) )
return parser return parser
@ -175,7 +176,7 @@ class IssueToken(command.ShowOne):
def take_action(self, parsed_args): def take_action(self, parsed_args):
if not self.app.client_manager.auth_ref: if not self.app.client_manager.auth_ref:
raise exceptions.AuthorizationFailure( raise exceptions.AuthorizationFailure(
"Only an authorized user may issue a new token.") _("Only an authorized user may issue a new token."))
token = self.app.client_manager.auth_ref.service_catalog.get_token() token = self.app.client_manager.auth_ref.service_catalog.get_token()
if 'tenant_id' in token: if 'tenant_id' in token:
token['project_id'] = token.pop('tenant_id') token['project_id'] = token.pop('tenant_id')
@ -190,7 +191,7 @@ class RevokeToken(command.Command):
parser.add_argument( parser.add_argument(
'token', 'token',
metavar='<token>', metavar='<token>',
help='Token to be deleted', help=_('Token to be deleted'),
) )
return parser return parser

View File

@ -18,6 +18,7 @@ import six
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
from openstackclient.identity import common from openstackclient.identity import common
@ -29,26 +30,26 @@ class CreateTrust(command.ShowOne):
parser.add_argument( parser.add_argument(
'trustor', 'trustor',
metavar='<trustor-user>', metavar='<trustor-user>',
help='User that is delegating authorization (name or ID)', help=_('User that is delegating authorization (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'trustee', 'trustee',
metavar='<trustee-user>', metavar='<trustee-user>',
help='User that is assuming authorization (name or ID)', help=_('User that is assuming authorization (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
required=True, required=True,
help='Project being delegated (name or ID) (required)', help=_('Project being delegated (name or ID) (required)'),
) )
parser.add_argument( parser.add_argument(
'--role', '--role',
metavar='<role>', metavar='<role>',
action='append', action='append',
default=[], default=[],
help='Roles to authorize (name or ID) ' help=_('Roles to authorize (name or ID) '
'(repeat option to set multiple values, required)', '(repeat option to set multiple values, required)'),
required=True required=True
) )
parser.add_argument( parser.add_argument(
@ -56,25 +57,25 @@ class CreateTrust(command.ShowOne):
dest='impersonate', dest='impersonate',
action='store_true', action='store_true',
default=False, default=False,
help='Tokens generated from the trust will represent <trustor>' help=_('Tokens generated from the trust will represent <trustor>'
' (defaults to False)', ' (defaults to False)'),
) )
parser.add_argument( parser.add_argument(
'--expiration', '--expiration',
metavar='<expiration>', metavar='<expiration>',
help='Sets an expiration date for the trust' help=_('Sets an expiration date for the trust'
' (format of YYYY-mm-ddTHH:MM:SS)', ' (format of YYYY-mm-ddTHH:MM:SS)'),
) )
common.add_project_domain_option_to_parser(parser) common.add_project_domain_option_to_parser(parser)
parser.add_argument( parser.add_argument(
'--trustor-domain', '--trustor-domain',
metavar='<trustor-domain>', metavar='<trustor-domain>',
help='Domain that contains <trustor> (name or ID)', help=_('Domain that contains <trustor> (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--trustee-domain', '--trustee-domain',
metavar='<trustee-domain>', metavar='<trustee-domain>',
help='Domain that contains <trustee> (name or ID)', help=_('Domain that contains <trustee> (name or ID)'),
) )
return parser return parser
@ -136,8 +137,8 @@ class DeleteTrust(command.Command):
parser.add_argument( parser.add_argument(
'trust', 'trust',
metavar='<trust>', metavar='<trust>',
help='Trust(s) to delete',
nargs="+", nargs="+",
help=_('Trust(s) to delete'),
) )
return parser return parser
@ -170,7 +171,7 @@ class ShowTrust(command.ShowOne):
parser.add_argument( parser.add_argument(
'trust', 'trust',
metavar='<trust>', metavar='<trust>',
help='Trust to display', help=_('Trust to display'),
) )
return parser return parser

View File

@ -20,6 +20,7 @@ a scoped token."""
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import exceptions from openstackclient.common import exceptions
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
UNSCOPED_AUTH_PLUGINS = ['v3unscopedsaml', 'v3unscopedadfs', 'v3oidc'] UNSCOPED_AUTH_PLUGINS = ['v3unscopedsaml', 'v3unscopedadfs', 'v3oidc']
@ -33,10 +34,10 @@ def auth_with_unscoped_saml(func):
if auth_plugin_name in UNSCOPED_AUTH_PLUGINS: if auth_plugin_name in UNSCOPED_AUTH_PLUGINS:
return func(self, parsed_args) return func(self, parsed_args)
else: else:
msg = ('This command requires the use of an unscoped SAML ' msg = (_('This command requires the use of an unscoped SAML '
'authentication plugin. Please use argument ' 'authentication plugin. Please use argument '
'--os-auth-type with one of the following ' '--os-auth-type with one of the following '
'plugins: ' + ', '.join(UNSCOPED_AUTH_PLUGINS)) 'plugins: %s') % ', '.join(UNSCOPED_AUTH_PLUGINS))
raise exceptions.CommandError(msg) raise exceptions.CommandError(msg)
return _decorated return _decorated

View File

@ -35,50 +35,50 @@ class CreateUser(command.ShowOne):
parser.add_argument( parser.add_argument(
'name', 'name',
metavar='<name>', metavar='<name>',
help='New user name', help=_('New user name'),
) )
parser.add_argument( parser.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Default domain (name or ID)', help=_('Default domain (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
help='Default project (name or ID)', help=_('Default project (name or ID)'),
) )
common.add_project_domain_option_to_parser(parser) common.add_project_domain_option_to_parser(parser)
parser.add_argument( parser.add_argument(
'--password', '--password',
metavar='<password>', metavar='<password>',
help='Set user password', help=_('Set user password'),
) )
parser.add_argument( parser.add_argument(
'--password-prompt', '--password-prompt',
dest="password_prompt", dest="password_prompt",
action="store_true", action="store_true",
help='Prompt interactively for password', help=_('Prompt interactively for password'),
) )
parser.add_argument( parser.add_argument(
'--email', '--email',
metavar='<email-address>', metavar='<email-address>',
help='Set user email address', help=_('Set user email address'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='User description', help=_('User description'),
) )
enable_group = parser.add_mutually_exclusive_group() enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument( enable_group.add_argument(
'--enable', '--enable',
action='store_true', action='store_true',
help='Enable user (default)', help=_('Enable user (default)'),
) )
enable_group.add_argument( enable_group.add_argument(
'--disable', '--disable',
action='store_true', action='store_true',
help='Disable user', help=_('Disable user'),
) )
parser.add_argument( parser.add_argument(
'--or-show', '--or-show',
@ -122,7 +122,7 @@ class CreateUser(command.ShowOne):
user = utils.find_resource(identity_client.users, user = utils.find_resource(identity_client.users,
parsed_args.name, parsed_args.name,
domain_id=domain_id) domain_id=domain_id)
self.log.info('Returning existing user %s', user.name) self.log.info(_('Returning existing user %s'), user.name)
else: else:
raise e raise e
@ -139,12 +139,12 @@ class DeleteUser(command.Command):
'users', 'users',
metavar='<user>', metavar='<user>',
nargs="+", nargs="+",
help='User(s) to delete (name or ID)', help=_('User(s) to delete (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Domain owning <user> (name or ID)', help=_('Domain owning <user> (name or ID)'),
) )
return parser return parser
@ -173,24 +173,24 @@ class ListUser(command.Lister):
parser.add_argument( parser.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Filter users by <domain> (name or ID)', help=_('Filter users by <domain> (name or ID)'),
) )
project_or_group = parser.add_mutually_exclusive_group() project_or_group = parser.add_mutually_exclusive_group()
project_or_group.add_argument( project_or_group.add_argument(
'--group', '--group',
metavar='<group>', metavar='<group>',
help='Filter users by <group> membership (name or ID)', help=_('Filter users by <group> membership (name or ID)'),
) )
project_or_group.add_argument( project_or_group.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
help='Filter users by <project> (name or ID)', help=_('Filter users by <project> (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--long', '--long',
action='store_true', action='store_true',
default=False, default=False,
help='List additional fields in output', help=_('List additional fields in output'),
) )
return parser return parser
@ -273,50 +273,50 @@ class SetUser(command.Command):
parser.add_argument( parser.add_argument(
'user', 'user',
metavar='<user>', metavar='<user>',
help='User to change (name or ID)', help=_('User to change (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<name>', metavar='<name>',
help='Set user name', help=_('Set user name'),
) )
parser.add_argument( parser.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
help='Set default project (name or ID)', help=_('Set default project (name or ID)'),
) )
common.add_project_domain_option_to_parser(parser) common.add_project_domain_option_to_parser(parser)
parser.add_argument( parser.add_argument(
'--password', '--password',
metavar='<password>', metavar='<password>',
help='Set user password', help=_('Set user password'),
) )
parser.add_argument( parser.add_argument(
'--password-prompt', '--password-prompt',
dest="password_prompt", dest="password_prompt",
action="store_true", action="store_true",
help='Prompt interactively for password', help=_('Prompt interactively for password'),
) )
parser.add_argument( parser.add_argument(
'--email', '--email',
metavar='<email-address>', metavar='<email-address>',
help='Set user email address', help=_('Set user email address'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='Set user description', help=_('Set user description'),
) )
enable_group = parser.add_mutually_exclusive_group() enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument( enable_group.add_argument(
'--enable', '--enable',
action='store_true', action='store_true',
help='Enable user (default)', help=_('Enable user (default)'),
) )
enable_group.add_argument( enable_group.add_argument(
'--disable', '--disable',
action='store_true', action='store_true',
help='Disable user', help=_('Disable user'),
) )
return parser return parser
@ -334,9 +334,8 @@ class SetUser(command.Command):
and not parsed_args.description and not parsed_args.description
and not parsed_args.enable and not parsed_args.enable
and not parsed_args.disable): and not parsed_args.disable):
sys.stderr.write("Incorrect set of arguments " sys.stderr.write(_("Incorrect set of arguments provided. "
"provided. See openstack --help for more " "See openstack --help for more details\n"))
"details\n")
return return
user = utils.find_resource( user = utils.find_resource(
@ -376,12 +375,12 @@ class SetPasswordUser(command.Command):
parser.add_argument( parser.add_argument(
'--password', '--password',
metavar='<new-password>', metavar='<new-password>',
help='New user password' help=_('New user password'),
) )
parser.add_argument( parser.add_argument(
'--original-password', '--original-password',
metavar='<original-password>', metavar='<original-password>',
help='Original user password' help=_('Original user password'),
) )
return parser return parser
@ -429,12 +428,12 @@ class ShowUser(command.ShowOne):
parser.add_argument( parser.add_argument(
'user', 'user',
metavar='<user>', metavar='<user>',
help='User to display (name or ID)', help=_('User to display (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--domain', '--domain',
metavar='<domain>', metavar='<domain>',
help='Domain owning <user> (name or ID)', help=_('Domain owning <user> (name or ID)'),
) )
return parser return parser