From 8379ad612e543fcc345bb6f57bb4f93009d3e7c4 Mon Sep 17 00:00:00 2001 From: TerryHowe Date: Sat, 21 Feb 2015 07:07:33 -0700 Subject: [PATCH] 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 --- README.rst | 2 +- doc/source/code/connection.py | 2 +- doc/source/users/userguides/usage.rst | 2 +- examples/common.py | 2 +- examples/connection.py | 2 +- examples/object_store.py | 2 +- openstack/auth/identity/discoverable.py | 4 +-- openstack/auth/identity/v2.py | 28 +++++++++---------- openstack/auth/identity/v3.py | 12 ++++---- openstack/connection.py | 2 +- .../tests/auth/identity/test_discoverable.py | 10 +++---- openstack/tests/auth/identity/test_v2.py | 4 +-- openstack/tests/auth/identity/test_v3.py | 10 +++---- openstack/tests/test_connection.py | 14 +++++----- 14 files changed, 48 insertions(+), 48 deletions(-) diff --git a/README.rst b/README.rst index 297c64451..a4eb54c0a 100644 --- a/README.rst +++ b/README.rst @@ -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) diff --git a/doc/source/code/connection.py b/doc/source/code/connection.py index e4d6f4dd0..f57c1a945 100644 --- a/doc/source/code/connection.py +++ b/doc/source/code/connection.py @@ -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") diff --git a/doc/source/users/userguides/usage.rst b/doc/source/users/userguides/usage.rst index 38d991269..11a14261f 100644 --- a/doc/source/users/userguides/usage.rst +++ b/doc/source/users/userguides/usage.rst @@ -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', } diff --git a/examples/common.py b/examples/common.py index 68bcdceda..ed61b7a5d 100755 --- a/examples/common.py +++ b/examples/common.py @@ -213,7 +213,7 @@ def option_parser(): ) parser.add_argument( '--os-username', - dest='user_name', + dest='username', metavar='', default=env('OS_USERNAME'), help='Authentication username (Env: OS_USERNAME)', diff --git a/examples/connection.py b/examples/connection.py index 88a0199f8..36d019a23 100644 --- a/examples/connection.py +++ b/examples/connection.py @@ -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, diff --git a/examples/object_store.py b/examples/object_store.py index d46fb81f6..5404c28e3 100644 --- a/examples/object_store.py +++ b/examples/object_store.py @@ -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, diff --git a/openstack/auth/identity/discoverable.py b/openstack/auth/identity/discoverable.py index 21b4cc7b8..b087f96c2 100644 --- a/openstack/auth/identity/discoverable.py +++ b/openstack/auth/identity/discoverable.py @@ -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) diff --git a/openstack/auth/identity/v2.py b/openstack/auth/identity/v2.py index bf99f59ce..e49ba1725 100644 --- a/openstack/auth/identity/v2.py +++ b/openstack/auth/identity/v2.py @@ -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 diff --git a/openstack/auth/identity/v3.py b/openstack/auth/identity/v3.py index 0c48f1669..4b5a5643e 100644 --- a/openstack/auth/identity/v3.py +++ b/openstack/auth/identity/v3.py @@ -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 diff --git a/openstack/connection.py b/openstack/connection.py index 97e8e7c4a..01ab15c15 100644 --- a/openstack/connection.py +++ b/openstack/connection.py @@ -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) diff --git a/openstack/tests/auth/identity/test_discoverable.py b/openstack/tests/auth/identity/test_discoverable.py index c4f6fe68c..5e3a0b8f8 100644 --- a/openstack/tests/auth/identity/test_discoverable.py +++ b/openstack/tests/auth/identity/test_discoverable.py @@ -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) diff --git a/openstack/tests/auth/identity/test_v2.py b/openstack/tests/auth/identity/test_v2.py index 75346ade6..dda7574b3 100644 --- a/openstack/tests/auth/identity/test_v2.py +++ b/openstack/tests/auth/identity/test_v2.py @@ -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) diff --git a/openstack/tests/auth/identity/test_v3.py b/openstack/tests/auth/identity/test_v3.py index ee29f5f6a..28eebfb8e 100644 --- a/openstack/tests/auth/identity/test_v3.py +++ b/openstack/tests/auth/identity/test_v3.py @@ -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) diff --git a/openstack/tests/test_connection.py b/openstack/tests/test_connection.py index 0bcd26fe9..e87bb282b 100644 --- a/openstack/tests/test_connection.py +++ b/openstack/tests/test_connection.py @@ -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)