Respect 'interface' key from clouds.yaml

Commit c500b63703 assigned DEFAULT_INTERFACE as the default value of cli
parser's 'interface' key. But this resulted in the 'interface' key from
clouds.yaml aka OSC_Config always being ignored/overridden.

Instead this commit overrides the config default for 'interface' key with
DEFAULT_INTERFACE which can still be overridden with keys 'interface' or
'endpoint_type' in clouds.yaml or via the existing
--os-interface/OS_INTERFACE methods.

Ref.: c500b63703

Task: 38955
Story: 2007380
Change-Id: Ia4e511c9d47201cca175711e1c4cfa596168202f
This commit is contained in:
Jakob Meng 2021-04-02 12:47:40 +02:00 committed by Jakob Meng
parent 650795af70
commit 4b593699bc
1 changed files with 5 additions and 4 deletions

View File

@ -254,9 +254,10 @@ class OpenStackShell(app.App):
metavar='<interface>',
dest='interface',
choices=['admin', 'public', 'internal'],
default=utils.env(
'OS_INTERFACE',
default=DEFAULT_INTERFACE),
# do not set default value inside utils.env() else user's cloud
# config key 'interface' will be ignored. Use OSC_Config's ctor
# option 'override_defaults' below instead.
default=utils.env('OS_INTERFACE'),
help=_('Select an interface type.'
' Valid interface types: [admin, public, internal].'
' default=%s, (Env: OS_INTERFACE)') % DEFAULT_INTERFACE,
@ -408,7 +409,7 @@ class OpenStackShell(app.App):
self.cloud_config = cloud_config.OSC_Config(
pw_func=prompt_for_password,
override_defaults={
'interface': None,
'interface': DEFAULT_INTERFACE,
'auth_type': self._auth_type,
},
)