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, auth_url=opts.os_auth_url,
version=opts.os_identity_api_version, version=opts.os_identity_api_version,
project_name=opts.os_project_name, 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' help='Project name of the requested project-level'
'authorization scope (Env: OS_PROJECT_NAME)', '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( parser.add_argument(
'--os-username', '--os-username',
metavar='<auth-username>', metavar='<auth-username>',

View File

@ -35,6 +35,9 @@ def make_session(opts):
auth_url=opts.os_auth_url, auth_url=opts.os_auth_url,
version=opts.os_identity_api_version, version=opts.os_identity_api_version,
project_name=opts.os_project_name, 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, cacert=opts.os_cacert,
insecure=opts.insecure, insecure=opts.insecure,
user_agent='SDKExample', user_agent='SDKExample',

View File

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

View File

@ -41,7 +41,8 @@ class Session(object):
@classmethod @classmethod
def create(cls, username=None, password=None, token=None, auth_url=None, def create(cls, username=None, password=None, token=None, auth_url=None,
version=None, project_name=None, cacert=None, insecure=False, 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( xport = transport.Transport.create(
cacert=cacert, cacert=cacert,
insecure=insecure, insecure=insecure,
@ -52,7 +53,10 @@ class Session(object):
'password': password, 'password': password,
'token': token, 'token': token,
'auth_url': auth_url, '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: if version:
args['version'] = version args['version'] = version

View File

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