Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ Common
Compute
~~~~~~~

- [OpenStack] Select service catalog endpoints by service type without filtering
by the default service name. The service name is only used as a filter when
explicitly provided via ``ex_force_service_name``.

(#2074)
[Miguel Caballer - @micafer]

- [SSH] Support paramiko 4

RSA key support has been removed as of paramiko 4, so only import it
Expand Down
2 changes: 1 addition & 1 deletion libcloud/common/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def get_endpoint(self):
:returns: url of the relevant endpoint for the driver
"""
service_type = self.service_type
service_name = self.service_name
service_name = None
service_region = self.service_region

if self._ex_force_service_type:
Expand Down
33 changes: 33 additions & 0 deletions libcloud/test/common/test_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,39 @@ def test_set_microversion(self):
headers = self.connection.add_default_headers({})
self.assertEqual(headers["OpenStack-API-Version"], "volume 2.67")

def test_get_endpoint_does_not_filter_by_default_service_name(self):
self.connection.service_catalog = Mock()
self.connection.service_catalog.get_endpoint.return_value.url = (
"https://compute.example.com"
)
self.connection.service_type = "compute"
self.connection.service_name = "nova"
self.connection.service_region = "RegionOne"

endpoint = self.connection.get_endpoint()

self.assertEqual(endpoint, "https://compute.example.com")
self.connection.service_catalog.get_endpoint.assert_called_once_with(
service_type="compute", name=None, region="RegionOne"
)

def test_get_endpoint_filters_by_explicit_service_name(self):
self.connection.service_catalog = Mock()
self.connection.service_catalog.get_endpoint.return_value.url = (
"https://compute.example.com"
)
self.connection.service_type = "compute"
self.connection.service_name = "nova"
self.connection.service_region = "RegionOne"
self.connection._ex_force_service_name = "custom-nova"

endpoint = self.connection.get_endpoint()

self.assertEqual(endpoint, "https://compute.example.com")
self.connection.service_catalog.get_endpoint.assert_called_once_with(
service_type="compute", name="custom-nova", region="RegionOne"
)

@patch("libcloud.common.base.ConnectionUserAndKey.request")
def test_request(self, mock_request):
OpenStackBaseConnection.conn_class._raw_data = ""
Expand Down