summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2013-01-17 14:16:32 -0600
committerDean Troyer <dtroyer@gmail.com>2013-07-16 11:31:28 -0500
commitbbb71e7ce2cb8bc81318858823018ff494c61a40 (patch)
tree5ec472d0d741a37477f1f242006cb535b6ea0772 /openstackclient
parent6cb58fa16b1d13db92b6048fc92ca7dae8cbccce (diff)
downloadpython-openstackclient-bbb71e7ce2cb8bc81318858823018ff494c61a40.tar.gz
Add --catalog to service show
Shows endpoints from the service catalog rather than the system services. Change-Id: I842916af9f7c0a76c4d3e27e419bf0fec059ec78
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/identity/v2_0/service.py67
1 files changed, 44 insertions, 23 deletions
diff --git a/openstackclient/identity/v2_0/service.py b/openstackclient/identity/v2_0/service.py
index 9940cb91..629475df 100644
--- a/openstackclient/identity/v2_0/service.py
+++ b/openstackclient/identity/v2_0/service.py
@@ -1,4 +1,4 @@
-# Copyright 2012-2013 OpenStack, LLC.
+# Copyright 2012-2013 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@@ -110,7 +110,7 @@ class ListService(lister.Lister):
class ShowService(show.ShowOne):
- """Show service command"""
+ """Show cloud service information"""
log = logging.getLogger(__name__ + '.ShowService')
@@ -119,30 +119,51 @@ class ShowService(show.ShowOne):
parser.add_argument(
'service',
metavar='<service>',
- help='Type, name or ID of service to display')
+ help='Type, name or ID of service to display',
+ )
+ parser.add_argument(
+ '--catalog',
+ action='store_true',
+ default=False,
+ help='Show service catalog information',
+ )
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- try:
- # search for the usual ID or name
- service = utils.find_resource(identity_client.services,
- parsed_args.service)
- except exceptions.CommandError:
- try:
- # search for service type
- service = identity_client.services.find(
- type=parsed_args.service)
- # FIXME(dtroyer): This exception should eventually come from
- # common client exceptions
- except identity_exc.NotFound:
- msg = "No service with exists."
- # TODO(mordred): Where does name_or_id come from?
- # msg = ("No service with a type, name or ID of '%s' exists." %
- # name_or_id)
- raise exceptions.CommandError(msg)
- info = {}
- info.update(service._info)
- return zip(*sorted(info.iteritems()))
+ if parsed_args.catalog:
+ endpoints = identity_client.service_catalog.get_endpoints(
+ service_type=parsed_args.service)
+ for (service, service_endpoints) in endpoints.iteritems():
+ if service_endpoints:
+ info = {"type": service}
+ info.update(service_endpoints[0])
+ return zip(*sorted(info.iteritems()))
+
+ msg = ("No service catalog with a type, name or ID of '%s' "
+ "exists." % (parsed_args.service))
+ raise exceptions.CommandError(msg)
+ else:
+ try:
+ # search for the usual ID or name
+ service = utils.find_resource(
+ identity_client.services,
+ parsed_args.service,
+ )
+ except exceptions.CommandError:
+ try:
+ # search for service type
+ service = identity_client.services.find(
+ type=parsed_args.service)
+ # FIXME(dtroyer): This exception should eventually come from
+ # common client exceptions
+ except identity_exc.NotFound:
+ msg = ("No service with a type, name or ID of '%s' exists."
+ % parsed_args.service)
+ raise exceptions.CommandError(msg)
+
+ info = {}
+ info.update(service._info)
+ return zip(*sorted(info.iteritems()))