diff --git a/novaclient/shell.py b/novaclient/shell.py index 583cddb66..5da855aa7 100644 --- a/novaclient/shell.py +++ b/novaclient/shell.py @@ -558,6 +558,10 @@ class OpenStackComputeShell(object): do_help = ('help' in argv) or ( '--help' in argv) or ('-h' in argv) or not argv + # bash-completion should not require authentification + skip_auth = do_help or ( + 'bash-completion' in argv) + # Discover available auth plugins novaclient.auth_plugin.discover_auth_systems() @@ -629,7 +633,7 @@ class OpenStackComputeShell(object): # FIXME(usrleon): Here should be restrict for project id same as # for os_username or os_password but for compatibility it is not. - if must_auth and not do_help: + if must_auth and not skip_auth: if auth_plugin: auth_plugin.parse_opts(args) @@ -686,8 +690,9 @@ class OpenStackComputeShell(object): # set password for auth plugins os_password = args.os_password - if not do_help and not any([args.os_tenant_id, args.os_tenant_name, - args.os_project_id, args.os_project_name]): + if (not skip_auth and + not any([args.os_tenant_id, args.os_tenant_name, + args.os_project_id, args.os_project_name])): raise exc.CommandError(_("You must provide a project name or" " project id via --os-project-name," " --os-project-id, env[OS_PROJECT_ID]" @@ -695,7 +700,7 @@ class OpenStackComputeShell(object): " use os-project and os-tenant" " interchangeably.")) - if not os_auth_url and not do_help: + if not os_auth_url and not skip_auth: raise exc.CommandError( _("You must provide an auth url " "via either --os-auth-url or env[OS_AUTH_URL]")) @@ -717,7 +722,7 @@ class OpenStackComputeShell(object): cacert=cacert, timeout=timeout, session=keystone_session, auth=keystone_auth) - if not do_help: + if not skip_auth: if not api_version.is_latest(): if api_version > api_versions.APIVersion("2.0"): if not api_version.matches(novaclient.API_MIN_VERSION, diff --git a/novaclient/tests/unit/test_shell.py b/novaclient/tests/unit/test_shell.py index 350b2b979..37a1ab69d 100644 --- a/novaclient/tests/unit/test_shell.py +++ b/novaclient/tests/unit/test_shell.py @@ -200,7 +200,6 @@ class ShellTest(utils.TestCase): self._test_help('help set-password', required=required) def test_bash_completion(self): - self.make_env() stdout, stderr = self.shell('bash-completion') # just check we have some output required = [