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
@@ -281,8 +289,10 @@ def take_action(self, parsed_args):
281289 filters = {}
282290 if parsed_args .share :
283291 filters ['shared' ] = True
292+ filters ['is_shared' ] = True
284293 elif parsed_args .no_share :
285294 filters ['shared' ] = False
295+ filters ['is_shared' ] = False
286296 if parsed_args .default :
287297 filters ['is_default' ] = True
288298 elif parsed_args .no_default :
@@ -294,6 +304,7 @@ def take_action(self, parsed_args):
294304 parsed_args .project_domain ,
295305 ).id
296306 filters ['tenant_id' ] = project_id
307+ filters ['project_id' ] = project_id
297308 if parsed_args .name is not None :
298309 filters ['name' ] = parsed_args .name
299310 if parsed_args .address_scope :
@@ -308,8 +319,8 @@ def take_action(self, parsed_args):
308319 if parsed_args .long :
309320 headers += ('Default Prefix Length' , 'Address Scope' ,
310321 'Default Subnet Pool' , 'Shared' )
311- columns += ('default_prefixlen ' , 'address_scope_id' ,
312- 'is_default' , 'shared ' )
322+ columns += ('default_prefix_length ' , 'address_scope_id' ,
323+ 'is_default' , 'is_shared ' )
313324
314325 return (headers ,
315326 (utils .get_item_properties (
@@ -318,6 +329,8 @@ def take_action(self, parsed_args):
318329 ) for s in data ))
319330
320331
332+ # TODO(rtheis): Use the SDK resource mapped attribute names once the
333+ # OSC minimum requirements include SDK 1.0.
321334class SetSubnetPool (command .Command ):
322335 """Set subnet pool properties"""
323336
@@ -388,9 +401,9 @@ def take_action(self, parsed_args):
388401 parsed_args .subnet_pool ,
389402 ignore_missing = False
390403 )
391- columns = _get_columns (obj )
404+ display_columns , columns = _get_columns (obj )
392405 data = utils .get_item_properties (obj , columns , formatters = _formatters )
393- return (columns , data )
406+ return (display_columns , data )
394407
395408
396409class UnsetSubnetPool (command .Command ):
0 commit comments