Rename endpoint type to interface

Change-Id: I4e21d09bc747e8210f4f79a1d6c4c7ccf2f25d1c
Closes-Bug: #1454392
This commit is contained in:
TerryHowe 2015-07-04 09:32:16 -06:00
parent ee64c2fa6b
commit 36391a81a3
13 changed files with 46 additions and 50 deletions

View File

@ -78,7 +78,7 @@ The keys match the :program:`openstack` global options but without the
username: openstack
password: xyzpdq!lazydog
region_name: DFW,ORD,IAD
endpoint_type: internal
interface: internal
In the above example, the ``auth_url`` for the ``rackspace`` cloud is taken
from :file:`clouds-public.yaml` (see below).
@ -97,7 +97,7 @@ to the following options if the ``rackspace`` entry in :file:`clouds-public.yaml
--os-username openstack
--os-password xyzpdq!lazydog
--os-region-name DFW
--os-endpoint-type internal
--os-interface internal
and can be selected on the command line::
@ -107,9 +107,9 @@ Note that multiple regions are listed in the ``rackspace`` entry. An otherwise
identical configuration is created for each region. If ``-os-region-name`` is not
specified on the command line, the first region in the list is used by default.
The selection of ``endpoint_type`` (as seen above in the ``rackspace`` entry)
The selection of ``interface`` (as seen above in the ``rackspace`` entry)
is optional. For this configuration to work, every service for this cloud
instance must already be configured to support this type of endpoint.
instance must already be configured to support this type of interface.
clouds-public.yaml
~~~~~~~~~~~~~~~~~~

View File

@ -67,7 +67,7 @@ OPTIONS
The authentication plugin type to use when connecting to the Identity service.
If this option is not set, :program:`openstack` will attempt to guess the
authentication method to use based on the other options.
If this option is set, its version must match :option:`--os-identity-api-version`
If this option is set, its version must match :option:`--os-identity-api-version`
:option:`--os-auth-url` <auth-url>
Authentication URL
@ -120,8 +120,8 @@ OPTIONS
:option:`--os-XXXX-api-version` <XXXX-api-version>
Additional API version options will be available depending on the installed API libraries.
:option:`--os-endpoint-type` <endpoint-type>
Endpoint type. Valid options are `public`, `admin` and `internal`.
:option:`--os-interface` <interface>
Interface type. Valid options are `public`, `admin` and `internal`.
COMMANDS
========
@ -299,7 +299,7 @@ The following environment variables can be set to alter the behaviour of :progra
The name of a cloud configuration in ``clouds.yaml``.
:envvar:`OS_AUTH_PLUGIN`
The authentication plugin to use when connecting to the Identity service, its version must match the Identity API version
The authentication plugin to use when connecting to the Identity service, its version must match the Identity API version
:envvar:`OS_AUTH_URL`
Authentication URL
@ -346,8 +346,8 @@ The following environment variables can be set to alter the behaviour of :progra
:envvar:`OS_XXXX_API_VERSION`
Additional API version options will be available depending on the installed API libraries.
:envvar:`OS_ENDPOINT_TYPE`
Endpoint type. Valid options are `public`, `admin` and `internal`.
:envvar:`OS_INTERFACE`
Interface type. Valid options are `public`, `admin` and `internal`.
BUGS

View File

@ -86,7 +86,7 @@ class ClientManager(object):
self._pw_callback = pw_func
self._url = self._cli_options.auth.get('url', None)
self._region_name = self._cli_options.region_name
self._endpoint_type = self._cli_options.endpoint_type
self._interface = self._cli_options.interface
self.timing = self._cli_options.timing
@ -185,22 +185,22 @@ class ClientManager(object):
return self._auth_ref
def get_endpoint_for_service_type(self, service_type, region_name=None,
endpoint_type='public'):
interface='public'):
"""Return the endpoint URL for the service type."""
if not endpoint_type:
endpoint_type = 'public'
if not interface:
interface = 'public'
# See if we are using password flow auth, i.e. we have a
# service catalog to select endpoints from
if self.auth_ref:
endpoint = self.auth_ref.service_catalog.url_for(
service_type=service_type,
region_name=region_name,
endpoint_type=endpoint_type,
endpoint_type=interface,
)
else:
# Get the passed endpoint directly from the auth plugin
endpoint = self.auth.get_endpoint(self.session,
interface=endpoint_type)
interface=interface)
return endpoint

View File

@ -48,9 +48,8 @@ def make_client(instance):
extensions = [extension.Extension('list_extensions', list_extensions)]
# Remember endpoint_type only if it is set
kwargs = utils.build_kwargs_dict('endpoint_type',
instance._endpoint_type)
# Remember interface only if it is set
kwargs = utils.build_kwargs_dict('endpoint_type', instance._interface)
client = compute_client(
session=instance.session,

View File

@ -46,9 +46,8 @@ def make_client(instance):
API_VERSIONS)
LOG.debug('Instantiating identity client: %s', identity_client)
# Remember interface only if endpoint_type is set
kwargs = utils.build_kwargs_dict('interface',
instance._endpoint_type)
# Remember interface only if interface is set
kwargs = utils.build_kwargs_dict('interface', instance._interface)
client = identity_client(
session=instance.session,

View File

@ -46,7 +46,7 @@ def make_client(instance):
endpoint = instance.get_endpoint_for_service_type(
API_NAME,
region_name=instance._region_name,
endpoint_type=instance._endpoint_type,
interface=instance._interface,
)
client = image_client(
@ -69,7 +69,7 @@ def make_client(instance):
endpoint=instance.get_endpoint_for_service_type(
IMAGE_API_TYPE,
region_name=instance._region_name,
endpoint_type=instance._endpoint_type,
interface=instance._interface,
)
)

View File

@ -47,12 +47,11 @@ def make_client(instance):
endpoint = instance.get_endpoint_for_service_type(
API_NAME,
region_name=instance._region_name,
endpoint_type=instance._endpoint_type,
interface=instance._interface,
)
# Remember endpoint_type only if it is set
kwargs = utils.build_kwargs_dict('endpoint_type',
instance._endpoint_type)
kwargs = utils.build_kwargs_dict('endpoint_type', instance._interface)
client = network_client(
session=instance.session,

View File

@ -36,7 +36,7 @@ def make_client(instance):
endpoint = instance.get_endpoint_for_service_type(
'object-store',
region_name=instance._region_name,
endpoint_type=instance._endpoint_type,
interface=instance._interface,
)
client = object_store_v1.APIv1(

View File

@ -209,14 +209,14 @@ class OpenStackShell(app.App):
DEFAULT_DOMAIN +
' (Env: OS_DEFAULT_DOMAIN)')
parser.add_argument(
'--os-endpoint-type',
metavar='<endpoint-type>',
dest='endpoint_type',
'--os-interface',
metavar='<interface>',
dest='interface',
choices=['admin', 'public', 'internal'],
default=utils.env('OS_ENDPOINT_TYPE'),
help='Select an endpoint type.'
' Valid endpoint types: [admin, public, internal].'
' (Env: OS_ENDPOINT_TYPE)')
default=utils.env('OS_INTERFACE'),
help='Select an interface type.'
' Valid interface types: [admin, public, internal].'
' (Env: OS_INTERFACE)')
parser.add_argument(
'--timing',
default=False,
@ -263,10 +263,10 @@ class OpenStackShell(app.App):
self.options.project_name = tenant_name
# Do configuration file handling
# Ignore the default value of endpoint_type. Only if it is set later
# Ignore the default value of interface. Only if it is set later
# will it be used.
cc = cloud_config.OpenStackConfig(
override_defaults={'endpoint_type': None, })
override_defaults={'interface': None, })
self.log.debug("defaults: %s", cc.defaults)
self.cloud = cc.get_one_cloud(

View File

@ -54,7 +54,7 @@ class FakeOptions(object):
self.identity_api_version = '2.0'
self.timing = None
self.region_name = None
self.endpoint_type = None
self.interface = None
self.url = None
self.auth = {}
self.default_domain = 'default'
@ -124,7 +124,7 @@ class TestClientManager(utils.TestCase):
auth_url=fakes.AUTH_URL,
),
auth_type='v2token',
endpoint_type=fakes.ENDPOINT_TYPE,
interface=fakes.INTERFACE,
region_name=fakes.REGION_NAME,
),
api_version=API_VERSION,
@ -141,8 +141,8 @@ class TestClientManager(utils.TestCase):
auth_v2.Token,
)
self.assertEqual(
fakes.ENDPOINT_TYPE,
client_manager._endpoint_type,
fakes.INTERFACE,
client_manager._interface,
)
self.assertEqual(
fakes.REGION_NAME,

View File

@ -27,7 +27,7 @@ USERNAME = "itchy"
PASSWORD = "scratchy"
PROJECT_NAME = "poochie"
REGION_NAME = "richie"
ENDPOINT_TYPE = "catchy"
INTERFACE = "catchy"
TEST_RESPONSE_DICT = fixture.V2Token(token_id=AUTH_TOKEN,
user_name=USERNAME)

View File

@ -38,7 +38,7 @@ DEFAULT_REGION_NAME = "ZZ9_Plural_Z_Alpha"
DEFAULT_TOKEN = "token"
DEFAULT_SERVICE_URL = "http://127.0.0.1:8771/v3.0/"
DEFAULT_AUTH_PLUGIN = "v2password"
DEFAULT_ENDPOINT_TYPE = "internal"
DEFAULT_INTERFACE = "internal"
DEFAULT_COMPUTE_API_VERSION = "2"
DEFAULT_IDENTITY_API_VERSION = "2"
@ -62,7 +62,7 @@ CLOUD_1 = {
},
'region_name': 'occ-cloud',
'donut': 'glazed',
'endpoint_type': 'public',
'interface': 'public',
}
}
}
@ -106,7 +106,7 @@ global_options = {
'--os-default-domain': (DEFAULT_DOMAIN_NAME, True, True),
'--os-cacert': ('/dev/null', True, True),
'--timing': (True, True, False),
'--os-endpoint-type': (DEFAULT_ENDPOINT_TYPE, True, True)
'--os-interface': (DEFAULT_INTERFACE, True, True)
}
auth_options = {
@ -126,7 +126,7 @@ auth_options = {
'--os-auth-type': ("v2password", True, True),
'--os-token': (DEFAULT_TOKEN, True, True),
'--os-url': (DEFAULT_SERVICE_URL, True, True),
'--os-endpoint-type': (DEFAULT_ENDPOINT_TYPE, True, True),
'--os-interface': (DEFAULT_INTERFACE, True, True),
}
@ -614,7 +614,7 @@ class TestShellCli(TestShell):
)
self.assertEqual(
'public',
_shell.cloud.config['endpoint_type'],
_shell.cloud.config['interface'],
)
@mock.patch("os_client_config.config.OpenStackConfig._load_vendor_file")

View File

@ -53,9 +53,8 @@ def make_client(instance):
extensions = [extension.Extension('list_extensions', list_extensions)]
# Remember endpoint_type only if it is set
kwargs = utils.build_kwargs_dict('endpoint_type',
instance._endpoint_type)
# Remember interface only if it is set
kwargs = utils.build_kwargs_dict('endpoint_type', instance._interface)
client = volume_client(
session=instance.session,