summaryrefslogtreecommitdiff
path: root/openstackclient/identity/v3
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2019-06-23 04:49:33 +0000
committerGerrit Code Review <review@openstack.org>2019-06-23 04:49:33 +0000
commiteada2db332caa3dc042650437a1536e589505c2b (patch)
tree4359e107710853135e6a1166c107f88cb867ce97 /openstackclient/identity/v3
parentf0fafec54f0d0ad5bc241d5d93c98b4d23f94dfc (diff)
parentfa5046a3dbf8cf398b9a05c68e6ee4badbb14ee7 (diff)
downloadpython-openstackclient-eada2db332caa3dc042650437a1536e589505c2b.tar.gz
Merge "Use cliff formattable columns in identity commands"
Diffstat (limited to 'openstackclient/identity/v3')
-rw-r--r--openstackclient/identity/v3/catalog.py24
-rw-r--r--openstackclient/identity/v3/identity_provider.py5
2 files changed, 16 insertions, 13 deletions
diff --git a/openstackclient/identity/v3/catalog.py b/openstackclient/identity/v3/catalog.py
index 28f4fada..59430c4c 100644
--- a/openstackclient/identity/v3/catalog.py
+++ b/openstackclient/identity/v3/catalog.py
@@ -15,6 +15,7 @@
import logging
+from cliff import columns as cliff_columns
from osc_lib.command import command
from osc_lib import exceptions
from osc_lib import utils
@@ -26,15 +27,16 @@ from openstackclient.i18n import _
LOG = logging.getLogger(__name__)
-def _format_endpoints(eps=None):
- if not eps:
- return ""
- ret = ''
- for ep in eps:
- region = ep.get('region_id') or ep.get('region') or '<none>'
- ret += region + '\n'
- ret += " %s: %s\n" % (ep['interface'], ep['url'])
- return ret
+class EndpointsColumn(cliff_columns.FormattableColumn):
+ def human_readable(self):
+ if not self._value:
+ return ""
+ ret = ''
+ for ep in self._value:
+ region = ep.get('region_id') or ep.get('region') or '<none>'
+ ret += region + '\n'
+ ret += " %s: %s\n" % (ep['interface'], ep['url'])
+ return ret
class ListCatalog(command.Lister):
@@ -55,7 +57,7 @@ class ListCatalog(command.Lister):
(utils.get_dict_properties(
s, columns,
formatters={
- 'Endpoints': _format_endpoints,
+ 'Endpoints': EndpointsColumn,
},
) for s in data))
@@ -86,7 +88,7 @@ class ShowCatalog(command.ShowOne):
if (service.get('name') == parsed_args.service or
service.get('type') == parsed_args.service):
data = dict(service)
- data['endpoints'] = _format_endpoints(data['endpoints'])
+ data['endpoints'] = EndpointsColumn(data['endpoints'])
if 'links' in data:
data.pop('links')
break
diff --git a/openstackclient/identity/v3/identity_provider.py b/openstackclient/identity/v3/identity_provider.py
index d8951d31..b3315182 100644
--- a/openstackclient/identity/v3/identity_provider.py
+++ b/openstackclient/identity/v3/identity_provider.py
@@ -15,6 +15,7 @@
import logging
+from osc_lib.cli import format_columns
from osc_lib.command import command
from osc_lib import exceptions
from osc_lib import utils
@@ -103,7 +104,7 @@ class CreateIdentityProvider(command.ShowOne):
enabled=parsed_args.enabled)
idp._info.pop('links', None)
- remote_ids = utils.format_list(idp._info.pop('remote_ids', []))
+ remote_ids = format_columns.ListColumn(idp._info.pop('remote_ids', []))
idp._info['remote_ids'] = remote_ids
return zip(*sorted(six.iteritems(idp._info)))
@@ -245,6 +246,6 @@ class ShowIdentityProvider(command.ShowOne):
id=parsed_args.identity_provider)
idp._info.pop('links', None)
- remote_ids = utils.format_list(idp._info.pop('remote_ids', []))
+ remote_ids = format_columns.ListColumn(idp._info.pop('remote_ids', []))
idp._info['remote_ids'] = remote_ids
return zip(*sorted(six.iteritems(idp._info)))