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>
This commit is contained in:
Tang Chen 2015-12-01 16:00:28 +08:00
parent 6a3bc765f4
commit 481b711fae
2 changed files with 24 additions and 1 deletions

View File

@ -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:

View File

@ -7,6 +7,7 @@ six>=1.9.0
Babel>=1.3
cliff>=1.15.0 # Apache-2.0
keystoneauth1>=1.0.0
openstacksdk
os-client-config!=1.6.2,>=1.4.0
oslo.config>=2.7.0 # Apache-2.0
oslo.i18n>=1.5.0 # Apache-2.0