Merge "Fix nova bash-completion needs authentication"
This commit is contained in:
commit
4d5cfdead0
@ -558,6 +558,10 @@ class OpenStackComputeShell(object):
|
|||||||
do_help = ('help' in argv) or (
|
do_help = ('help' in argv) or (
|
||||||
'--help' in argv) or ('-h' in argv) or not argv
|
'--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
|
# Discover available auth plugins
|
||||||
novaclient.auth_plugin.discover_auth_systems()
|
novaclient.auth_plugin.discover_auth_systems()
|
||||||
|
|
||||||
@ -629,7 +633,7 @@ class OpenStackComputeShell(object):
|
|||||||
|
|
||||||
# FIXME(usrleon): Here should be restrict for project id same as
|
# FIXME(usrleon): Here should be restrict for project id same as
|
||||||
# for os_username or os_password but for compatibility it is not.
|
# 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:
|
if auth_plugin:
|
||||||
auth_plugin.parse_opts(args)
|
auth_plugin.parse_opts(args)
|
||||||
|
|
||||||
@ -686,8 +690,9 @@ class OpenStackComputeShell(object):
|
|||||||
# set password for auth plugins
|
# set password for auth plugins
|
||||||
os_password = args.os_password
|
os_password = args.os_password
|
||||||
|
|
||||||
if not do_help and not any([args.os_tenant_id, args.os_tenant_name,
|
if (not skip_auth and
|
||||||
args.os_project_id, args.os_project_name]):
|
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"
|
raise exc.CommandError(_("You must provide a project name or"
|
||||||
" project id via --os-project-name,"
|
" project id via --os-project-name,"
|
||||||
" --os-project-id, env[OS_PROJECT_ID]"
|
" --os-project-id, env[OS_PROJECT_ID]"
|
||||||
@ -695,7 +700,7 @@ class OpenStackComputeShell(object):
|
|||||||
" use os-project and os-tenant"
|
" use os-project and os-tenant"
|
||||||
" interchangeably."))
|
" interchangeably."))
|
||||||
|
|
||||||
if not os_auth_url and not do_help:
|
if not os_auth_url and not skip_auth:
|
||||||
raise exc.CommandError(
|
raise exc.CommandError(
|
||||||
_("You must provide an auth url "
|
_("You must provide an auth url "
|
||||||
"via either --os-auth-url or env[OS_AUTH_URL]"))
|
"via either --os-auth-url or env[OS_AUTH_URL]"))
|
||||||
@ -717,7 +722,7 @@ class OpenStackComputeShell(object):
|
|||||||
cacert=cacert, timeout=timeout,
|
cacert=cacert, timeout=timeout,
|
||||||
session=keystone_session, auth=keystone_auth)
|
session=keystone_session, auth=keystone_auth)
|
||||||
|
|
||||||
if not do_help:
|
if not skip_auth:
|
||||||
if not api_version.is_latest():
|
if not api_version.is_latest():
|
||||||
if api_version > api_versions.APIVersion("2.0"):
|
if api_version > api_versions.APIVersion("2.0"):
|
||||||
if not api_version.matches(novaclient.API_MIN_VERSION,
|
if not api_version.matches(novaclient.API_MIN_VERSION,
|
||||||
|
@ -200,7 +200,6 @@ class ShellTest(utils.TestCase):
|
|||||||
self._test_help('help set-password', required=required)
|
self._test_help('help set-password', required=required)
|
||||||
|
|
||||||
def test_bash_completion(self):
|
def test_bash_completion(self):
|
||||||
self.make_env()
|
|
||||||
stdout, stderr = self.shell('bash-completion')
|
stdout, stderr = self.shell('bash-completion')
|
||||||
# just check we have some output
|
# just check we have some output
|
||||||
required = [
|
required = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user