2121
2222from openstackclient .i18n import _
2323from openstackclient .identity import common as identity_common
24+ from openstackclient .network import sdk_utils
2425
2526
2627LOG = logging .getLogger (__name__ )
2728
2829
2930def _get_columns (item ):
30- columns = list ( item . keys ())
31- if 'tenant_id' in columns :
32- columns . remove ( 'tenant_id' )
33- columns . append ( 'project_id' )
34- return tuple ( sorted ( columns ) )
31+ column_map = {
32+ 'is_shared' : 'shared' ,
33+ 'tenant_id' : 'project_id' ,
34+ }
35+ return sdk_utils . get_osc_show_columns_for_sdk_resource ( item , column_map )
3536
3637
3738def _get_attrs (client_manager , parsed_args ):
@@ -56,6 +57,8 @@ def _get_attrs(client_manager, parsed_args):
5657 return attrs
5758
5859
60+ # TODO(abhiraut): Use the SDK resource mapped attribute names once the
61+ # OSC minimum requirements include SDK 1.0.
5962class CreateNetworkQosPolicy (command .ShowOne ):
6063 _description = _ ("Create a QoS policy" )
6164
@@ -96,9 +99,9 @@ def take_action(self, parsed_args):
9699 client = self .app .client_manager .network
97100 attrs = _get_attrs (self .app .client_manager , parsed_args )
98101 obj = client .create_qos_policy (** attrs )
99- columns = _get_columns (obj )
102+ display_columns , columns = _get_columns (obj )
100103 data = utils .get_item_properties (obj , columns , formatters = {})
101- return columns , data
104+ return ( display_columns , data )
102105
103106
104107class DeleteNetworkQosPolicy (command .Command ):
@@ -135,6 +138,8 @@ def take_action(self, parsed_args):
135138 raise exceptions .CommandError (msg )
136139
137140
141+ # TODO(abhiraut): Use only the SDK resource mapped attribute names once the
142+ # OSC minimum requirements include SDK 1.0.
138143class ListNetworkQosPolicy (command .Lister ):
139144 _description = _ ("List QoS policies" )
140145
@@ -143,8 +148,8 @@ def take_action(self, parsed_args):
143148 columns = (
144149 'id' ,
145150 'name' ,
146- 'shared ' ,
147- 'tenant_id ' ,
151+ 'is_shared ' ,
152+ 'project_id ' ,
148153 )
149154 column_headers = (
150155 'ID' ,
@@ -160,6 +165,8 @@ def take_action(self, parsed_args):
160165 ) for s in data ))
161166
162167
168+ # TODO(abhiraut): Use the SDK resource mapped attribute names once the
169+ # OSC minimum requirements include SDK 1.0.
163170class SetNetworkQosPolicy (command .Command ):
164171 _description = _ ("Set QoS policy properties" )
165172
@@ -226,6 +233,6 @@ def take_action(self, parsed_args):
226233 client = self .app .client_manager .network
227234 obj = client .find_qos_policy (parsed_args .policy ,
228235 ignore_missing = False )
229- columns = _get_columns (obj )
236+ display_columns , columns = _get_columns (obj )
230237 data = utils .get_item_properties (obj , columns )
231- return columns , data
238+ return ( display_columns , data )
0 commit comments