@@ -90,10 +90,7 @@ def _get_columns(item):
9090 column_map = {
9191 'security_group_rules' : 'rules' ,
9292 }
93- # FIXME(lajoskatona): Stop hiding is_shared when
94- # https://review.opendev.org/c/openstack/openstacksdk/+/950305
95- # is released and SDK version is bumped
96- hidden_columns = ['location' , 'tenant_id' , 'is_shared' ]
93+ hidden_columns = ['location' , 'tenant_id' ]
9794 return utils .get_osc_show_columns_for_sdk_resource (
9895 item , column_map , hidden_columns
9996 )
@@ -225,7 +222,14 @@ def take_action_compute(self, client, parsed_args):
225222# the OSC minimum requirements include SDK 1.0.
226223class ListSecurityGroup (common .NetworkAndComputeLister ):
227224 _description = _ ("List security groups" )
228- FIELDS_TO_RETRIEVE = ['id' , 'name' , 'description' , 'project_id' , 'tags' ]
225+ FIELDS_TO_RETRIEVE = [
226+ 'id' ,
227+ 'name' ,
228+ 'description' ,
229+ 'project_id' ,
230+ 'tags' ,
231+ 'shared' ,
232+ ]
229233
230234 def update_parser_network (self , parser ):
231235 if not self .is_docs_build :
@@ -248,6 +252,23 @@ def update_parser_network(self, parser):
248252 identity_common .add_project_domain_option_to_parser (
249253 parser , enhance_help = self .enhance_help_neutron
250254 )
255+
256+ shared_group = parser .add_mutually_exclusive_group ()
257+ shared_group .add_argument (
258+ '--share' ,
259+ action = 'store_true' ,
260+ dest = 'shared' ,
261+ default = None ,
262+ help = _ ("List security groups shared between projects" ),
263+ )
264+ shared_group .add_argument (
265+ '--no-share' ,
266+ action = 'store_false' ,
267+ dest = 'shared' ,
268+ default = None ,
269+ help = _ ("List security groups not shared between projects" ),
270+ )
271+
251272 _tag .add_tag_filtering_option_to_parser (
252273 parser , _ ('security group' ), enhance_help = self .enhance_help_neutron
253274 )
@@ -275,13 +296,30 @@ def take_action_network(self, client, parsed_args):
275296 ).id
276297 filters ['project_id' ] = project_id
277298
299+ if parsed_args .shared is not None :
300+ filters ['shared' ] = parsed_args .shared
301+
278302 _tag .get_tag_filtering_args (parsed_args , filters )
279303 data = client .security_groups (
280304 fields = self .FIELDS_TO_RETRIEVE , ** filters
281305 )
282306
283- columns = ("id" , "name" , "description" , "project_id" , "tags" )
284- column_headers = ("ID" , "Name" , "Description" , "Project" , "Tags" )
307+ columns = (
308+ "id" ,
309+ "name" ,
310+ "description" ,
311+ "project_id" ,
312+ "tags" ,
313+ "is_shared" ,
314+ )
315+ column_headers = (
316+ "ID" ,
317+ "Name" ,
318+ "Description" ,
319+ "Project" ,
320+ "Tags" ,
321+ "Shared" ,
322+ )
285323 return (
286324 column_headers ,
287325 (
0 commit comments