1919
2020from cliff import lister
2121
22- from openstackclient .common import exceptions as exc
2322from openstackclient .common import utils
2423
2524
2625class ListExtension (lister .Lister ):
2726 """List extension command"""
2827
29- # TODO(mfisch): add support for volume and compute
30- # when the underlying APIs support it. Add support
31- # for network when it's added to openstackclient.
28+ # TODO(mfisch): add support for volume and network
29+ # when the underlying APIs support it.
3230
3331 log = logging .getLogger (__name__ + '.ListExtension' )
3432
@@ -44,6 +42,11 @@ def get_parser(self, prog_name):
4442 action = 'store_true' ,
4543 default = False ,
4644 help = 'List extensions for the Identity API' )
45+ parser .add_argument (
46+ '--compute' ,
47+ action = 'store_true' ,
48+ default = False ,
49+ help = 'List extensions for the Compute API' )
4750 return parser
4851
4952 def take_action (self , parsed_args ):
@@ -59,17 +62,24 @@ def take_action(self, parsed_args):
5962
6063 # by default we want to show everything, unless the
6164 # user specifies one or more of the APIs to show
62- # for now, only identity is supported
63- show_all = (not parsed_args .identity )
65+ # for now, only identity and compute are supported.
66+ show_all = (not parsed_args .identity and not parsed_args . compute )
6467
6568 if parsed_args .identity or show_all :
6669 identity_client = self .app .client_manager .identity
6770 try :
6871 data += identity_client .extensions .list ()
6972 except Exception :
70- raise exc .CommandError (
71- "Extensions list not supported by"
72- " identity API" )
73+ message = "Extensions list not supported by Identity API"
74+ self .log .warning (message )
75+
76+ if parsed_args .compute or show_all :
77+ compute_client = self .app .client_manager .compute
78+ try :
79+ data += compute_client .list_extensions .show_all ()
80+ except Exception :
81+ message = "Extensions list not supported by Compute API"
82+ self .log .warning (message )
7383
7484 return (columns ,
7585 (utils .get_item_properties (
0 commit comments