summaryrefslogtreecommitdiff
path: root/openstackclient/common
diff options
context:
space:
mode:
authorSteve Martinelli <stevemar@ca.ibm.com>2014-11-17 21:35:30 -0500
committerSteve Martinelli <stevemar@ca.ibm.com>2015-01-16 02:52:15 -0500
commit1d75edb1678e42a36879245c6ebac69c14a5f965 (patch)
tree96fd9fe1bbb32b7a679b1e472aee7fb9de29884a /openstackclient/common
parent9057cedfd4acce5b50af28ef2475952e8530ba29 (diff)
downloadpython-openstackclient-1d75edb1678e42a36879245c6ebac69c14a5f965.tar.gz
Default user domain id and project domain id
If either of OS_USER_DOMAIN_ID or OS_USER_DOMAIN_NAME are present then we don't tinker with anything. Otherwise, we should set the USER_DOMAIN_ID to 'OS_DEFAULT_DOMAIN', as this provides a better UX, since the end user doesn't have to specify these arguments. Same logic applies for OS_PROJECT_DOMAIN_ID. Closes-Bug: #1385338 Change-Id: I8a4034c16a1dd50d269f809abab8e960d5de20f7
Diffstat (limited to 'openstackclient/common')
-rw-r--r--openstackclient/common/clientmanager.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py
index 0396e83d..2a138d94 100644
--- a/openstackclient/common/clientmanager.py
+++ b/openstackclient/common/clientmanager.py
@@ -98,6 +98,23 @@ class ClientManager(object):
self._auth_ref = None
self.timing = auth_options.timing
+ default_domain = auth_options.os_default_domain
+ # NOTE(stevemar): If PROJECT_DOMAIN_ID or PROJECT_DOMAIN_NAME is
+ # present, then do not change the behaviour. Otherwise, set the
+ # PROJECT_DOMAIN_ID to 'OS_DEFAULT_DOMAIN' for better usability.
+ if (self._api_version.get('identity') == '3' and
+ not self._auth_params.get('project_domain_id') and
+ not self._auth_params.get('project_domain_name')):
+ self._auth_params['project_domain_id'] = default_domain
+
+ # NOTE(stevemar): If USER_DOMAIN_ID or USER_DOMAIN_NAME is present,
+ # then do not change the behaviour. Otherwise, set the USER_DOMAIN_ID
+ # to 'OS_DEFAULT_DOMAIN' for better usability.
+ if (self._api_version.get('identity') == '3' and
+ not self._auth_params.get('user_domain_id') and
+ not self._auth_params.get('user_domain_name')):
+ self._auth_params['user_domain_id'] = default_domain
+
# For compatibility until all clients can be updated
if 'project_name' in self._auth_params:
self._project_name = self._auth_params['project_name']