Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# Copyright 2010 Jacob Kaplan-Moss # Copyright 2011 OpenStack LLC. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License.
Command-line interface to the OpenStack Identity API. """
return None
"""Search for the first defined of possibly many env vars
Returns the first environment variable defined in vars, or returns the default defined in kwargs.
"""
prog='keystone', description=__doc__.strip(), epilog='See "keystone help COMMAND" ' 'for help on a specific command.', add_help=False, formatter_class=OpenStackHelpFormatter, )
# Global arguments '--help', action='store_true', help=argparse.SUPPRESS)
action='version', version=keystoneclient.__version__, help="Shows the client version and exits")
default=False, action='store_true', help=argparse.SUPPRESS)
default=600, type=positive_non_zero_float, metavar='<seconds>', help="Set request timeout (in seconds)")
metavar='<auth-user-name>', default=env('OS_USERNAME'), help='Name used for authentication with the ' 'OpenStack Identity service. ' 'Defaults to env[OS_USERNAME]') help=argparse.SUPPRESS)
metavar='<auth-password>', default=env('OS_PASSWORD'), help='Password used for authentication with the ' 'OpenStack Identity service. ' 'Defaults to env[OS_PASSWORD]') help=argparse.SUPPRESS)
metavar='<auth-tenant-name>', default=env('OS_TENANT_NAME'), help='Tenant to request authorization on. ' 'Defaults to env[OS_TENANT_NAME]') help=argparse.SUPPRESS)
metavar='<tenant-id>', default=env('OS_TENANT_ID'), help='Tenant to request authorization on. ' 'Defaults to env[OS_TENANT_ID]') help=argparse.SUPPRESS)
metavar='<auth-url>', default=env('OS_AUTH_URL'), help='Specify the Identity endpoint to use for ' 'authentication. ' 'Defaults to env[OS_AUTH_URL]') help=argparse.SUPPRESS)
metavar='<region-name>', default=env('OS_REGION_NAME'), help='Defaults to env[OS_REGION_NAME]') help=argparse.SUPPRESS)
metavar='<identity-api-version>', default=env('OS_IDENTITY_API_VERSION', 'KEYSTONE_VERSION'), help='Defaults to env[OS_IDENTITY_API_VERSION]' ' or 2.0') help=argparse.SUPPRESS)
metavar='<service-token>', default=env('OS_SERVICE_TOKEN'), help='Specify an existing token to use instead of ' 'retrieving one via authentication (e.g. ' 'with username & password). ' 'Defaults to env[OS_SERVICE_TOKEN]')
metavar='<service-endpoint>', default=env('OS_SERVICE_ENDPOINT'), help='Specify an endpoint to use instead of ' 'retrieving one from the service catalog ' '(via authentication). ' 'Defaults to env[OS_SERVICE_ENDPOINT]')
metavar='<ca-certificate>', default=env('OS_CACERT', default=None), help='Specify a CA bundle file to use in ' 'verifying a TLS (https) server certificate. ' 'Defaults to env[OS_CACERT]') help=argparse.SUPPRESS)
default=False, action="store_true", help='Explicitly allow keystoneclient to perform ' '"insecure" TLS (https) requests. The ' 'server\'s certificate will not be verified ' 'against any certificate authorities. This ' 'option should be used with caution.')
metavar='<certificate>', default=env('OS_CERT'), help='Defaults to env[OS_CERT]') help=argparse.SUPPRESS)
metavar='<key>', default=env('OS_KEY'), help='Defaults to env[OS_KEY]') help=argparse.SUPPRESS)
default=env('OS_CACHE', default=False), action='store_true', help='Use the auth token cache. ' 'Defaults to env[OS_CACHE]') help=argparse.SUPPRESS)
default=False, action="store_true", dest='force_new_token', help="If the keyring is available and in use, " "token will always be stored and fetched " "from the keyring until the token has " "expired. Use this option to request a " "new token and replace the existing one " "in the keyring.")
metavar='<seconds>', default=access.STALE_TOKEN_DURATION, dest='stale_duration', help="Stale duration (in seconds) used to " "determine whether a token has expired " "when retrieving it from keyring. This " "is useful in mitigating process or " "network delays. Default is %s seconds." % ( access.STALE_TOKEN_DURATION))
#FIXME(heckj): # deprecated command line options for essex compatibility. To be # removed in Grizzly release cycle. metavar='<service-token>', dest='os_token', default=env('SERVICE_TOKEN'), help=argparse.SUPPRESS) dest='os_endpoint', metavar='<service-endpoint>', default=env('SERVICE_ENDPOINT'), help=argparse.SUPPRESS)
'2.0': shell_v2_0, }[version]
'bash_completion', add_help=False, formatter_class=OpenStackHelpFormatter )
# I prefer to be hypen-separated instead of underscores.
command, help=help, description=desc, add_help=False, formatter_class=OpenStackHelpFormatter) help=argparse.SUPPRESS)
# Parse args once to find version
# build available subcommands based on version
# Handle top-level --help/-h before attempting to parse # a command off the command line
# Parse args again and call whatever callback was selected
# Short-circuit and deal with help command right away.
# TODO(heckj): supporting backwards compatibility with environment # variables. To be removed after DEVSTACK is updated, ideally in # the Grizzly release cycle.
# if the user hasn't provided any auth data args.os_password or args.os_auth_url): '\n either a service token, ' '--os-token or env[OS_SERVICE_TOKEN], ' '\n or credentials, ' '--os-username or env[OS_USERNAME].')
# user supplied a token and endpoint and at least one other cred args.os_tenant_id or args.os_tenant_name or args.os_password or args.os_auth_url): 'endpoint (authentication credentials are being ' 'ignored).')
# if it looks like the user wants to provide a credentials # but is missing something and ((args.os_username or args.os_password or args.os_auth_url) and not (args.os_username and args.os_password and args.os_auth_url))): 'Expecting a username provided via either ' '--os-username or env[OS_USERNAME]')
'Expecting an auth URL via either --os-auth-url or ' 'env[OS_AUTH_URL]')
if not args.os_password: # No password, If we've got a tty, try prompting for it if hasattr(sys.stdin, 'isatty') and sys.stdin.isatty(): # Check for Ctl-D try: args.os_password = getpass.getpass('OS Password: ') except EOFError: pass # No password because we did't have a tty or the # user Ctl-D when prompted? if not args.os_password: raise exc.CommandError( 'Expecting a password provided via either ' '--os-password, env[OS_PASSWORD], or ' 'prompted response')
# if it looks like the user wants to provide a service token # but is missing something args.os_token and args.os_endpoint): 'Expecting a token provided via either --os-token or ' 'env[OS_SERVICE_TOKEN]')
'Expecting an endpoint provided via either ' '--os-endpoint or env[OS_SERVICE_ENDPOINT]')
cacert=args.os_cacert, key=args.os_key, cert=args.os_cert, insecure=args.insecure, debug=args.debug, timeout=args.timeout) else: username=args.os_username, tenant_name=args.os_tenant_name, tenant_id=args.os_tenant_id, token=token, endpoint=args.os_endpoint, password=args.os_password, auth_url=args.os_auth_url, region_name=args.os_region_name, cacert=args.os_cacert, key=args.os_key, cert=args.os_cert, insecure=args.insecure, debug=args.debug, use_keyring=args.os_cache, force_new_token=args.force_new_token, stale_duration=args.stale_duration, timeout=args.timeout)
except exc.Unauthorized: raise exc.CommandError("Invalid OpenStack Identity credentials.") except exc.AuthorizationFailure: raise exc.CommandError("Unable to authorize user")
"2.0": shell_v2_0.CLIENT_CLASS, }[version]
""" Prints all of the commands and options to stdout. The keystone.bash_completion script doesn't have to hard code them. """
help='Display help for <subcommand>') def do_help(self, args): """ Display help about this program or one of its subcommands. """ else: args.command) else:
# I'm picky about my shell help. # Title-case the headings
try: OpenStackIdentityShell().main(sys.argv[1:])
except Exception as e: print >> sys.stderr, e sys.exit(1)
sys.exit(main()) |