more work on standardization of cliauth
This commit is contained in:
@@ -27,7 +27,7 @@ By way of a quick-start::
|
||||
|
||||
# use v2.0 auth with http://example.com:5000/v2.0")
|
||||
>>> from keystoneclient.v2_0 import client
|
||||
>>> keystone = client.Client(user_name=USERNAME, password=PASSWORD, tenant_name=TENANT, auth_url=KEYSTONE_URL)
|
||||
>>> keystone = client.Client(username=USERNAME, password=PASSWORD, tenant_name=TENANT, auth_url=KEYSTONE_URL)
|
||||
>>> keystone.tenants.list()
|
||||
>>> tenant = keystone.tenants.create(name="test", descrption="My new tenant!", enabled=True)
|
||||
>>> tenant.delete()
|
||||
@@ -49,7 +49,7 @@ with the ``--username``, ``--apikey`` and ``--projectid`` params, but it's
|
||||
easier to just set them as environment variables::
|
||||
|
||||
export OS_TENANT_NAME=project
|
||||
export OS_USER_NAME=user
|
||||
export OS_USERNAME=user
|
||||
export OS_PASSWORD=pass
|
||||
|
||||
You will also need to define the authentication url with ``--url`` and the
|
||||
@@ -66,7 +66,7 @@ can specify the one you want with ``--region_name`` (or
|
||||
You'll find complete documentation on the shell by running
|
||||
``keystone help``::
|
||||
|
||||
usage: keystone [--user_name user] [--password password]
|
||||
usage: keystone [--username user] [--password password]
|
||||
[--tenant_name tenant] [--auth_url URL]
|
||||
<subcommand> ...
|
||||
|
||||
@@ -78,8 +78,7 @@ You'll find complete documentation on the shell by running
|
||||
|
||||
|
||||
Optional arguments:
|
||||
--user_name USER Defaults to env[OS_USER_NAME].
|
||||
--user_id USERID Defaults to env[OS_USER_ID].
|
||||
--username USER Defaults to env[OS_USERNAME].
|
||||
--password PASSWORD Defaults to env[OS_PASSWORD].
|
||||
--tenant_name TENANT Defaults to env[OS_TENANT_NAME].
|
||||
--tenant_id TENANTID Defaults to env[OS_TENANT_].
|
||||
|
@@ -38,11 +38,11 @@ class HTTPClient(httplib2.Http):
|
||||
|
||||
USER_AGENT = 'python-keystoneclient'
|
||||
|
||||
def __init__(self, user_name=None, tenant_id=None, tenant_name=None,
|
||||
def __init__(self, username=None, tenant_id=None, tenant_name=None,
|
||||
password=None, project_id=None, auth_url=None,
|
||||
region_name=None, timeout=None, endpoint=None, token=None):
|
||||
super(HTTPClient, self).__init__(timeout=timeout)
|
||||
self.user_name = user_name
|
||||
self.username = username
|
||||
self.tenant_id = tenant_id
|
||||
self.tenant_name = tenant_name
|
||||
self.password = password
|
||||
|
@@ -55,9 +55,9 @@ class OpenStackIdentityShell(object):
|
||||
action='store_true',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
parser.add_argument('--user_name',
|
||||
default=env('OS_USER_NAME'),
|
||||
help='Defaults to env[OS_USER_NAME].')
|
||||
parser.add_argument('--username',
|
||||
default=env('OS_USERNAME'),
|
||||
help='Defaults to env[OS_USERNAME].')
|
||||
|
||||
parser.add_argument('--password',
|
||||
default=env('OS_PASSWORD'),
|
||||
@@ -151,9 +151,9 @@ class OpenStackIdentityShell(object):
|
||||
#FIXME(usrleon): Here should be restrict for project id same as
|
||||
# for username or apikey but for compatibility it is not.
|
||||
|
||||
if not args.user_name:
|
||||
raise exc.CommandError("You must provide a user name:"
|
||||
"via --user_name or env[OS_USER_NAME]")
|
||||
if not args.username:
|
||||
raise exc.CommandError("You must provide a username:"
|
||||
"via --username or env[OS_USERNAME]")
|
||||
if not args.password:
|
||||
raise exc.CommandError("You must provide a password, either"
|
||||
"via --password or env[OS_PASSWORD]")
|
||||
@@ -163,7 +163,7 @@ class OpenStackIdentityShell(object):
|
||||
"via --auth_url or via"
|
||||
"env[OS_AUTH_URL")
|
||||
|
||||
self.cs = self.get_api_class(options.version)(user_name=args.user_name,
|
||||
self.cs = self.get_api_class(options.version)(username=args.username,
|
||||
tenant_name=args.tenant_name,
|
||||
tenant_id=args.tenant_id,
|
||||
password=args.password,
|
||||
|
@@ -86,7 +86,7 @@ class Client(client.HTTPClient):
|
||||
"""
|
||||
self.management_url = self.auth_url
|
||||
# try:
|
||||
raw_token = self.tokens.authenticate(user_name=self.user_name,
|
||||
raw_token = self.tokens.authenticate(username=self.username,
|
||||
tenant_id=self.tenant_id,
|
||||
tenant_name=self.tenant_name,
|
||||
password=self.password,
|
||||
|
@@ -21,12 +21,12 @@ class Token(base.Resource):
|
||||
class TokenManager(base.ManagerWithFind):
|
||||
resource_class = Token
|
||||
|
||||
def authenticate(self, user_name=None, tenant_id=None, tenant_name=None,
|
||||
def authenticate(self, username=None, tenant_id=None, tenant_name=None,
|
||||
password=None, token=None, return_raw=False):
|
||||
if token and token != password:
|
||||
params = {"auth": {"token": {"id": token}}}
|
||||
elif user_name and password:
|
||||
params = {"auth": {"passwordCredentials": {"username": user_name,
|
||||
elif username and password:
|
||||
params = {"auth": {"passwordCredentials": {"username": username,
|
||||
"password": password}}}
|
||||
else:
|
||||
raise ValueError('A username and password or token is required.')
|
||||
|
Reference in New Issue
Block a user