diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2014-09-18 10:35:15 -0500 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2015-01-22 10:06:15 -0600 |
| commit | 748e0ab6cef50910e25fe32cdebb5962e247bcfb (patch) | |
| tree | 526c31276bb41a128eb02947e779233662ed3f89 /openstackclient/network/client.py | |
| parent | b02cce567855399794e654f45eb2619eee8cc357 (diff) | |
| download | python-openstackclient-748e0ab6cef50910e25fe32cdebb5962e247bcfb.tar.gz | |
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
Diffstat (limited to 'openstackclient/network/client.py')
| -rw-r--r-- | openstackclient/network/client.py | 37 |
1 files changed, 35 insertions, 2 deletions
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""" |
