Skip to content

Commit 9b2e264

Browse files
author
Steve Martinelli
committed
Add support to list volume extensions
Since cinderclient has support to list extensions, we should add some of the logic to our list extensions command. Change-Id: I7dc7ca325ea9b82194bba6d875e7b8dc1884d77e Closes-Bug: #1337687
1 parent 270c7fe commit 9b2e264

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

openstackclient/common/extension.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ def get_parser(self, prog_name):
4747
action='store_true',
4848
default=False,
4949
help='List extensions for the Compute API')
50+
parser.add_argument(
51+
'--volume',
52+
action='store_true',
53+
default=False,
54+
help='List extensions for the Volume API')
5055
return parser
5156

5257
def take_action(self, parsed_args):
@@ -63,7 +68,8 @@ def take_action(self, parsed_args):
6368
# by default we want to show everything, unless the
6469
# user specifies one or more of the APIs to show
6570
# for now, only identity and compute are supported.
66-
show_all = (not parsed_args.identity and not parsed_args.compute)
71+
show_all = (not parsed_args.identity and not parsed_args.compute
72+
and not parsed_args.volume)
6773

6874
if parsed_args.identity or show_all:
6975
identity_client = self.app.client_manager.identity
@@ -81,6 +87,14 @@ def take_action(self, parsed_args):
8187
message = "Extensions list not supported by Compute API"
8288
self.log.warning(message)
8389

90+
if parsed_args.volume or show_all:
91+
volume_client = self.app.client_manager.volume
92+
try:
93+
data += volume_client.list_extensions.show_all()
94+
except Exception:
95+
message = "Extensions list not supported by Volume API"
96+
self.log.warning(message)
97+
8498
return (columns,
8599
(utils.get_item_properties(
86100
s, columns,

openstackclient/volume/client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515

1616
import logging
1717

18+
from cinderclient import extension
19+
from cinderclient.v1.contrib import list_extensions
1820
from cinderclient.v1 import volume_snapshots
1921
from cinderclient.v1 import volumes
22+
2023
from openstackclient.common import utils
2124

2225
# Monkey patch for v1 cinderclient
@@ -46,6 +49,7 @@ def make_client(instance):
4649
# Set client http_log_debug to True if verbosity level is high enough
4750
http_log_debug = utils.get_effective_log_level() <= logging.DEBUG
4851

52+
extensions = [extension.Extension('list_extensions', list_extensions)]
4953
client = volume_client(
5054
username=instance._username,
5155
api_key=instance._password,
@@ -54,7 +58,8 @@ def make_client(instance):
5458
cacert=instance._cacert,
5559
insecure=instance._insecure,
5660
region_name=instance._region_name,
57-
http_log_debug=http_log_debug
61+
extensions=extensions,
62+
http_log_debug=http_log_debug,
5863
)
5964

6065
# Populate the Cinder client to skip another auth query to Identity

0 commit comments

Comments
 (0)