You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2016/04/23 09:06:33 UTC
[2/3] libcloud git commit: openstack: Specify default values in
method signature
openstack: Specify default values in method signature
Closes #744
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/efe55b23
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/efe55b23
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/efe55b23
Branch: refs/heads/trunk
Commit: efe55b2369532fd5246e55a46079f6f9fc554d64
Parents: eb497fa
Author: lionel <li...@sixsq.com>
Authored: Fri Apr 15 15:28:03 2016 +0200
Committer: Tomaz Muraus <to...@tomaz.me>
Committed: Sat Apr 23 08:45:21 2016 +0200
----------------------------------------------------------------------
libcloud/common/openstack.py | 7 ++++---
libcloud/common/openstack_identity.py | 15 +++++++++------
libcloud/test/common/test_openstack_identity.py | 10 ++++++++++
3 files changed, 23 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/efe55b23/libcloud/common/openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/common/openstack.py b/libcloud/common/openstack.py
index 8347613..07796b5 100644
--- a/libcloud/common/openstack.py
+++ b/libcloud/common/openstack.py
@@ -31,7 +31,8 @@ from libcloud.compute.types import KeyPairDoesNotExistError
from libcloud.common.openstack_identity import get_class_for_auth_version
# Imports for backward compatibility reasons
-from libcloud.common.openstack_identity import OpenStackServiceCatalog
+from libcloud.common.openstack_identity import (OpenStackServiceCatalog,
+ OpenStackIdentityTokenScope)
try:
@@ -145,8 +146,8 @@ class OpenStackBaseConnection(ConnectionUserAndKey):
ex_force_auth_url=None,
ex_force_auth_version=None,
ex_force_auth_token=None,
- ex_token_scope=None,
- ex_domain_name=None,
+ ex_token_scope=OpenStackIdentityTokenScope.PROJECT,
+ ex_domain_name='Default',
ex_tenant_name=None,
ex_force_service_type=None,
ex_force_service_name=None,
http://git-wip-us.apache.org/repos/asf/libcloud/blob/efe55b23/libcloud/common/openstack_identity.py
----------------------------------------------------------------------
diff --git a/libcloud/common/openstack_identity.py b/libcloud/common/openstack_identity.py
index 3ac9338..ee07843 100644
--- a/libcloud/common/openstack_identity.py
+++ b/libcloud/common/openstack_identity.py
@@ -572,7 +572,8 @@ class OpenStackIdentityConnection(ConnectionUserAndKey):
auth_version = None
def __init__(self, auth_url, user_id, key, tenant_name=None,
- domain_name=None, token_scope=None,
+ domain_name='Default',
+ token_scope=OpenStackIdentityTokenScope.PROJECT,
timeout=None, parent_conn=None):
super(OpenStackIdentityConnection, self).__init__(user_id=user_id,
key=key,
@@ -590,10 +591,8 @@ class OpenStackIdentityConnection(ConnectionUserAndKey):
self.auth_url = auth_url
self.tenant_name = tenant_name
- self.domain_name = domain_name if domain_name is not None else \
- 'Default'
- self.token_scope = token_scope if token_scope is not None else \
- OpenStackIdentityTokenScope.PROJECT
+ self.domain_name = domain_name
+ self.token_scope = token_scope
self.timeout = timeout
self.urls = {}
@@ -930,7 +929,8 @@ class OpenStackIdentity_3_0_Connection(OpenStackIdentityConnection):
]
def __init__(self, auth_url, user_id, key, tenant_name=None,
- domain_name=None, token_scope=None,
+ domain_name='Default',
+ token_scope=OpenStackIdentityTokenScope.PROJECT,
timeout=None, parent_conn=None):
"""
:param tenant_name: Name of the project this user belongs to. Note:
@@ -965,6 +965,9 @@ class OpenStackIdentity_3_0_Connection(OpenStackIdentityConnection):
(not self.tenant_name or not self.domain_name)):
raise ValueError('Must provide tenant_name and domain_name '
'argument')
+ elif (self.token_scope == OpenStackIdentityTokenScope.DOMAIN and
+ not self.domain_name):
+ raise ValueError('Must provide domain_name argument')
self.auth_user_roles = None
http://git-wip-us.apache.org/repos/asf/libcloud/blob/efe55b23/libcloud/test/common/test_openstack_identity.py
----------------------------------------------------------------------
diff --git a/libcloud/test/common/test_openstack_identity.py b/libcloud/test/common/test_openstack_identity.py
index 69e6f45..456162d 100644
--- a/libcloud/test/common/test_openstack_identity.py
+++ b/libcloud/test/common/test_openstack_identity.py
@@ -274,6 +274,16 @@ class OpenStackIdentity_3_0_ConnectionTests(unittest.TestCase):
key='test',
token_scope='project')
+ # Missing domain_name
+ expected_msg = 'Must provide domain_name argument'
+ self.assertRaisesRegexp(ValueError, expected_msg,
+ OpenStackIdentity_3_0_Connection,
+ auth_url='http://none',
+ user_id='test',
+ key='test',
+ token_scope='domain',
+ domain_name=None)
+
# Scope to project all ok
OpenStackIdentity_3_0_Connection(auth_url='http://none',
user_id='test',