summaryrefslogtreecommitdiff
path: root/openstackclient/network/v2/network.py
diff options
context:
space:
mode:
authorTang Chen <tangchen@cn.fujitsu.com>2015-12-05 12:34:54 +0800
committerTang Chen <tangchen@cn.fujitsu.com>2015-12-09 09:30:13 +0800
commit2a2cb4f75d4b83ac821df0d3da0046d24ca5eee0 (patch)
treeeccfc1f51625f534d2592f29efc0e1cb523d703e /openstackclient/network/v2/network.py
parent45c644d428581592f9a17585e019bd6d565133e3 (diff)
downloadpython-openstackclient-2a2cb4f75d4b83ac821df0d3da0046d24ca5eee0.tar.gz
Migrate "network show" command to use SDK.
This patch makes "network show" command use sdk. Since we have to keep the other commands runnable with the old network client, we use a temporary method to create sdk network client. And as a result, the tests need to patch a method to fake the temporary method, which will be removed at last. There are two same test cases in the unit tests. This patch will remove one. And since the output has changed, we also need to fix function test cases. Change-Id: I4c06b4efad2db430767bbaa882b0876df3ab483a Implements: blueprint neutron-client Co-Authored-By: Terry Howe <terrylhowe@gmail.com> Co-Authored-By: Tang Chen <tangchen@cn.fujitsu.com>
Diffstat (limited to 'openstackclient/network/v2/network.py')
-rw-r--r--openstackclient/network/v2/network.py29
1 files changed, 6 insertions, 23 deletions
diff --git a/openstackclient/network/v2/network.py b/openstackclient/network/v2/network.py
index 184c8629..4c94dc65 100644
--- a/openstackclient/network/v2/network.py
+++ b/openstackclient/network/v2/network.py
@@ -14,7 +14,6 @@
"""Network action implementations"""
import logging
-import six
from cliff import command
from cliff import lister
@@ -48,22 +47,6 @@ def _make_client_sdk(instance):
return conn.network
-def _prep_network_detail(net):
- """Prepare network object for output"""
- if 'subnets' in net:
- net['subnets'] = utils.format_list(net['subnets'])
- if 'admin_state_up' in net:
- net['state'] = 'UP' if net['admin_state_up'] else 'DOWN'
- net.pop('admin_state_up')
- if 'router:external' in net:
- net['router_type'] = 'External' if net['router:external'] \
- else 'Internal'
- net.pop('router:external')
- if 'tenant_id' in net:
- net['project_id'] = net.pop('tenant_id')
- return net
-
-
class CreateNetwork(show.ShowOne):
"""Create new network"""
@@ -323,10 +306,10 @@ class ShowNetwork(show.ShowOne):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
+ self.app.client_manager.network = \
+ _make_client_sdk(self.app.client_manager)
client = self.app.client_manager.network
- net = client.api.find_attr(
- 'networks',
- parsed_args.identifier,
- )
- data = _prep_network_detail(net)
- return zip(*sorted(six.iteritems(data)))
+ obj = client.find_network(parsed_args.identifier, ignore_missing=False)
+ columns = sorted(obj.keys())
+ data = utils.get_item_properties(obj, columns, formatters=_formatters)
+ return (tuple(columns), data)