Skip to content

Commit 279563e

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "SDK Refactor: Prepare network rbac commands"
2 parents 6977105 + 1256aee commit 279563e

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

openstackclient/network/v2/network_rbac.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,18 @@
2121

2222
from openstackclient.i18n import _
2323
from openstackclient.identity import common as identity_common
24+
from openstackclient.network import sdk_utils
2425

2526

2627
LOG = logging.getLogger(__name__)
2728

2829

2930
def _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-
if 'target_tenant' in columns:
35-
columns.remove('target_tenant')
36-
columns.append('target_project_id')
37-
return tuple(sorted(columns))
31+
column_map = {
32+
'target_tenant': 'target_project_id',
33+
'tenant_id': 'project_id',
34+
}
35+
return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map)
3836

3937

4038
def _get_attrs(client_manager, parsed_args):
@@ -70,6 +68,8 @@ def _get_attrs(client_manager, parsed_args):
7068
return attrs
7169

7270

71+
# TODO(abhiraut): Use the SDK resource mapped attribute names once the
72+
# OSC minimum requirements include SDK 1.0.
7373
class CreateNetworkRBAC(command.ShowOne):
7474
_description = _("Create network RBAC policy")
7575

@@ -122,9 +122,9 @@ def take_action(self, parsed_args):
122122
client = self.app.client_manager.network
123123
attrs = _get_attrs(self.app.client_manager, parsed_args)
124124
obj = client.create_rbac_policy(**attrs)
125-
columns = _get_columns(obj)
125+
display_columns, columns = _get_columns(obj)
126126
data = utils.get_item_properties(obj, columns)
127-
return columns, data
127+
return display_columns, data
128128

129129

130130
class DeleteNetworkRBAC(command.Command):
@@ -185,6 +185,8 @@ def take_action(self, parsed_args):
185185
) for s in data))
186186

187187

188+
# TODO(abhiraut): Use the SDK resource mapped attribute names once the
189+
# OSC minimum requirements include SDK 1.0.
188190
class SetNetworkRBAC(command.Command):
189191
_description = _("Set network RBAC policy properties")
190192

@@ -242,6 +244,6 @@ def take_action(self, parsed_args):
242244
client = self.app.client_manager.network
243245
obj = client.find_rbac_policy(parsed_args.rbac_policy,
244246
ignore_missing=False)
245-
columns = _get_columns(obj)
247+
display_columns, columns = _get_columns(obj)
246248
data = utils.get_item_properties(obj, columns)
247-
return columns, data
249+
return display_columns, data

0 commit comments

Comments
 (0)