diff options
| author | Jenkins <jenkins@review.openstack.org> | 2014-07-08 15:41:37 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2014-07-08 15:41:37 +0000 |
| commit | ab5416a385f3597c2a63b5518f20dce7de75efc4 (patch) | |
| tree | 593b6b9a72d6746b8489b0beede26d433602b3ae /openstackclient | |
| parent | 6575581f79afc79b3ab933ed962eb0b9c1b6e06f (diff) | |
| parent | 270c7fe96727cedf81e7f4fe6361672c512fc150 (diff) | |
| download | python-openstackclient-ab5416a385f3597c2a63b5518f20dce7de75efc4.tar.gz | |
Merge "Add support to list compute extensions"
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/common/extension.py | 28 | ||||
| -rw-r--r-- | openstackclient/compute/client.py | 7 |
2 files changed, 24 insertions, 11 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( diff --git a/openstackclient/compute/client.py b/openstackclient/compute/client.py index 3dacee88..c8712809 100644 --- a/openstackclient/compute/client.py +++ b/openstackclient/compute/client.py @@ -15,6 +15,9 @@ import logging +from novaclient import extension +from novaclient.v1_1.contrib import list_extensions + from openstackclient.common import utils LOG = logging.getLogger(__name__) @@ -39,6 +42,7 @@ def make_client(instance): # Set client http_log_debug to True if verbosity level is high enough http_log_debug = utils.get_effective_log_level() <= logging.DEBUG + extensions = [extension.Extension('list_extensions', list_extensions)] client = compute_client( username=instance._username, api_key=instance._password, @@ -49,8 +53,7 @@ def make_client(instance): region_name=instance._region_name, # FIXME(dhellmann): get endpoint_type from option? endpoint_type='publicURL', - # FIXME(dhellmann): add extension discovery - extensions=[], + extensions=extensions, service_type=API_NAME, # FIXME(dhellmann): what is service_name? service_name='', |
