diff options
| author | Tang Chen <tangchen@cn.fujitsu.com> | 2015-12-01 15:40:52 +0800 |
|---|---|---|
| committer | Tang Chen <tangchen@cn.fujitsu.com> | 2015-12-08 23:24:20 +0800 |
| commit | 56150de2243c8b9d81aa2dc87ffc764b893a75e1 (patch) | |
| tree | 175335b57206709458347703dbb599f2174a7a33 /openstackclient/network | |
| parent | 85d6aeea32e1d208b4af1247012fe63e68922a7d (diff) | |
| download | python-openstackclient-56150de2243c8b9d81aa2dc87ffc764b893a75e1.tar.gz | |
Migrate "network list" command to new version using SDK.
This patch makes "network list" 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.
Change-Id: I0882501cd7bb2c17917e10a6da4298f1452c9765
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')
| -rw-r--r-- | openstackclient/network/v2/network.py | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/openstackclient/network/v2/network.py b/openstackclient/network/v2/network.py index cd14592d..48b5b5a0 100644 --- a/openstackclient/network/v2/network.py +++ b/openstackclient/network/v2/network.py @@ -188,21 +188,21 @@ class ListNetwork(lister.Lister): 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 - data = client.api.network_list(external=parsed_args.external) - if parsed_args.long: columns = ( - 'ID', - 'Name', - 'Status', - 'project_id', - 'state', - 'Shared', - 'Subnets', - 'provider:network_type', - 'router_type', + 'id', + 'name', + 'status', + 'tenant_id', + 'admin_state_up', + 'shared', + 'subnets', + 'provider_network_type', + 'router_external', ) column_headers = ( 'ID', @@ -216,16 +216,26 @@ class ListNetwork(lister.Lister): 'Router Type', ) else: - columns = ('ID', 'Name', 'Subnets') - column_headers = columns - - for d in data: - d = _prep_network_detail(d) + columns = ( + 'id', + 'name', + 'subnets' + ) + column_headers = ( + 'ID', + 'Name', + 'Subnets', + ) + if parsed_args.external: + args = {'router:external': True} + else: + args = {} + data = client.networks(**args) return (column_headers, - (utils.get_dict_properties( + (utils.get_item_properties( s, columns, - formatters={'subnets': utils.format_list}, + formatters=_formatters, ) for s in data)) |
