Moved CLI specific error message from ksclient to shell

Change-Id: I3edccf0bd146eda975b6c773ac5f5ef592768457
This commit is contained in:
Joe Keen 2015-04-17 13:46:03 -06:00
parent ef2a741231
commit 4fc30376ed
2 changed files with 12 additions and 9 deletions

View File

@ -72,14 +72,7 @@ class KSClient(object):
if self._keystone.project_id: if self._keystone.project_id:
self._token = self._keystone.auth_token self._token = self._keystone.auth_token
else: else:
raise exc.CommandError("User does not have a default project. " raise exc.CommandError("No project id or project name.")
"You must provide a project id using "
"--os-project-id or via env[OS_PROJECT_ID], "
"or you must provide a project name using "
"--os-project-name or via env[OS_PROJECT_NAME] "
"and a domain using --os-domain-name, via "
"env[OS_DOMAIN_NAME], using --os-domain-id or "
"via env[OS_DOMAIN_ID]")
return self._token return self._token
@property @property

View File

@ -331,7 +331,17 @@ class MonascaShell(object):
if args.os_auth_token: if args.os_auth_token:
token = args.os_auth_token token = args.os_auth_token
else: else:
token = _ksclient.token try:
token = _ksclient.token
except exc.CommandError:
raise exc.CommandError("User does not have a default project. "
"You must provide a project id using "
"--os-project-id or via env[OS_PROJECT_ID], "
"or you must provide a project name using "
"--os-project-name or via env[OS_PROJECT_NAME] "
"and a domain using --os-domain-name, via "
"env[OS_DOMAIN_NAME], using --os-domain-id or "
"via env[OS_DOMAIN_ID]")
kwargs = { kwargs = {
'token': token, 'token': token,