diff options
| author | Steve Martinelli <stevemar@ca.ibm.com> | 2014-07-03 18:25:42 -0400 |
|---|---|---|
| committer | Steve Martinelli <stevemar@ca.ibm.com> | 2014-07-03 23:53:57 -0400 |
| commit | 270c7fe96727cedf81e7f4fe6361672c512fc150 (patch) | |
| tree | 62e7b2b37ae9044d56faf4d430e9ded7b3e317c5 /openstackclient/common | |
| parent | e43c0f2b9b8b1e75959179646c212fdaf3d00265 (diff) | |
| download | python-openstackclient-270c7fe96727cedf81e7f4fe6361672c512fc150.tar.gz | |
Add support to list compute extensions
Since novaclient has support to list extensions, we should add
some of the logic to our list extensions command.
Closes-Bug: #1337684
Change-Id: I3074225780142df265a34add03e60c0f7c64c711
Diffstat (limited to 'openstackclient/common')
| -rw-r--r-- | openstackclient/common/extension.py | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/openstackclient/common/extension.py b/openstackclient/common/extension.py index a8b1a6b0..a3f94c09 100644 --- a/openstackclient/common/extension.py +++ b/openstackclient/common/extension.py @@ -19,16 +19,14 @@ import logging from cliff import lister -from openstackclient.common import exceptions as exc from openstackclient.common import utils class ListExtension(lister.Lister): """List extension command""" - # TODO(mfisch): add support for volume and compute - # when the underlying APIs support it. Add support - # for network when it's added to openstackclient. + # TODO(mfisch): add support for volume and network + # when the underlying APIs support it. log = logging.getLogger(__name__ + '.ListExtension') @@ -44,6 +42,11 @@ class ListExtension(lister.Lister): action='store_true', default=False, help='List extensions for the Identity API') + parser.add_argument( + '--compute', + action='store_true', + default=False, + help='List extensions for the Compute API') return parser def take_action(self, parsed_args): @@ -59,17 +62,24 @@ class ListExtension(lister.Lister): # by default we want to show everything, unless the # user specifies one or more of the APIs to show - # for now, only identity is supported - show_all = (not parsed_args.identity) + # for now, only identity and compute are supported. + show_all = (not parsed_args.identity and not parsed_args.compute) if parsed_args.identity or show_all: identity_client = self.app.client_manager.identity try: data += identity_client.extensions.list() except Exception: - raise exc.CommandError( - "Extensions list not supported by" - " identity API") + message = "Extensions list not supported by Identity API" + self.log.warning(message) + + if parsed_args.compute or show_all: + compute_client = self.app.client_manager.compute + try: + data += compute_client.list_extensions.show_all() + except Exception: + message = "Extensions list not supported by Compute API" + self.log.warning(message) return (columns, (utils.get_item_properties( |
