diff options
| author | Terry Howe <terrylhowe@gmail.com> | 2014-07-11 09:05:37 -0600 |
|---|---|---|
| committer | Terry Howe <terrylhowe@gmail.com> | 2014-07-26 15:57:48 -0600 |
| commit | 25e0d2ab2794dc68cccec0d1e7b463b7d7f7e65f (patch) | |
| tree | cc49cce46df7eba08e19bbf420f8200cbe8a9532 /openstackclient/common | |
| parent | 70283744a04f868072edc0a31fe49a3122c4bc6e (diff) | |
| download | python-openstackclient-25e0d2ab2794dc68cccec0d1e7b463b7d7f7e65f.tar.gz | |
Add network extension list
Network extension list support
Change-Id: I013f68ef2c3329c8db59e2441dd8d4ffafd4470e
Closes-Bug: #1337685
Diffstat (limited to 'openstackclient/common')
| -rw-r--r-- | openstackclient/common/extension.py | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/openstackclient/common/extension.py b/openstackclient/common/extension.py index 91ee228b..be7426da 100644 --- a/openstackclient/common/extension.py +++ b/openstackclient/common/extension.py @@ -15,6 +15,7 @@ """Extension action implementations""" +import itertools import logging from cliff import lister @@ -25,28 +26,30 @@ from openstackclient.common import utils class ListExtension(lister.Lister): """List extension command""" - # TODO(mfisch): add support for volume and network - # when the underlying APIs support it. - log = logging.getLogger(__name__ + '.ListExtension') def get_parser(self, prog_name): parser = super(ListExtension, self).get_parser(prog_name) parser.add_argument( - '--long', + '--compute', action='store_true', default=False, - help='List additional fields in output') + help='List extensions for the Compute API') parser.add_argument( '--identity', action='store_true', default=False, help='List extensions for the Identity API') parser.add_argument( - '--compute', + '--long', action='store_true', default=False, - help='List extensions for the Compute API') + help='List additional fields in output') + parser.add_argument( + '--network', + action='store_true', + default=False, + help='List extensions for the Network API') parser.add_argument( '--volume', action='store_true', @@ -69,7 +72,7 @@ class ListExtension(lister.Lister): # user specifies one or more of the APIs to show # for now, only identity and compute are supported. show_all = (not parsed_args.identity and not parsed_args.compute - and not parsed_args.volume) + and not parsed_args.volume and not parsed_args.network) if parsed_args.identity or show_all: identity_client = self.app.client_manager.identity @@ -95,8 +98,33 @@ class ListExtension(lister.Lister): message = "Extensions list not supported by Volume API" self.log.warning(message) - return (columns, - (utils.get_item_properties( - s, columns, - formatters={}, - ) for s in data)) + # Resource classes for the above + extension_tuples = ( + utils.get_item_properties( + s, + columns, + formatters={}, + ) for s in data + ) + + # Dictionaries for the below + if parsed_args.network or show_all: + network_client = self.app.client_manager.network + try: + data = network_client.list_extensions()['extensions'] + dict_tuples = ( + utils.get_dict_properties( + s, + columns, + formatters={}, + ) for s in data + ) + extension_tuples = itertools.chain( + extension_tuples, + dict_tuples + ) + except Exception: + message = "Extensions list not supported by Network API" + self.log.warning(message) + + return (columns, extension_tuples) |
