diff options
| author | Richard Theis <rtheis@us.ibm.com> | 2016-01-05 12:33:11 -0600 |
|---|---|---|
| committer | Richard Theis <rtheis@us.ibm.com> | 2016-01-06 08:21:57 -0600 |
| commit | 5ff660f71854bc4e11d7e37b6ed54c6170bedc10 (patch) | |
| tree | 7288b65aa95f19ea84122b196b1ae96b06f9387a /openstackclient/compute | |
| parent | 401164939e16a8724d9b83fc1cad427dced66cd8 (diff) | |
| download | python-openstackclient-5ff660f71854bc4e11d7e37b6ed54c6170bedc10.tar.gz | |
Further improve output for "os security group show"
Improve the security group rules output when running the
"os security group show" command. Empty and duplicate
information for each security group rule is now removed.
This will ensure that the rules remain readable when
direction and ethertype information is returned as part
of the transition to neutron networking.
Change-Id: Ib49c27a9d7f4d5d38ceb2b0d785ddf94d88b2d89
Partial-Bug: #1519511
Related-To: blueprint neutron-client
Diffstat (limited to 'openstackclient/compute')
| -rw-r--r-- | openstackclient/compute/v2/security_group.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/openstackclient/compute/v2/security_group.py b/openstackclient/compute/v2/security_group.py index 95e3a1c1..6395e102 100644 --- a/openstackclient/compute/v2/security_group.py +++ b/openstackclient/compute/v2/security_group.py @@ -62,6 +62,23 @@ def _xform_security_group_rule(sgroup): return info +def _xform_and_trim_security_group_rule(sgroup): + info = _xform_security_group_rule(sgroup) + # Trim parent security group ID since caller has this information. + info.pop('parent_group_id', None) + # Trim keys with empty string values. + keys_to_trim = [ + 'ip_protocol', + 'ip_range', + 'port_range', + 'remote_security_group', + ] + for key in keys_to_trim: + if key in info and not info[key]: + info.pop(key) + return info + + class CreateSecurityGroup(show.ShowOne): """Create a new security group""" @@ -396,7 +413,8 @@ class ShowSecurityGroup(show.ShowOne): )._info) rules = [] for r in info['rules']: - rules.append(utils.format_dict(_xform_security_group_rule(r))) + formatted_rule = _xform_and_trim_security_group_rule(r) + rules.append(utils.format_dict(formatted_rule)) # Format rules into a list of strings info.update( |
