Skip to content

Commit 9bf24f3

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Set tenant options on parsed namespace"
2 parents 4d57e9f + 3ae247f commit 9bf24f3

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

openstackclient/api/auth.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ def check_valid_auth_options(options, auth_plugin_name):
149149
if (not options.auth.get('project_id', None) and not
150150
options.auth.get('domain_id', None) and not
151151
options.auth.get('domain_name', None) and not
152-
options.auth.get('project_name', None)):
152+
options.auth.get('project_name', None) and not
153+
options.auth.get('tenant_id', None) and not
154+
options.auth.get('tenant_name', None)):
153155
msg += _('Set a scope, such as a project or domain, with '
154156
'--os-project-name, OS_PROJECT_NAME or auth.project_name')
155157
elif auth_plugin_name.endswith('token'):

openstackclient/common/clientmanager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def setup_auth(self):
139139
# PROJECT_DOMAIN_ID to 'OS_DEFAULT_DOMAIN' for better usability.
140140
if (self._api_version.get('identity') == '3' and
141141
not self._auth_params.get('project_domain_id', None) and
142+
not self.auth_plugin_name.startswith('v2') and
142143
not self._auth_params.get('project_domain_name', None)):
143144
self._auth_params['project_domain_id'] = default_domain
144145

@@ -147,6 +148,7 @@ def setup_auth(self):
147148
# to 'OS_DEFAULT_DOMAIN' for better usability.
148149
if (self._api_version.get('identity') == '3' and
149150
self.auth_plugin_name.endswith('password') and
151+
not self.auth_plugin_name.startswith('v2') and
150152
not self._auth_params.get('user_domain_id', None) and
151153
not self._auth_params.get('user_domain_name', None)):
152154
self._auth_params['user_domain_id'] = default_domain

openstackclient/shell.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,23 @@ def initialize_app(self, argv):
234234
cloud_config.set_default('auth_type', 'osc_password')
235235
self.log.debug("options: %s", self.options)
236236

237+
project_id = getattr(self.options, 'project_id', None)
238+
project_name = getattr(self.options, 'project_name', None)
239+
tenant_id = getattr(self.options, 'tenant_id', None)
240+
tenant_name = getattr(self.options, 'tenant_name', None)
241+
242+
# handle some v2/v3 authentication inconsistencies by just acting like
243+
# both the project and tenant information are both present. This can
244+
# go away if we stop registering all the argparse options together.
245+
if project_id and not tenant_id:
246+
self.options.tenant_id = project_id
247+
if project_name and not tenant_name:
248+
self.options.tenant_name = project_name
249+
if tenant_id and not project_id:
250+
self.options.project_id = tenant_id
251+
if tenant_name and not project_name:
252+
self.options.project_name = tenant_name
253+
237254
# Do configuration file handling
238255
cc = cloud_config.OpenStackConfig()
239256
self.log.debug("defaults: %s", cc.defaults)

0 commit comments

Comments
 (0)