From beba6e7528f839c503933600525603563014ea24 Mon Sep 17 00:00:00 2001 From: Vitaly Gridnev Date: Thu, 21 Apr 2016 08:48:00 +0300 Subject: [PATCH] use the only method to initialize client using separate methods will produce a confusion and issues, like not using endpoint_type during client creation. Change-Id: I01f911da2eb9e8fb3157a71f68ea4ad79437b70f Closes-bug: 1564805 --- ...honor-endpoint-type-neutron-4583128c383d9745.yaml | 4 ++++ sahara/utils/openstack/neutron.py | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/honor-endpoint-type-neutron-4583128c383d9745.yaml diff --git a/releasenotes/notes/honor-endpoint-type-neutron-4583128c383d9745.yaml b/releasenotes/notes/honor-endpoint-type-neutron-4583128c383d9745.yaml new file mode 100644 index 00000000..77670deb --- /dev/null +++ b/releasenotes/notes/honor-endpoint-type-neutron-4583128c383d9745.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - Fixed issue with handling endpoint_type during creation neutron + client, closed bug 1564805 diff --git a/sahara/utils/openstack/neutron.py b/sahara/utils/openstack/neutron.py index 00549643..b916e798 100644 --- a/sahara/utils/openstack/neutron.py +++ b/sahara/utils/openstack/neutron.py @@ -47,9 +47,11 @@ CONF.register_opts(opts, group=neutron_group) LOG = logging.getLogger(__name__) -def client(): +def client(auth=None): + if not auth: + auth = keystone.auth() session = sessions.cache().get_session(sessions.SESSION_TYPE_NEUTRON) - neutron = neutron_cli.Client('2.0', session=session, auth=keystone.auth(), + neutron = neutron_cli.Client('2.0', session=session, auth=auth, endpoint_type=CONF.neutron.endpoint_type, region_name=CONF.os_region_name) return neutron @@ -60,11 +62,9 @@ class NeutronClient(object): routers = {} def __init__(self, network, token, tenant_name, auth=None): - session = sessions.cache().get_session(sessions.SESSION_TYPE_NEUTRON) - if auth is None: + if not auth: auth = keystone.token_auth(token=token, project_name=tenant_name) - self.neutron = neutron_cli.Client('2.0', session=session, auth=auth, - region_name=CONF.os_region_name) + self.neutron = client(auth) self.network = network def get_router(self):