Skip to content

Commit 6a540c1

Browse files
committed
fix: properly check if endpoints are enabled
The existing functions to check for endpoints are wrong because they just check for the service and not the endpoint. So if the service is defined they will succeed but if there is no endpoint they won't. This results in the quota code failing when setting quotas. Other places fail in similar ways such as the limits code. This improves the checks to actually check the endpoint instead of the service. Partial-Bug: #2150251 Change-Id: I3bae6ada6a6025f1036b8b52319c67d5b28ba835 Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
1 parent 902fb78 commit 6a540c1

2 files changed

Lines changed: 33 additions & 8 deletions

File tree

openstackclient/common/clientmanager.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,21 @@ def is_network_endpoint_enabled(self) -> bool:
156156
# there is no Service Catalog, callers here are
157157
# not expecting that so fold None into True to
158158
# use Network API by default
159-
return self.is_service_available('network') is not False
159+
return (
160+
self.is_service_available(
161+
'network', self.region_name, self.interface
162+
)
163+
is not False
164+
)
160165

161166
def is_compute_endpoint_enabled(self) -> bool:
162167
"""Check if Compute endpoint is enabled"""
163-
return self.is_service_available('compute') is not False
168+
return (
169+
self.is_service_available(
170+
'compute', self.region_name, self.interface
171+
)
172+
is not False
173+
)
164174

165175
# TODO(stephenfin): Drop volume_client argument in OSC 8.0 or later.
166176
def is_volume_endpoint_enabled(self, volume_client: Any = None) -> bool:
@@ -169,11 +179,26 @@ def is_volume_endpoint_enabled(self, volume_client: Any = None) -> bool:
169179
# Service Types Authority
170180
# https://service-types.openstack.org/service-types.json
171181
return (
172-
self.is_service_available('block-storage') is not False
173-
or self.is_service_available('volume') is not False
174-
or self.is_service_available('volumev3') is not False
175-
or self.is_service_available('volumev2') is not False
176-
or self.is_service_available('block-store') is not False
182+
self.is_service_available(
183+
'block-storage', self.region_name, self.interface
184+
)
185+
is not False
186+
or self.is_service_available(
187+
'volume', self.region_name, self.interface
188+
)
189+
is not False
190+
or self.is_service_available(
191+
'volumev3', self.region_name, self.interface
192+
)
193+
is not False
194+
or self.is_service_available(
195+
'volumev2', self.region_name, self.interface
196+
)
197+
is not False
198+
or self.is_service_available(
199+
'block-store', self.region_name, self.interface
200+
)
201+
is not False
177202
)
178203

179204

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cryptography>=2.7 # BSD/Apache-2.0
88
cliff>=4.13.0 # Apache-2.0
99
iso8601>=0.1.11 # MIT
1010
openstacksdk>=4.12.0 # Apache-2.0
11-
osc-lib>=2.3.0 # Apache-2.0
11+
osc-lib>=4.6.0 # Apache-2.0
1212
oslo.i18n>=3.15.3 # Apache-2.0
1313
python-keystoneclient>=3.22.0 # Apache-2.0
1414
python-cinderclient>=3.3.0 # Apache-2.0

0 commit comments

Comments
 (0)