Convert user_name to username

This will greatly reduce the number of ksc to sdk differences.
Why fight it, everyone is used to username anyway.

Change-Id: Ie6e897c1baa3184af77510b98790196e8f069f5a
This commit is contained in:
TerryHowe 2015-02-21 07:07:33 -07:00 committed by Brian Curtin
parent 00eed94106
commit 8379ad612e
14 changed files with 48 additions and 48 deletions

View File

@ -19,7 +19,7 @@ the containers in the Object Store service.::
from openstack import connection
conn = connection.Connection(auth_url="http://openstack:5000/v3",
project_name="big_project",
user_name="SDK_user",
username"SDK_user",
password="Super5ecretPassw0rd")
for container in conn.object_store.containers():
print(container.name)

View File

@ -1,6 +1,6 @@
from openstack import connection
conn = connection.Connection(auth_url="http://openstack:5000/v3",
project_name="big_project",
user_name="SDK_user",
username="SDK_user",
password="Super5ecretPassw0rd")

View File

@ -18,7 +18,7 @@ To use python-openstacksdk in a project::
auth_args = {
'auth_url': 'http://172.20.1.108:5000/v3',
'project_name': 'hacker',
'user_name': 'neo',
'username': 'neo',
'password': 'bluepill',
}

View File

@ -213,7 +213,7 @@ def option_parser():
)
parser.add_argument(
'--os-username',
dest='user_name',
dest='username',
metavar='<auth-username>',
default=env('OS_USERNAME'),
help='Authentication username (Env: OS_USERNAME)',

View File

@ -33,7 +33,7 @@ def make_connection(opts):
'domain_name': opts.domain_name,
'project_domain_name': opts.project_domain_name,
'user_domain_name': opts.user_domain_name,
'user_name': opts.user_name,
'username': opts.username,
'password': opts.password,
'verify': opts.verify,
'token': opts.token,

View File

@ -81,7 +81,7 @@ def main():
'domain_name': opts.domain_name,
'project_domain_name': opts.project_domain_name,
'user_domain_name': opts.user_domain_name,
'user_name': opts.user_name,
'username': opts.username,
'password': opts.password,
'verify': opts.verify,
'token': opts.token,

View File

@ -23,7 +23,7 @@ example::
args = {
'password': 'openSesame',
'auth_url': 'https://10.1.1.1:5000/v3/',
'user_name': 'alibaba',
'username': 'alibaba',
}
auth = discoverable.Auth(**args)
xport = transport.Transport()
@ -52,7 +52,7 @@ class Auth(base.BaseIdentityPlugin):
:param string auth_url: Identity service endpoint for authentication.
:raises TypeError: if a user_id, user_name or token is not provided.
:raises TypeError: if a user_id, username or token is not provided.
"""
super(Auth, self).__init__(auth_url=auth_url)

View File

@ -21,7 +21,7 @@ would also require a password. For example::
args = {
'password': 'openSesame',
'auth_url': 'https://10.1.1.1:5000/v2.0/',
'user_name': 'alibaba',
'username': 'alibaba',
}
auth = v2.Auth(**args)
xport = transport.Transport()
@ -115,7 +115,7 @@ class Password(Auth):
valid_options = [
'access_info',
'auth_url',
'user_name',
'username',
'user_id',
'password',
'project_id',
@ -124,38 +124,38 @@ class Password(Auth):
'trust_id',
]
def __init__(self, auth_url, user_name=_NOT_PASSED, password=None,
def __init__(self, auth_url, username=_NOT_PASSED, password=None,
user_id=_NOT_PASSED, **kwargs):
"""A plugin for authenticating with a user_name and password.
"""A plugin for authenticating with a username and password.
A user_name or user_id must be provided.
A username or user_id must be provided.
:param string auth_url: Identity service endpoint for authorization.
:param string user_name: Username for authentication.
:param string username: Username for authentication.
:param string password: Password for authentication.
:param string user_id: User ID for authentication.
:raises TypeError: if a user_id or user_name is not provided.
:raises TypeError: if a user_id or username is not provided.
"""
super(Password, self).__init__(auth_url, **kwargs)
if user_name is _NOT_PASSED and user_id is _NOT_PASSED:
msg = 'You need to specify either a user_name or user_id'
if username is _NOT_PASSED and user_id is _NOT_PASSED:
msg = 'You need to specify either a username or user_id'
raise TypeError(msg)
if user_name is _NOT_PASSED:
user_name = None
if username is _NOT_PASSED:
username = None
if user_id is _NOT_PASSED:
user_id = None
self.user_id = user_id
self.user_name = user_name
self.username = username
self.password = password
def get_auth_data(self, headers=None):
auth = {'password': self.password}
if self.user_name:
auth['username'] = self.user_name
if self.username:
auth['username'] = self.username
elif self.user_id:
auth['userId'] = self.user_id

View File

@ -21,7 +21,7 @@ would also require a password. For example::
args = {
'password': 'openSesame',
'auth_url': 'https://10.1.1.1:5000/v3/',
'user_name': 'alibaba',
'username': 'alibaba',
}
auth = v3.Auth(**args)
xport = transport.Transport()
@ -214,7 +214,7 @@ class AuthConstructor(Auth):
class PasswordMethod(AuthMethod):
_method_parameters = ['user_id',
'user_name',
'username',
'user_domain_id',
'user_domain_name',
'password']
@ -223,7 +223,7 @@ class PasswordMethod(AuthMethod):
"""Construct a User/Password based authentication method.
:param string password: Password for authentication.
:param string user_name: Username for authentication.
:param string username: Username for authentication.
:param string user_id: User ID for authentication.
:param string user_domain_id: User's domain ID for authentication.
:param string user_domain_name: User's domain name for authentication.
@ -236,8 +236,8 @@ class PasswordMethod(AuthMethod):
if self.user_id:
user['id'] = self.user_id
elif self.user_name:
user['name'] = self.user_name
elif self.username:
user['name'] = self.username
if self.user_domain_id:
user['domain'] = {'id': self.user_domain_id}
@ -265,7 +265,7 @@ class Password(AuthConstructor):
'user_domain_id',
'user_domain_name',
'user_id',
'user_name',
'username',
]
_auth_method_class = PasswordMethod

View File

@ -34,7 +34,7 @@ by this connection.::
auth_args = {
'auth_url': 'http://172.20.1.108:5000/v3',
'project_name': 'admin',
'user_name': 'admin',
'username': 'admin',
'password': 'admin',
}
conn = connection.Connection(**auth_args)

View File

@ -36,14 +36,14 @@ class TestDiscoverableAuth(testtools.TestCase):
'user_domain_id',
'user_domain_name',
'user_id',
'user_name',
'username',
]
self.assertEqual(expected, sorted(discoverable.Auth.valid_options))
def test_create2(self):
auth_args = {
'auth_url': 'http://localhost/v2',
'user_name': '1',
'username': '1',
'password': '2',
}
auth = discoverable.Auth(**auth_args)
@ -53,7 +53,7 @@ class TestDiscoverableAuth(testtools.TestCase):
def test_create3(self):
auth_args = {
'auth_url': 'http://localhost/v3',
'user_name': '1',
'username': '1',
'password': '2',
}
auth = discoverable.Auth(**auth_args)
@ -63,7 +63,7 @@ class TestDiscoverableAuth(testtools.TestCase):
def test_create_who_knows(self):
auth_args = {
'auth_url': 'http://localhost:5000/',
'user_name': '1',
'username': '1',
'password': '2',
}
auth = discoverable.Auth(**auth_args)
@ -79,7 +79,7 @@ class TestDiscoverableAuth(testtools.TestCase):
def test_methods(self):
auth_args = {
'auth_url': 'http://localhost:5000/',
'user_name': '1',
'username': '1',
'password': '2',
}
auth = discoverable.Auth(**auth_args)

View File

@ -32,7 +32,7 @@ class TestV2Auth(testtools.TestCase):
sot = v2.Password(TEST_URL, common.TEST_USER, common.TEST_PASS,
**kargs)
self.assertEqual(common.TEST_USER, sot.user_name)
self.assertEqual(common.TEST_USER, sot.username)
self.assertEqual(common.TEST_PASS, sot.password)
self.assertEqual(common.TEST_TRUST_ID, sot.trust_id)
self.assertEqual(common.TEST_TENANT_ID, sot.tenant_id)
@ -49,7 +49,7 @@ class TestV2Auth(testtools.TestCase):
sot = v2.Password(TEST_URL, None, common.TEST_PASS,
**kargs)
self.assertEqual(None, sot.user_name)
self.assertEqual(None, sot.username)
self.assertEqual(common.TEST_PASS, sot.password)
self.assertEqual(common.TEST_TRUST_ID, sot.trust_id)
self.assertEqual(common.TEST_TENANT_ID, sot.tenant_id)

View File

@ -26,7 +26,7 @@ class TestV3Auth(testtools.TestCase):
'project_id': common.TEST_PROJECT_ID,
'project_name': common.TEST_PROJECT_NAME}
method = v3.PasswordMethod(user_name=common.TEST_USER,
method = v3.PasswordMethod(username=common.TEST_USER,
user_id=common.TEST_USER_ID,
user_domain_id=common.TEST_DOMAIN_ID,
user_domain_name=common.TEST_DOMAIN_NAME,
@ -36,7 +36,7 @@ class TestV3Auth(testtools.TestCase):
self.assertEqual(1, len(sot.auth_methods))
auther = sot.auth_methods[0]
self.assertEqual(common.TEST_USER_ID, auther.user_id)
self.assertEqual(common.TEST_USER, auther.user_name)
self.assertEqual(common.TEST_USER, auther.username)
self.assertEqual(common.TEST_DOMAIN_ID, auther.user_domain_id)
self.assertEqual(common.TEST_DOMAIN_NAME, auther.user_domain_name)
self.assertEqual(common.TEST_PASS, auther.password)
@ -60,7 +60,7 @@ class TestV3Auth(testtools.TestCase):
'project_id': common.TEST_PROJECT_ID,
'project_name': common.TEST_PROJECT_NAME}
methods = [v3.PasswordMethod(user_name=common.TEST_USER,
methods = [v3.PasswordMethod(username=common.TEST_USER,
user_id=common.TEST_USER_ID,
password=common.TEST_PASS)]
sot = v3.Auth(TEST_URL, methods, **kargs)
@ -68,7 +68,7 @@ class TestV3Auth(testtools.TestCase):
self.assertEqual(1, len(sot.auth_methods))
auther = sot.auth_methods[0]
self.assertEqual(common.TEST_USER_ID, auther.user_id)
self.assertEqual(common.TEST_USER, auther.user_name)
self.assertEqual(common.TEST_USER, auther.username)
self.assertEqual(None, auther.user_domain_id)
self.assertEqual(None, auther.user_domain_name)
self.assertEqual(common.TEST_PASS, auther.password)
@ -288,7 +288,7 @@ class TestV3Auth(testtools.TestCase):
self.assertEqual(ecatalog, resp._info)
def test_authorize_multi_method(self):
methods = [v3.PasswordMethod(user_name=common.TEST_USER,
methods = [v3.PasswordMethod(username=common.TEST_USER,
password=common.TEST_PASS),
v3.TokenMethod(token=common.TEST_TOKEN)]
sot = v3.Auth(TEST_URL, methods)

View File

@ -41,33 +41,33 @@ class TestConnection(base.TestCase):
def test_create_authenticator_v2(self):
auth_args = {
'auth_url': '0',
'user_name': '1',
'username': '1',
'password': '2',
}
conn = connection.Connection(transport='0',
auth_plugin='identity_v2_password',
**auth_args)
self.assertEqual('0', conn.authenticator.auth_url)
self.assertEqual('1', conn.authenticator.user_name)
self.assertEqual('1', conn.authenticator.username)
self.assertEqual('2', conn.authenticator.password)
def test_create_authenticator_v3(self):
auth_args = {
'auth_url': '0',
'user_name': '1',
'username': '1',
'password': '2',
}
conn = connection.Connection(transport='0',
auth_plugin='identity_v3_password',
**auth_args)
self.assertEqual('0', conn.authenticator.auth_url)
self.assertEqual('1', conn.authenticator.auth_methods[0].user_name)
self.assertEqual('1', conn.authenticator.auth_methods[0].username)
self.assertEqual('2', conn.authenticator.auth_methods[0].password)
def test_create_authenticator_discoverable(self):
auth_args = {
'auth_url': '0',
'user_name': '1',
'username': '1',
'password': '2',
}
conn = connection.Connection(transport='0', auth_plugin='identity',
@ -75,7 +75,7 @@ class TestConnection(base.TestCase):
self.assertEqual('0', conn.authenticator.auth_url)
self.assertEqual(
'1',
conn.authenticator.auth_plugin.auth_methods[0].user_name)
conn.authenticator.auth_plugin.auth_methods[0].username)
self.assertEqual(
'2',
conn.authenticator.auth_plugin.auth_methods[0].password)
@ -83,7 +83,7 @@ class TestConnection(base.TestCase):
def test_create_authenticator_no_name(self):
auth_args = {
'auth_url': 'http://localhost/v2',
'user_name': '1',
'username': '1',
'password': '2',
}
conn = connection.Connection(transport='0', **auth_args)