summaryrefslogtreecommitdiff
path: root/keystoneclient/shell.py
diff options
context:
space:
mode:
authorZiad Sawalha <github@highbridgellc.com>2011-12-28 00:23:31 -0600
committerZiad Sawalha <github@highbridgellc.com>2012-01-20 12:14:02 -0600
commit8db366c448d4074c044f596a8e4271befdb797cb (patch)
treeff128968469d602e00ee41cfe09e12ba31a6d6b0 /keystoneclient/shell.py
parentcbe1f82931002e3562ab41582ff86470681b889b (diff)
downloadpython-keystoneclient-essex-3.tar.gz
Support for version and extension discoveryessex-3
- Supports unauthenticated call to Keystone to discover supported API versions - Added command-line support (usage: keystone discover) - Added client support (keystoneclient.genenric client). Client returns dicts, whereas shell command prints formated output. - Added tests for genenric client - Replicates 'nove discover' in python-novaclient - Starts to address blueprint keystone-client - keystone discover output looks like this: $ keystone discover Keystone found at http://localhost:35357 - supports version v1.0 (DEPRECATED) here http://localhost:35357/v1.0 - supports version v1.1 (CURRENT) here http://localhost:35357/v1.1 - supports version v2.0 (BETA) here http://localhost:35357/v2.0 - and HP-IDM: HP Token Validation Extension - and OS-KSADM: Openstack Keystone Admin - and OS-KSCATALOG: Openstack Keystone Catalog Change-Id: Id16d34dac094c780d36afb3e31c98c318b6071ac
Diffstat (limited to 'keystoneclient/shell.py')
-rw-r--r--keystoneclient/shell.py47
1 files changed, 27 insertions, 20 deletions
diff --git a/keystoneclient/shell.py b/keystoneclient/shell.py
index 01f7fc5..ba30054 100644
--- a/keystoneclient/shell.py
+++ b/keystoneclient/shell.py
@@ -26,6 +26,7 @@ import sys
from keystoneclient import exceptions as exc
from keystoneclient import utils
from keystoneclient.v2_0 import shell as shell_v2_0
+from keystoneclient.generic import shell as shell_generic
def env(e):
@@ -99,6 +100,7 @@ class OpenStackIdentityShell(object):
actions_module = shell_v2_0
self._find_actions(subparsers, actions_module)
+ self._find_actions(subparsers, shell_generic)
self._find_actions(subparsers, self)
return parser
@@ -151,28 +153,33 @@ class OpenStackIdentityShell(object):
#FIXME(usrleon): Here should be restrict for project id same as
# for username or apikey but for compatibility it is not.
- if not args.os_username:
- raise exc.CommandError("You must provide a username:"
- "via --username or env[OS_USERNAME]")
- if not args.os_password:
- raise exc.CommandError("You must provide a password, either"
- "via --password or env[OS_PASSWORD]")
-
- if not args.os_auth_url:
- raise exc.CommandError("You must provide a auth url, either"
- "via --os-auth_url or via"
- "env[OS_AUTH_URL]")
-
- self.cs = self.get_api_class(options.os_version)(
- username=args.os_username,
- tenant_name=args.os_tenant_name,
- tenant_id=args.os_tenant_id,
- password=args.os_password,
- auth_url=args.os_auth_url,
- region_name=args.os_region_name)
+ if not utils.isunauthenticated(args.func):
+ if not args.os_username:
+ raise exc.CommandError("You must provide a username:"
+ "via --username or env[OS_USERNAME]")
+ if not args.os_password:
+ raise exc.CommandError("You must provide a password, either"
+ "via --password or env[OS_PASSWORD]")
+
+ if not args.os_auth_url:
+ raise exc.CommandError("You must provide a auth url, either"
+ "via --os-auth_url or via"
+ "env[OS_AUTH_URL]")
+
+ if utils.isunauthenticated(args.func):
+ self.cs = shell_generic.CLIENT_CLASS(endpoint=args.os_auth_url)
+ else:
+ self.cs = self.get_api_class(options.version)(
+ username=args.os_username,
+ tenant_name=args.os_tenant_name,
+ tenant_id=args.os_tenant_id,
+ password=args.os_password,
+ auth_url=args.os_auth_url,
+ region_name=args.os_region_name)
try:
- self.cs.authenticate()
+ if not utils.isunauthenticated(args.func):
+ self.cs.authenticate()
except exc.Unauthorized:
raise exc.CommandError("Invalid OpenStack Keystone credentials.")
except exc.AuthorizationFailure: