@@ -128,12 +128,24 @@ def build_auth_params(auth_plugin_name, cmd_options):
128128 return (auth_plugin_loader , auth_params )
129129
130130
131- def check_valid_auth_options (options , auth_plugin_name , required_scope = True ):
132- """Perform basic option checking, provide helpful error messages.
133-
134- :param required_scope: indicate whether a scoped token is required
135-
136- """
131+ def check_valid_authorization_options (options , auth_plugin_name ):
132+ """Validate authorization options, and provide helpful error messages."""
133+ if (options .auth .get ('project_id' ) and not
134+ options .auth .get ('domain_id' ) and not
135+ options .auth .get ('domain_name' ) and not
136+ options .auth .get ('project_name' ) and not
137+ options .auth .get ('tenant_id' ) and not
138+ options .auth .get ('tenant_name' )):
139+ raise exc .CommandError (_ (
140+ 'Missing parameter(s): '
141+ 'Set either a project or a domain scope, but not both. Set a '
142+ 'project scope with --os-project-name, OS_PROJECT_NAME, or '
143+ 'auth.project_name. Alternatively, set a domain scope with '
144+ '--os-domain-name, OS_DOMAIN_NAME or auth.domain_name.' ))
145+
146+
147+ def check_valid_authentication_options (options , auth_plugin_name ):
148+ """Validate authentication options, and provide helpful error messages."""
137149
138150 msgs = []
139151 if auth_plugin_name .endswith ('password' ):
@@ -143,18 +155,6 @@ def check_valid_auth_options(options, auth_plugin_name, required_scope=True):
143155 if not options .auth .get ('auth_url' ):
144156 msgs .append (_ ('Set an authentication URL, with --os-auth-url,'
145157 ' OS_AUTH_URL or auth.auth_url' ))
146- if (required_scope and not
147- options .auth .get ('project_id' ) and not
148- options .auth .get ('domain_id' ) and not
149- options .auth .get ('domain_name' ) and not
150- options .auth .get ('project_name' ) and not
151- options .auth .get ('tenant_id' ) and not
152- options .auth .get ('tenant_name' )):
153- msgs .append (_ ('Set a scope, such as a project or domain, set a '
154- 'project scope with --os-project-name, '
155- 'OS_PROJECT_NAME or auth.project_name, set a domain '
156- 'scope with --os-domain-name, OS_DOMAIN_NAME or '
157- 'auth.domain_name' ))
158158 elif auth_plugin_name .endswith ('token' ):
159159 if not options .auth .get ('token' ):
160160 msgs .append (_ ('Set a token with --os-token, OS_TOKEN or '
0 commit comments