diff options
| author | Tang Chen <tangchen@cn.fujitsu.com> | 2015-12-01 16:00:28 +0800 |
|---|---|---|
| committer | Tang Chen <tangchen@cn.fujitsu.com> | 2015-12-07 22:44:23 +0800 |
| commit | 481b711faefe21738da20187cef80fc5fa63fce4 (patch) | |
| tree | a7e548428a2de932bea9caa44ae96d4adcfb73f5 /openstackclient/network | |
| parent | 6a3bc765f4fd23f1592e5e4e8fc6bc77634e8dc2 (diff) | |
| download | python-openstackclient-481b711faefe21738da20187cef80fc5fa63fce4.tar.gz | |
SDK integration: Add a temporary method to create network client using sdk.
This patch adds a temporary method to create a network client using sdk.
This method will help to migrate network commands from neutronclient to sdk
one by one. The command which is being migrated will use this temporary
method to create the sdk client, and the rest ones will use the old client.
The temporary method will finally be removed and implement the same thing
in make_client().
This patch will also add sdk to requirements file.
And adds some formatter helper functions, which will be used in class
CreateNetwork, ListNetwork and ShowNetwork.
This patch is splited from TerryHowe <terrylhowe@gmail.com> 's original patch.
Change-Id: Ie9b35747680afeb66cf6922e2c654fbca7e03569
Implements: blueprint neutron-client
Co-Authored-By: TerryHowe <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 | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/openstackclient/network/v2/network.py b/openstackclient/network/v2/network.py index 336b3086..cd14592d 100644 --- a/openstackclient/network/v2/network.py +++ b/openstackclient/network/v2/network.py @@ -20,15 +20,37 @@ from cliff import command from cliff import lister from cliff import show +from openstack import connection + from openstackclient.common import exceptions from openstackclient.common import utils from openstackclient.identity import common as identity_common from openstackclient.network import common +def _format_admin_state(item): + return 'UP' if item else 'DOWN' + + +def _format_router_external(item): + return 'External' if item else 'Internal' + + +_formatters = { + 'subnets': utils.format_list, + 'admin_state_up': _format_admin_state, + 'router_external': _format_router_external, +} + + +def _make_client_sdk(instance): + """Return a network proxy""" + conn = connection.Connection(authenticator=instance.session.auth) + 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: |
