summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorRichard Theis <rtheis@us.ibm.com>2016-04-19 16:08:12 -0500
committerRichard Theis <rtheis@us.ibm.com>2016-04-20 07:56:24 -0500
commitf753bad742476cc9a0fc1e5fef8e6c8253eff7a7 (patch)
treeb6e0b83c8e7de20ffa533e497dff4e4ff161db0d /openstackclient
parenta06bb28bcc86ed6e99f78c2d1b2a90d4a93a77b2 (diff)
downloadpython-openstackclient-f753bad742476cc9a0fc1e5fef8e6c8253eff7a7.tar.gz
Fixed subnet command host route output
Fixed the "os subnet create", "os subnet list" and "os subnet show" command output for host routes to improve readability and to align with the "--host-route" option on the "os subnet create" and "os subnet set" commands. Change-Id: Ida69ae1a0bdb2e1648f8b5c978fc80cf1bbe752f Closes-Bug: #1572309
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/network/v2/subnet.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/openstackclient/network/v2/subnet.py b/openstackclient/network/v2/subnet.py
index 715e6620..fb441cbf 100644
--- a/openstackclient/network/v2/subnet.py
+++ b/openstackclient/network/v2/subnet.py
@@ -14,8 +14,6 @@
"""Subnet action implementations"""
import copy
-from json.encoder import JSONEncoder
-
from openstackclient.common import command
from openstackclient.common import exceptions
from openstackclient.common import parseractions
@@ -31,10 +29,8 @@ def _format_allocation_pools(data):
def _format_host_routes(data):
- try:
- return '\n'.join([JSONEncoder().encode(route) for route in data])
- except (TypeError, KeyError):
- return ''
+ # Map the host route keys to match --host-route option.
+ return utils.format_list_of_dicts(convert_entries_to_gateway(data))
_formatters = {
@@ -89,8 +85,9 @@ def convert_entries_to_nexthop(entries):
# Change 'gateway' entry to 'nexthop'
changed_entries = copy.deepcopy(entries)
for entry in changed_entries:
- entry['nexthop'] = entry['gateway']
- del entry['gateway']
+ if 'gateway' in entry:
+ entry['nexthop'] = entry['gateway']
+ del entry['gateway']
return changed_entries
@@ -99,8 +96,9 @@ def convert_entries_to_gateway(entries):
# Change 'nexthop' entry to 'gateway'
changed_entries = copy.deepcopy(entries)
for entry in changed_entries:
- entry['gateway'] = entry['nexthop']
- del entry['nexthop']
+ if 'nexthop' in entry:
+ entry['gateway'] = entry['nexthop']
+ del entry['nexthop']
return changed_entries