summaryrefslogtreecommitdiff
path: root/openstackclient/network/client.py
diff options
context:
space:
mode:
authorTang Chen <tangchen@cn.fujitsu.com>2015-12-04 16:30:10 +0800
committerTang Chen <tangchen@cn.fujitsu.com>2015-12-09 09:30:29 +0800
commit4be716eb27752d715ea1140b76e4a03907edd87f (patch)
tree06284f23536f14b236b1b21fc9a17bd48df36ec2 /openstackclient/network/client.py
parent2a2cb4f75d4b83ac821df0d3da0046d24ca5eee0 (diff)
downloadpython-openstackclient-4be716eb27752d715ea1140b76e4a03907edd87f.tar.gz
Migrate network client to SDK.
The previous patches have migrate all network commands to the new version using sdk. This patch will remove the temporary method, and implement a new make_client() to create sdk network client. And also, find() in openstackclient/network/common.py must support sdk. The logic of this function will become much easier than before, so this patch also removes two useless test cases of find(). This patch will also remove the patched methods in tests. Change-Id: Ic2f7bca073beb9757172d16f95d9b82c48cbbc12 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/client.py')
-rw-r--r--openstackclient/network/client.py62
1 files changed, 10 insertions, 52 deletions
diff --git a/openstackclient/network/client.py b/openstackclient/network/client.py
index 69ed11fe..7714c525 100644
--- a/openstackclient/network/client.py
+++ b/openstackclient/network/client.py
@@ -13,6 +13,8 @@
import logging
+from openstack import connection
+
from openstackclient.common import utils
@@ -22,62 +24,18 @@ DEFAULT_API_VERSION = '2.0'
API_VERSION_OPTION = 'os_network_api_version'
API_NAME = "network"
API_VERSIONS = {
- "2.0": "neutronclient.v2_0.client.Client",
- "2": "neutronclient.v2_0.client.Client",
-}
-# Translate our API version to auth plugin version prefix
-API_VERSION_MAP = {
- '2.0': 'v2.0',
- '2': 'v2.0',
-}
-
-NETWORK_API_TYPE = 'network'
-NETWORK_API_VERSIONS = {
- '2.0': 'openstackclient.api.network_v2.APIv2',
- '2': 'openstackclient.api.network_v2.APIv2',
+ "2.0": "openstack.connection.Connection",
+ "2": "openstack.connection.Connection",
}
def make_client(instance):
- """Returns an network service client"""
- network_client = utils.get_client_class(
- API_NAME,
- instance._api_version[API_NAME],
- API_VERSIONS)
- LOG.debug('Instantiating network client: %s', network_client)
-
- endpoint = instance.get_endpoint_for_service_type(
- API_NAME,
- region_name=instance._region_name,
- interface=instance._interface,
- )
-
- # Remember endpoint_type only if it is set
- kwargs = utils.build_kwargs_dict('endpoint_type', instance._interface)
-
- client = network_client(
- session=instance.session,
- region_name=instance._region_name,
- **kwargs
- )
-
- network_api = utils.get_client_class(
- API_NAME,
- instance._api_version[API_NAME],
- NETWORK_API_VERSIONS)
- LOG.debug('Instantiating network api: %s', network_client)
-
- # v2 is hard-coded until discovery is completed, neutron only has one atm
- client.api = network_api(
- session=instance.session,
- service_type=NETWORK_API_TYPE,
- endpoint='/'.join([
- endpoint,
- API_VERSION_MAP[instance._api_version[API_NAME]],
- ])
- )
-
- return client
+ """Returns a network proxy"""
+ conn = connection.Connection(authenticator=instance.session.auth)
+ LOG.debug('Connection: %s', conn)
+ LOG.debug('Network client initialized using OpenStack SDK: %s',
+ conn.network)
+ return conn.network
def build_option_parser(parser):