Fix auth cred opts for glance-cache-manage
The glance-cache-manage binary now supports the same auth env variables and flags as python-glanceclient. The old flag formats are still supported (but not documented) to support backwards- compatibility. Fixes bug 1038112 Change-Id: If9f15d030e3167f5c81ea275c0005c854cd94a40
This commit is contained in:
parent
5eb7ac1d2e
commit
743d3b230b
@ -271,6 +271,19 @@ def get_client(options):
|
|||||||
insecure=options.insecure)
|
insecure=options.insecure)
|
||||||
|
|
||||||
|
|
||||||
|
def env(*vars, **kwargs):
|
||||||
|
"""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.
|
||||||
|
"""
|
||||||
|
for v in vars:
|
||||||
|
value = os.environ.get(v, None)
|
||||||
|
if value:
|
||||||
|
return value
|
||||||
|
return kwargs.get('default', '')
|
||||||
|
|
||||||
|
|
||||||
def create_options(parser):
|
def create_options(parser):
|
||||||
"""
|
"""
|
||||||
Sets up the CLI and config-file options that may be
|
Sets up the CLI and config-file options that may be
|
||||||
@ -289,44 +302,76 @@ def create_options(parser):
|
|||||||
type=int, default=9292,
|
type=int, default=9292,
|
||||||
help="Port the Glance API host listens on. "
|
help="Port the Glance API host listens on. "
|
||||||
"Default: %default")
|
"Default: %default")
|
||||||
parser.add_option('-A', '--os_auth_token', '--auth_token',
|
|
||||||
dest="os_auth_token", metavar="TOKEN", default=None,
|
|
||||||
help="Authentication token to use to identify the "
|
|
||||||
"client to the glance server. --auth_token"
|
|
||||||
"is deprecated and will be removed")
|
|
||||||
parser.add_option('-I', '--os_username', dest="os_username",
|
|
||||||
metavar="USER", default=None,
|
|
||||||
help="User name used to acquire an authentication token")
|
|
||||||
parser.add_option('-K', '--os_password', dest="os_password",
|
|
||||||
metavar="PASSWORD", default=None,
|
|
||||||
help="Password used to acquire an authentication token")
|
|
||||||
parser.add_option('-R', '--os_region_name', dest="os_region_name",
|
|
||||||
metavar="REGION", default=None,
|
|
||||||
help="Region name. When using keystone authentication "
|
|
||||||
"version 2.0 or later this identifies the region "
|
|
||||||
"name to use when selecting the service endpoint. A "
|
|
||||||
"region name must be provided if more than one "
|
|
||||||
"region endpoint is available")
|
|
||||||
parser.add_option('-T', '--os_tenant_name', dest="os_tenant_name",
|
|
||||||
metavar="TENANT", default=None,
|
|
||||||
help="Tenant name")
|
|
||||||
parser.add_option('-N', '--os_auth_url', dest="os_auth_url",
|
|
||||||
metavar="AUTH_URL", default=None,
|
|
||||||
help="Authentication URL")
|
|
||||||
parser.add_option('-k', '--insecure', dest="insecure",
|
parser.add_option('-k', '--insecure', dest="insecure",
|
||||||
default=False, action="store_true",
|
default=False, action="store_true",
|
||||||
help="Explicitly allow glance to perform \"insecure\" "
|
help="Explicitly allow glance to perform \"insecure\" "
|
||||||
"SSL (https) requests. The server's certificate will "
|
"SSL (https) requests. The server's certificate will "
|
||||||
"not be verified against any certificate authorities. "
|
"not be verified against any certificate authorities. "
|
||||||
"This option should be used with caution.")
|
"This option should be used with caution.")
|
||||||
parser.add_option('-S', '--os_auth_strategy', dest="os_auth_strategy",
|
|
||||||
metavar="STRATEGY", default=None,
|
|
||||||
help="Authentication strategy (keystone or noauth)")
|
|
||||||
parser.add_option('-f', '--force', dest="force", metavar="FORCE",
|
parser.add_option('-f', '--force', dest="force", metavar="FORCE",
|
||||||
default=False, action="store_true",
|
default=False, action="store_true",
|
||||||
help="Prevent select actions from requesting "
|
help="Prevent select actions from requesting "
|
||||||
"user confirmation")
|
"user confirmation")
|
||||||
|
|
||||||
|
parser.add_option('--os-auth-token',
|
||||||
|
dest = 'os_auth_token',
|
||||||
|
default=env('OS_AUTH_TOKEN'),
|
||||||
|
help='Defaults to env[OS_AUTH_TOKEN]')
|
||||||
|
parser.add_option('-A', '--os_auth_token', '--auth_token',
|
||||||
|
dest = 'os_auth_token',
|
||||||
|
help=optparse.SUPPRESS_HELP)
|
||||||
|
|
||||||
|
parser.add_option('--os-username',
|
||||||
|
dest = 'os_username',
|
||||||
|
default=env('OS_USERNAME'),
|
||||||
|
help='Defaults to env[OS_USERNAME]')
|
||||||
|
parser.add_option('-I', '--os_username',
|
||||||
|
dest='os_username',
|
||||||
|
help=optparse.SUPPRESS_HELP)
|
||||||
|
|
||||||
|
parser.add_option('--os-password',
|
||||||
|
dest='os_password',
|
||||||
|
default=env('OS_PASSWORD'),
|
||||||
|
help='Defaults to env[OS_PASSWORD]')
|
||||||
|
parser.add_option('-K', '--os_password',
|
||||||
|
dest='os_password',
|
||||||
|
help=optparse.SUPPRESS_HELP)
|
||||||
|
|
||||||
|
parser.add_option('--os-region-name',
|
||||||
|
dest='os_region_name',
|
||||||
|
default=env('OS_REGION_NAME'),
|
||||||
|
help='Defaults to env[OS_REGION_NAME]')
|
||||||
|
parser.add_option('-R', '--os_region_name',
|
||||||
|
dest='os_region_name',
|
||||||
|
help=optparse.SUPPRESS_HELP)
|
||||||
|
|
||||||
|
parser.add_option('--os-tenant-id',
|
||||||
|
dest='os_tenant_id',
|
||||||
|
default=env('OS_TENANT_ID'),
|
||||||
|
help='Defaults to env[OS_TENANT_ID]')
|
||||||
|
parser.add_option('--os_tenant_id',
|
||||||
|
dest='os_tenant_id',
|
||||||
|
help=optparse.SUPPRESS_HELP)
|
||||||
|
|
||||||
|
parser.add_option('--os-tenant-name',
|
||||||
|
dest='os_tenant_name',
|
||||||
|
default=env('OS_TENANT_NAME'),
|
||||||
|
help='Defaults to env[OS_TENANT_NAME]')
|
||||||
|
parser.add_option('-T', '--os_tenant_name',
|
||||||
|
dest='os_tenant_name',
|
||||||
|
help=optparse.SUPPRESS_HELP)
|
||||||
|
|
||||||
|
parser.add_option('--os-auth-url',
|
||||||
|
default=env('OS_AUTH_URL'),
|
||||||
|
help='Defaults to env[OS_AUTH_URL]')
|
||||||
|
parser.add_option('-N', '--os_auth_url',
|
||||||
|
dest='os_auth_url',
|
||||||
|
help=optparse.SUPPRESS_HELP)
|
||||||
|
|
||||||
|
parser.add_option('-S', '--os_auth_strategy', dest="os_auth_strategy",
|
||||||
|
metavar="STRATEGY", default=None,
|
||||||
|
help="Authentication strategy (keystone or noauth)")
|
||||||
|
|
||||||
|
|
||||||
def parse_options(parser, cli_args):
|
def parse_options(parser, cli_args):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user