From 36391a81a3415d24c55d6bbc318157dc119da8a7 Mon Sep 17 00:00:00 2001 From: TerryHowe Date: Sat, 4 Jul 2015 09:32:16 -0600 Subject: [PATCH] Rename endpoint type to interface Change-Id: I4e21d09bc747e8210f4f79a1d6c4c7ccf2f25d1c Closes-Bug: #1454392 --- doc/source/configuration.rst | 8 ++++---- doc/source/man/openstack.rst | 12 ++++++------ openstackclient/common/clientmanager.py | 12 ++++++------ openstackclient/compute/client.py | 5 ++--- openstackclient/identity/client.py | 5 ++--- openstackclient/image/client.py | 4 ++-- openstackclient/network/client.py | 5 ++--- openstackclient/object/client.py | 2 +- openstackclient/shell.py | 18 +++++++++--------- .../tests/common/test_clientmanager.py | 8 ++++---- openstackclient/tests/fakes.py | 2 +- openstackclient/tests/test_shell.py | 10 +++++----- openstackclient/volume/client.py | 5 ++--- 13 files changed, 46 insertions(+), 50 deletions(-) diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index b603eee425..de3f84ee8e 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -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 ~~~~~~~~~~~~~~~~~~ diff --git a/doc/source/man/openstack.rst b/doc/source/man/openstack.rst index 9d7115275c..53bf36299b 100644 --- a/doc/source/man/openstack.rst +++ b/doc/source/man/openstack.rst @@ -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` Authentication URL @@ -120,8 +120,8 @@ OPTIONS :option:`--os-XXXX-api-version` Additional API version options will be available depending on the installed API libraries. -:option:`--os-endpoint-type` - Endpoint type. Valid options are `public`, `admin` and `internal`. +:option:`--os-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 diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py index fae95630dc..8612a614e9 100644 --- a/openstackclient/common/clientmanager.py +++ b/openstackclient/common/clientmanager.py @@ -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 diff --git a/openstackclient/compute/client.py b/openstackclient/compute/client.py index 27d63a9575..6ae87b7982 100644 --- a/openstackclient/compute/client.py +++ b/openstackclient/compute/client.py @@ -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, diff --git a/openstackclient/identity/client.py b/openstackclient/identity/client.py index cc803511d6..d7b663ddaf 100644 --- a/openstackclient/identity/client.py +++ b/openstackclient/identity/client.py @@ -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, diff --git a/openstackclient/image/client.py b/openstackclient/image/client.py index 8e2d6cd979..8fbf8c0f25 100644 --- a/openstackclient/image/client.py +++ b/openstackclient/image/client.py @@ -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, ) ) diff --git a/openstackclient/network/client.py b/openstackclient/network/client.py index de08e5e2fe..0ef6885287 100644 --- a/openstackclient/network/client.py +++ b/openstackclient/network/client.py @@ -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, diff --git a/openstackclient/object/client.py b/openstackclient/object/client.py index 676f664217..0359940d82 100644 --- a/openstackclient/object/client.py +++ b/openstackclient/object/client.py @@ -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( diff --git a/openstackclient/shell.py b/openstackclient/shell.py index b4e5904c2a..edeffdfb54 100644 --- a/openstackclient/shell.py +++ b/openstackclient/shell.py @@ -209,14 +209,14 @@ class OpenStackShell(app.App): DEFAULT_DOMAIN + ' (Env: OS_DEFAULT_DOMAIN)') parser.add_argument( - '--os-endpoint-type', - metavar='', - dest='endpoint_type', + '--os-interface', + metavar='', + 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( diff --git a/openstackclient/tests/common/test_clientmanager.py b/openstackclient/tests/common/test_clientmanager.py index e86ef50997..29cc59ed26 100644 --- a/openstackclient/tests/common/test_clientmanager.py +++ b/openstackclient/tests/common/test_clientmanager.py @@ -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, diff --git a/openstackclient/tests/fakes.py b/openstackclient/tests/fakes.py index a9322ec3ed..ff69c190df 100644 --- a/openstackclient/tests/fakes.py +++ b/openstackclient/tests/fakes.py @@ -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) diff --git a/openstackclient/tests/test_shell.py b/openstackclient/tests/test_shell.py index 674d83452d..4e1b0ed846 100644 --- a/openstackclient/tests/test_shell.py +++ b/openstackclient/tests/test_shell.py @@ -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") diff --git a/openstackclient/volume/client.py b/openstackclient/volume/client.py index 965c42ec2d..093178e305 100644 --- a/openstackclient/volume/client.py +++ b/openstackclient/volume/client.py @@ -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,