Add validation for token and bypass_url
Specifying only token or only bypass_url leads to a client error. Better to have a corresponding sanity check on shell level to include the needed parameters/env variables. Change-Id: I55dac599d4dadc273eacab14746bf449d3495f2b Closes-bug: #1604820
This commit is contained in:
parent
ada9da0b30
commit
f387243e36
@ -602,19 +602,28 @@ class OpenStackManilaShell(object):
|
|||||||
def _validate_required_options(self, tenant_name, tenant_id,
|
def _validate_required_options(self, tenant_name, tenant_id,
|
||||||
project_name, project_id,
|
project_name, project_id,
|
||||||
token, service_catalog_url, auth_url):
|
token, service_catalog_url, auth_url):
|
||||||
|
if token and not service_catalog_url:
|
||||||
|
raise exc.CommandError(
|
||||||
|
"bypass_url missing: When specifying a token the bypass_url "
|
||||||
|
"must be set via --bypass-url or env[OS_MANILA_BYPASS_URL]")
|
||||||
|
if service_catalog_url and not token:
|
||||||
|
raise exc.CommandError(
|
||||||
|
"Token missing: When specifying a bypass_url a token must be "
|
||||||
|
"set via --os-token or env[OS_TOKEN]")
|
||||||
if token and service_catalog_url:
|
if token and service_catalog_url:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not (tenant_name or tenant_id or project_name or project_id):
|
if not (tenant_name or tenant_id or project_name or project_id):
|
||||||
raise exc.CommandError(
|
raise exc.CommandError(
|
||||||
"You must provide a tenant_name, tenant_id, "
|
"You must provide a tenant_name, tenant_id, "
|
||||||
"project_id or project_name (with "
|
"project_id or project_name (with "
|
||||||
"project_domain_name or project_domain_id) via "
|
"project_domain_name or project_domain_id) via "
|
||||||
"--os-tenant-name (env[OS_TENANT_NAME]), "
|
"--os-tenant-name or env[OS_TENANT_NAME], "
|
||||||
"--os-tenant-id (env[OS_TENANT_ID]), "
|
"--os-tenant-id or env[OS_TENANT_ID], "
|
||||||
"--os-project-id (env[OS_PROJECT_ID]), "
|
"--os-project-id or env[OS_PROJECT_ID], "
|
||||||
"--os-project-name (env[OS_PROJECT_NAME]), "
|
"--os-project-name or env[OS_PROJECT_NAME], "
|
||||||
"--os-project-domain-id (env[OS_PROJECT_DOMAIN_ID]) and "
|
"--os-project-domain-id or env[OS_PROJECT_DOMAIN_ID] and "
|
||||||
"--os-project-domain-name (env[OS_PROJECT_DOMAIN_NAME])."
|
"--os-project-domain-name or env[OS_PROJECT_DOMAIN_NAME]."
|
||||||
)
|
)
|
||||||
|
|
||||||
if not auth_url:
|
if not auth_url:
|
||||||
|
@ -77,6 +77,8 @@ class OpenstackManilaShellTest(utils.TestCase):
|
|||||||
'OS_PASSWORD': 'foo_password'},
|
'OS_PASSWORD': 'foo_password'},
|
||||||
{'OS_TENANT_NAME': 'foo_tenant', 'OS_USERNAME': 'foo_user',
|
{'OS_TENANT_NAME': 'foo_tenant', 'OS_USERNAME': 'foo_user',
|
||||||
'OS_PASSWORD': 'foo_password'},
|
'OS_PASSWORD': 'foo_password'},
|
||||||
|
{'OS_TOKEN': 'foo_token'},
|
||||||
|
{'OS_MANILA_BYPASS_URL': 'http://foo.foo'},
|
||||||
)
|
)
|
||||||
def test_main_failure(self, env_vars):
|
def test_main_failure(self, env_vars):
|
||||||
self.set_env_vars(env_vars)
|
self.set_env_vars(env_vars)
|
||||||
|
3
releasenotes/notes/bug_1606168_fix-54d3c3bb78389f01.yaml
Normal file
3
releasenotes/notes/bug_1606168_fix-54d3c3bb78389f01.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Fix error handling for os-token and bypass-url.
|
Loading…
Reference in New Issue
Block a user