python client ignores region_name

Bug #2057951 reported by Bodo Petermann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-manilaclient
Triaged
Undecided
Unassigned

Bug Description

Manila python clients (manilaclient.v1.client.Client and manilaclient.v2.client.Client) ignore the region_name parameter if initialized with a session.

Python code to set up a manila client (assuming the openstack environment variables are set for an admin account):

import openstack
from manilaclient.v2.client import Client

# get an SDK connection
sdkconnection = openstack.connect()

# create a Manila client using sdkconnection's session
client = Client(session=sdkconnection.session, endpoint_type="public", region_name="region1")

If the client is created this way it may actually use a different region than "region1", as one could check by looking at client.client.endpoint_url.

For example in a setup with two regions "region1" and "region2" and host names in API endpoints like "api.<region>.domain.com", the following python shell snippet shows the effect:

>>> import openstack
>>> from manilaclient.v2.client import Client
>>> c = openstack.connect()
>>> c.session.get_endpoint(service_type="sharev2", interface="public", region_name="region1")
'https://api.region1.domain.com:8786/v2'
>>> c.session.get_endpoint(service_type="sharev2", interface="public", region_name="region2")
'https://api.region2.domain.com:8786/v2'
>>> client = Client(session=c.session, endpoint_type="public", region_name="region1")
>>> client.client.endpoint_url
'https://api.region2.domain.com:8786/v2'

The problem is most likely the code in the initialization of the Client class, if session is set but service_catalog_url is not.

        if session and not service_catalog_url:
            service_catalog_url = self.keystone_client.session.get_endpoint(
                auth, interface=endpoint_type,
                service_type=service_type)

where get_endpoint is missing the region_name parameter.

Versions tested with:

openstacksdk==3.0.0
python-manilaclient==4.8.0
keystoneauth1==5.1.2

tags: added: low-hanging-fruit
Changed in python-manilaclient:
status: New → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.