2222
2323from openstackclient .i18n import _
2424from openstackclient .identity import common as identity_common
25+ from openstackclient .network import sdk_utils
2526
2627
2728LOG = logging .getLogger (__name__ )
2829
2930
3031def _get_columns (item ):
31- columns = list (item .keys ())
32- if 'tenant_id' in columns :
33- columns .remove ('tenant_id' )
34- columns .append ('project_id' )
35- return tuple (sorted (columns ))
32+ column_map = {
33+ 'default_prefix_length' : 'default_prefixlen' ,
34+ 'is_shared' : 'shared' ,
35+ 'maximum_prefix_length' : 'max_prefixlen' ,
36+ 'minimum_prefix_length' : 'min_prefixlen' ,
37+ 'tenant_id' : 'project_id' ,
38+ }
39+ return sdk_utils .get_osc_show_columns_for_sdk_resource (item , column_map )
3640
3741
3842_formatters = {
@@ -134,6 +138,8 @@ def _add_default_options(parser):
134138 )
135139
136140
141+ # TODO(rtheis): Use the SDK resource mapped attribute names once the
142+ # OSC minimum requirements include SDK 1.0.
137143class CreateSubnetPool (command .ShowOne ):
138144 """Create subnet pool"""
139145
@@ -184,9 +190,9 @@ def take_action(self, parsed_args):
184190 if "prefixes" not in attrs :
185191 attrs ['prefixes' ] = []
186192 obj = client .create_subnet_pool (** attrs )
187- columns = _get_columns (obj )
193+ display_columns , columns = _get_columns (obj )
188194 data = utils .get_item_properties (obj , columns , formatters = _formatters )
189- return (columns , data )
195+ return (display_columns , data )
190196
191197
192198class DeleteSubnetPool (command .Command ):
@@ -223,6 +229,8 @@ def take_action(self, parsed_args):
223229 raise exceptions .CommandError (msg )
224230
225231
232+ # TODO(rtheis): Use only the SDK resource mapped attribute names once the
233+ # OSC minimum requirements include SDK 1.0.
226234class ListSubnetPool (command .Lister ):
227235 """List subnet pools"""
228236
@@ -283,8 +291,10 @@ def take_action(self, parsed_args):
283291 filters = {}
284292 if parsed_args .share :
285293 filters ['shared' ] = True
294+ filters ['is_shared' ] = True
286295 elif parsed_args .no_share :
287296 filters ['shared' ] = False
297+ filters ['is_shared' ] = False
288298 if parsed_args .default :
289299 filters ['is_default' ] = True
290300 elif parsed_args .no_default :
@@ -296,6 +306,7 @@ def take_action(self, parsed_args):
296306 parsed_args .project_domain ,
297307 ).id
298308 filters ['tenant_id' ] = project_id
309+ filters ['project_id' ] = project_id
299310 if parsed_args .name is not None :
300311 filters ['name' ] = parsed_args .name
301312 if parsed_args .address_scope :
@@ -310,8 +321,8 @@ def take_action(self, parsed_args):
310321 if parsed_args .long :
311322 headers += ('Default Prefix Length' , 'Address Scope' ,
312323 'Default Subnet Pool' , 'Shared' )
313- columns += ('default_prefixlen ' , 'address_scope_id' ,
314- 'is_default' , 'shared ' )
324+ columns += ('default_prefix_length ' , 'address_scope_id' ,
325+ 'is_default' , 'is_shared ' )
315326
316327 return (headers ,
317328 (utils .get_item_properties (
@@ -320,6 +331,8 @@ def take_action(self, parsed_args):
320331 ) for s in data ))
321332
322333
334+ # TODO(rtheis): Use the SDK resource mapped attribute names once the
335+ # OSC minimum requirements include SDK 1.0.
323336class SetSubnetPool (command .Command ):
324337 """Set subnet pool properties"""
325338
@@ -390,9 +403,9 @@ def take_action(self, parsed_args):
390403 parsed_args .subnet_pool ,
391404 ignore_missing = False
392405 )
393- columns = _get_columns (obj )
406+ display_columns , columns = _get_columns (obj )
394407 data = utils .get_item_properties (obj , columns , formatters = _formatters )
395- return (columns , data )
408+ return (display_columns , data )
396409
397410
398411class UnsetSubnetPool (command .Command ):
0 commit comments