summaryrefslogtreecommitdiff
path: root/openstackclient/shell.py
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2012-05-09 17:15:43 -0500
committerDean Troyer <dtroyer@gmail.com>2012-05-10 13:54:58 -0500
commit6fb1a4e496f6860c800f08e68c05b7e95be36c3b (patch)
treef109c8da9544b54f59313006f4c219e10bd8ff8f /openstackclient/shell.py
parenta7da2b8008c7429eab270aa937f563dfa3353afa (diff)
downloadpython-openstackclient-6fb1a4e496f6860c800f08e68c05b7e95be36c3b.tar.gz
More identity client config
* move auth option checking back to OpenStackShell() to keep the shell-level interaction at that level; add checking for token flow options * make identity.client.make_client() configure keystoneclient.v2_0.Client() properly for both password flow and token flow auth * eliminated ClientManager.init_token(), set _service_catalog in __init__() * compute client handles token flow Change-Id: I42481b5424489387798c4ec6d3e2a723ab1e6067
Diffstat (limited to 'openstackclient/shell.py')
-rw-r--r--openstackclient/shell.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/openstackclient/shell.py b/openstackclient/shell.py
index fb5d0727..83dd1040 100644
--- a/openstackclient/shell.py
+++ b/openstackclient/shell.py
@@ -27,6 +27,7 @@ from cliff.app import App
from cliff.commandmanager import CommandManager
from openstackclient.common import clientmanager
+from openstackclient.common import exceptions as exc
from openstackclient.common import utils
@@ -141,6 +142,41 @@ class OpenStackShell(App):
'image': self.options.os_image_api_version,
}
+ self.log.debug('validating authentication options')
+ if self.options.os_token or self.options.os_url:
+ # Token flow auth takes priority
+ if not self.options.os_token:
+ raise exc.CommandError(
+ "You must provide a token via"
+ " either --os-token or env[OS_TOKEN]")
+
+ if not self.options.os_url:
+ raise exc.CommandError(
+ "You must provide a service URL via"
+ " either --os-url or env[OS_URL]")
+
+ else:
+ # Validate password flow auth
+ if not self.options.os_username:
+ raise exc.CommandError(
+ "You must provide a username via"
+ " either --os-username or env[OS_USERNAME]")
+
+ if not self.options.os_password:
+ raise exc.CommandError(
+ "You must provide a password via"
+ " either --os-password or env[OS_PASSWORD]")
+
+ if not (self.options.os_tenant_id or self.options.os_tenant_name):
+ raise exc.CommandError(
+ "You must provide a tenant_id via"
+ " either --os-tenant-id or via env[OS_TENANT_ID]")
+
+ if not self.options.os_auth_url:
+ raise exc.CommandError(
+ "You must provide an auth url via"
+ " either --os-auth-url or via env[OS_AUTH_URL]")
+
self.client_manager = clientmanager.ClientManager(
token=self.options.os_token,
url=self.options.os_url,