From 748e0ab6cef50910e25fe32cdebb5962e247bcfb Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Thu, 18 Sep 2014 10:35:15 -0500 Subject: Begin low-level API for Network v2 api.network.APIv2 starts with network_list() support to flush out the skeleton of the Network API. list_dhcp_agent() supports the --dhcp option of 'network list' Change-Id: I9a2b90cde84eced1f2ea6a014b769e2bae668211 --- openstackclient/network/client.py | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'openstackclient/network/client.py') diff --git a/openstackclient/network/client.py b/openstackclient/network/client.py index 858a5079..870566aa 100644 --- a/openstackclient/network/client.py +++ b/openstackclient/network/client.py @@ -24,21 +24,54 @@ API_NAME = "network" API_VERSIONS = { "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': 'openstackclient.api.network_v2.APIv2', +} def make_client(instance): - """Returns an network service client.""" + """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) - return network_client( + endpoint = instance.get_endpoint_for_service_type( + API_NAME, + region_name=instance._region_name, + ) + + client = network_client( session=instance.session, region_name=instance._region_name, ) + 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 + def build_option_parser(parser): """Hook to add global options""" -- cgit v1.2.1