Merge "Add domains for v3 authentication"

This commit is contained in:
Jenkins 2014-08-29 20:58:23 +00:00 committed by Gerrit Code Review
commit 8ba7650d02
6 changed files with 50 additions and 3 deletions

View File

@ -54,6 +54,9 @@ def make_authenticate(opts):
auth_url=opts.os_auth_url,
version=opts.os_identity_api_version,
project_name=opts.os_project_name,
domain_name=opts.os_domain_name,
project_domain_name=opts.os_project_domain_name,
user_domain_name=opts.os_user_domain_name,
)

View File

@ -129,6 +129,27 @@ def option_parser():
help='Project name of the requested project-level'
'authorization scope (Env: OS_PROJECT_NAME)',
)
parser.add_argument(
'--os-domain-name',
metavar='<auth-domain-name>',
default=env('OS_DOMAIN_NAME'),
help='Domain name for scope of '
'authorization (Env: OS_DOMAIN_NAME)',
)
parser.add_argument(
'--os-project-domain-name',
metavar='<auth-project-domain-name>',
default=env('OS_PROJECT_DOMAIN_NAME'),
help='Project domain name for scope of '
'authorization (Env: OS_PROJECT_DOMAIN_NAME)',
)
parser.add_argument(
'--os-user-domain-name',
metavar='<auth-user-domain-name>',
default=env('OS_USER_DOMAIN_NAME'),
help='User domain name for scope of '
'authorization (Env: OS_USER_DOMAIN_NAME)',
)
parser.add_argument(
'--os-username',
metavar='<auth-username>',

View File

@ -35,6 +35,9 @@ def make_session(opts):
auth_url=opts.os_auth_url,
version=opts.os_identity_api_version,
project_name=opts.os_project_name,
domain_name=opts.os_domain_name,
project_domain_name=opts.os_project_domain_name,
user_domain_name=opts.os_user_domain_name,
cacert=opts.os_cacert,
insecure=opts.insecure,
user_agent='SDKExample',

View File

@ -16,7 +16,8 @@ from openstack import exceptions
def create(username=None, password=None, token=None, auth_url=None,
version='3', project_name=None):
version='3', project_name=None, domain_name=None,
project_domain_name=None, user_domain_name=None):
"""Temporary code for creating an authenticator
This is temporary code to create an authenticator. This code will be
@ -28,6 +29,9 @@ def create(username=None, password=None, token=None, auth_url=None,
:param string auth_url: The URL to use for authentication.
:param string version: Version of authentication to use.
:param string project_name: Project name to athenticate.
:param string domain_name: Domain name to athenticate.
:param string project_domain_name: Project domain name to athenticate.
:param string user_domain_name: User domain name to athenticate.
:returns string: An authenticator.
"""
@ -38,6 +42,12 @@ def create(username=None, password=None, token=None, auth_url=None,
args = {'username': username, 'password': password}
if project_name:
args['project_name'] = project_name
if domain_name:
args['domain_name'] = domain_name
if project_domain_name:
args['project_domain_name'] = project_domain_name
if user_domain_name:
args['user_domain_name'] = user_domain_name
return v3.Password(auth_url, **args)
else:
return v3.Token(auth_url, token=token)

View File

@ -41,7 +41,8 @@ class Session(object):
@classmethod
def create(cls, username=None, password=None, token=None, auth_url=None,
version=None, project_name=None, cacert=None, insecure=False,
user_agent=None, region=None):
user_agent=None, region=None, domain_name=None,
project_domain_name=None, user_domain_name=None):
xport = transport.Transport.create(
cacert=cacert,
insecure=insecure,
@ -52,7 +53,10 @@ class Session(object):
'password': password,
'token': token,
'auth_url': auth_url,
'project_name': project_name
'project_name': project_name,
'domain_name': domain_name,
'project_domain_name': project_domain_name,
'user_domain_name': user_domain_name,
}
if version:
args['version'] = version

View File

@ -24,11 +24,17 @@ class TestAuthenticatorCreate(base.TestCase):
auth_url='4',
version='3',
project_name='6',
domain_name='7',
project_domain_name='8',
user_domain_name='9',
)
self.assertEqual('1', auth.auth_methods[0].username)
self.assertEqual('2', auth.auth_methods[0].password)
self.assertEqual('4', auth.auth_url)
self.assertEqual('6', auth.project_name)
self.assertEqual('7', auth.domain_name)
self.assertEqual('8', auth.project_domain_name)
self.assertEqual('9', auth.auth_methods[0].user_domain_name)
def test_create_3_token(self):
auth = authenticator.create(