diff options
| author | Jamie Lennox <jamielennox@redhat.com> | 2015-05-31 13:37:50 +1000 |
|---|---|---|
| committer | Jamie Lennox <jamielennox@redhat.com> | 2015-05-31 15:03:42 +1000 |
| commit | 3ae247fdceac0e2c7bb6160f9ffefc4ad5d8da29 (patch) | |
| tree | 4799e829cd7034810aba68aefd34f1511259c421 /openstackclient/shell.py | |
| parent | 211c14c638b9bf393932be42d4f04a4dd12a84bc (diff) | |
| download | python-openstackclient-3ae247fdceac0e2c7bb6160f9ffefc4ad5d8da29.tar.gz | |
Set tenant options on parsed namespace
Because of the way OSC registers all plugins together we end up
with os-tenant-X parameters being saved to the project-X attribute after
parsing. If you are using the v2 plugins directly then they and os-client-config
expect the tenant_X values and will assuming no scoping information if
they are not present.
Validating options for scope will also fail in this situation, not just
because the resultant auth dictionary is missing the tenant-X
attributes, but because OSC validates that either project or domain
scope information is present.
Fix this by just always setting the v2 parameters if the v3 parameters
are present. This will have no effect on the generic or v3 case but fix
the v2 case.
Expand validation to include the tenant options so it knows that v2
plugins are scoped.
Change-Id: I8cab3e423663f801cbf2d83106c671bddc58d7e6
Closes-Bug: #1460369
Diffstat (limited to 'openstackclient/shell.py')
| -rw-r--r-- | openstackclient/shell.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/openstackclient/shell.py b/openstackclient/shell.py index da985cbc..ab732dad 100644 --- a/openstackclient/shell.py +++ b/openstackclient/shell.py @@ -234,6 +234,23 @@ class OpenStackShell(app.App): cloud_config.set_default('auth_type', 'osc_password') self.log.debug("options: %s", self.options) + project_id = getattr(self.options, 'project_id', None) + project_name = getattr(self.options, 'project_name', None) + tenant_id = getattr(self.options, 'tenant_id', None) + tenant_name = getattr(self.options, 'tenant_name', None) + + # handle some v2/v3 authentication inconsistencies by just acting like + # both the project and tenant information are both present. This can + # go away if we stop registering all the argparse options together. + if project_id and not tenant_id: + self.options.tenant_id = project_id + if project_name and not tenant_name: + self.options.tenant_name = project_name + if tenant_id and not project_id: + self.options.project_id = tenant_id + if tenant_name and not project_name: + self.options.project_name = tenant_name + # Do configuration file handling cc = cloud_config.OpenStackConfig() self.log.debug("defaults: %s", cc.defaults) |
