diff options
| author | Jenkins <jenkins@review.openstack.org> | 2015-03-10 04:52:14 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2015-03-10 04:52:14 +0000 |
| commit | 706c51bf962c17282f0c246c809f8f158e080cbc (patch) | |
| tree | c06c6502c3c57aec3c0ef53f8e1b26d46a94428c /openstackclient/identity | |
| parent | 3da6e47e5e8455f8b42392a94b44574c36828e1e (diff) | |
| parent | fa5f02eb2280b7f713d2b7f6e5eafe191bb40d0c (diff) | |
| download | python-openstackclient-706c51bf962c17282f0c246c809f8f158e080cbc.tar.gz | |
Merge "Add identity v3 catalog show"
Diffstat (limited to 'openstackclient/identity')
| -rw-r--r-- | openstackclient/identity/v3/catalog.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/openstackclient/identity/v3/catalog.py b/openstackclient/identity/v3/catalog.py index 09713661..1899f25e 100644 --- a/openstackclient/identity/v3/catalog.py +++ b/openstackclient/identity/v3/catalog.py @@ -16,8 +16,11 @@ import logging from cliff import lister +from cliff import show +import six from openstackclient.common import utils +from openstackclient.i18n import _ # noqa def _format_endpoints(eps=None): @@ -54,3 +57,44 @@ class ListCatalog(lister.Lister): 'Endpoints': _format_endpoints, }, ) for s in data)) + + +class ShowCatalog(show.ShowOne): + """Display service catalog details""" + + log = logging.getLogger(__name__ + '.ShowCatalog') + + def get_parser(self, prog_name): + parser = super(ShowCatalog, self).get_parser(prog_name) + parser.add_argument( + 'service', + metavar='<service>', + help=_('Service to display (type or name)'), + ) + return parser + + def take_action(self, parsed_args): + self.log.debug('take_action(%s)', parsed_args) + + # This is ugly because if auth hasn't happened yet we need + # to trigger it here. + sc = self.app.client_manager.session.auth.get_auth_ref( + self.app.client_manager.session, + ).service_catalog + + data = None + for service in sc.get_data(): + if (service.get('name') == parsed_args.service or + service.get('type') == parsed_args.service): + data = dict(service) + data['endpoints'] = _format_endpoints(data['endpoints']) + if 'links' in data: + data.pop('links') + break + + if not data: + self.app.log.error('service %s not found\n' % + parsed_args.service) + return ([], []) + + return zip(*sorted(six.iteritems(data))) |
