From 2a2cb4f75d4b83ac821df0d3da0046d24ca5eee0 Mon Sep 17 00:00:00 2001 From: Tang Chen Date: Sat, 5 Dec 2015 12:34:54 +0800 Subject: 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 Co-Authored-By: Tang Chen --- openstackclient/network/v2/network.py | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'openstackclient/network') 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) -- cgit v1.2.1