Skip to content

Commit 9ffcd0d

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Fix handling the use_default_subnet_pool attribute"
2 parents 1e739d7 + 3e6356a commit 9ffcd0d

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

openstackclient/network/sdk_utils.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,24 @@
1313
import six
1414

1515

16-
# Get the OSC show command display and attribute columns for an SDK resource.
17-
def get_osc_show_columns_for_sdk_resource(sdk_resource, osc_column_map):
16+
def get_osc_show_columns_for_sdk_resource(
17+
sdk_resource,
18+
osc_column_map,
19+
invisible_columns=[]
20+
):
21+
"""Get and filter the display and attribute columns for an SDK resource.
22+
23+
Common utility function for preparing the output of an OSC show command.
24+
Some of the columns may need to get renamed, others made invisible.
25+
26+
:param sdk_resource: An SDK resource
27+
:param osc_column_map: A hash of mappings for display column names
28+
:param invisible_columns: A list of invisible column names
29+
30+
:returns: Two tuples containing the names of the display and attribute
31+
columns
32+
"""
33+
1834
if getattr(sdk_resource, 'allow_get', None) is not None:
1935
resource_dict = sdk_resource.to_dict(
2036
body=True, headers=False, ignore_none=False)
@@ -24,6 +40,9 @@ def get_osc_show_columns_for_sdk_resource(sdk_resource, osc_column_map):
2440
# Build the OSC column names to display for the SDK resource.
2541
attr_map = {}
2642
display_columns = list(resource_dict.keys())
43+
for col_name in invisible_columns:
44+
if col_name in display_columns:
45+
display_columns.remove(col_name)
2746
for sdk_attr, osc_attr in six.iteritems(osc_column_map):
2847
if sdk_attr in display_columns:
2948
attr_map[osc_attr] = sdk_attr

openstackclient/network/v2/subnet.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,13 @@ def _get_columns(item):
132132
'subnet_pool_id': 'subnetpool_id',
133133
'tenant_id': 'project_id',
134134
}
135-
return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map)
135+
# Do not show this column when displaying a subnet
136+
invisible_columns = ['use_default_subnetpool']
137+
return sdk_utils.get_osc_show_columns_for_sdk_resource(
138+
item,
139+
column_map,
140+
invisible_columns=invisible_columns
141+
)
136142

137143

138144
def convert_entries_to_nexthop(entries):
@@ -179,7 +185,7 @@ def _get_attrs(client_manager, parsed_args, is_create=True):
179185
ignore_missing=False)
180186
attrs['subnetpool_id'] = subnet_pool.id
181187
if parsed_args.use_default_subnet_pool:
182-
attrs['use_default_subnetpool'] = True
188+
attrs['use_default_subnet_pool'] = True
183189
if parsed_args.prefix_length is not None:
184190
attrs['prefixlen'] = parsed_args.prefix_length
185191
if parsed_args.subnet_range is not None:

0 commit comments

Comments
 (0)