Blueprint cli-auth: common cli args

Add OS_USERNAME, OS_PASSWORD, OS_TENANT_NAME and OS_TOKEN support
to glance client binary.

Fixes lp923936

Change-Id: I9339b169eadbe198e6ed183cf1aeb42b99f3a7d9
This commit is contained in:
Dean Troyer 2012-02-06 14:40:59 -06:00
parent c6c458e6b6
commit 8df4d1df10
2 changed files with 11 additions and 4 deletions

View File

@ -7,6 +7,7 @@ Chris Behrens <cbehrens@codestud.com>
Christopher MacGown <chris@pistoncloud.com>
Cory Wright <corywright@gmail.com>
Dan Prince <dan.prince@rackspace.com>
Dean Troyer <dtroyer@gmail.com>
Donal Lafferty <donal.lafferty@citrix.com>
Eldar Nugaev <enugaev@griddynamics.com>
Eoghan Glynn <eglynn@redhat.com>

View File

@ -731,9 +731,13 @@ def get_client(options):
specified by the --host and --port options
supplied to the CLI
"""
creds = dict(username=options.username or os.getenv('OS_AUTH_USER'),
password=options.password or os.getenv('OS_AUTH_KEY'),
tenant=options.tenant or os.getenv('OS_AUTH_TENANT'),
creds = dict(username=options.username or \
os.getenv('OS_AUTH_USER', os.getenv('OS_USERNAME')),
password=options.password or \
os.getenv('OS_AUTH_KEY', os.getenv('OS_PASSWORD')),
tenant=options.tenant or \
os.getenv('OS_AUTH_TENANT',
os.getenv('OS_TENANT_NAME')),
auth_url=options.auth_url or os.getenv('OS_AUTH_URL'),
strategy=options.auth_strategy or \
os.getenv('OS_AUTH_STRATEGY', 'noauth'))
@ -743,7 +747,9 @@ def get_client(options):
creds['auth_url'].find('https') != -1))
return glance_client.Client(host=options.host, port=options.port,
use_ssl=use_ssl, auth_tok=options.auth_token,
use_ssl=use_ssl,
auth_tok=options.auth_token or \
os.getenv('OS_TOKEN'),
creds=creds)