OpenStack Identity Authentication Library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

discovery.py 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  2. # not use this file except in compliance with the License. You may obtain
  3. # a copy of the License at
  4. #
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. #
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  9. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  10. # License for the specific language governing permissions and limitations
  11. # under the License.
  12. import os_service_types
  13. from keystoneauth1.exceptions import base
  14. _SERVICE_TYPES = os_service_types.ServiceTypes()
  15. __all__ = ('DiscoveryFailure',
  16. 'ImpliedVersionMismatch',
  17. 'ImpliedMinVersionMismatch',
  18. 'ImpliedMaxVersionMismatch',
  19. 'VersionNotAvailable')
  20. class DiscoveryFailure(base.ClientException):
  21. message = "Discovery of client versions failed."
  22. class VersionNotAvailable(DiscoveryFailure):
  23. message = "Discovery failed. Requested version is not available."
  24. class ImpliedVersionMismatch(ValueError):
  25. label = 'version'
  26. def __init__(self, service_type, implied, given):
  27. super(ImpliedVersionMismatch, self).__init__(
  28. "service_type {service_type} was given which implies"
  29. " major API version {implied} but {label} of"
  30. " {given} was also given. Please update your code"
  31. " to use the official service_type {official_type}.".format(
  32. service_type=service_type,
  33. implied=str(implied[0]),
  34. given=given,
  35. label=self.label,
  36. official_type=_SERVICE_TYPES.get_service_type(service_type),
  37. ))
  38. class ImpliedMinVersionMismatch(ImpliedVersionMismatch):
  39. label = 'min_version'
  40. class ImpliedMaxVersionMismatch(ImpliedVersionMismatch):
  41. label = 'max_version'