Skip to content

Commit e8f0587

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add support to list volume extensions"
2 parents e7bfabc + 9b2e264 commit e8f0587

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
@@ -45,6 +48,7 @@ def make_client(instance):
4548
# Set client http_log_debug to True if verbosity level is high enough
4649
http_log_debug = utils.get_effective_log_level() <= logging.DEBUG
4750

51+
extensions = [extension.Extension('list_extensions', list_extensions)]
4852
client = volume_client(
4953
username=instance._username,
5054
api_key=instance._password,
@@ -53,7 +57,8 @@ def make_client(instance):
5357
cacert=instance._cacert,
5458
insecure=instance._insecure,
5559
region_name=instance._region_name,
56-
http_log_debug=http_log_debug
60+
extensions=extensions,
61+
http_log_debug=http_log_debug,
5762
)
5863

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

0 commit comments

Comments
 (0)