keystoneauth1.access.service_catalog 模块

class keystoneauth1.access.service_catalog.ServiceCatalog(catalog: list[dict[str, Any]])

基类: object

用于处理 Keystone 服务目录的辅助方法。

__abstractmethods__ = frozenset({'from_token', 'is_interface_match'})
__dict__ = mappingproxy({'__module__': 'keystoneauth1.access.service_catalog', '__doc__': 'Helper methods for dealing with a Keystone Service Catalog.', '__init__': <function ServiceCatalog.__init__>, 'from_token': <classmethod(<function ServiceCatalog.from_token>)>, '_get_endpoint_region': <function ServiceCatalog._get_endpoint_region>, 'catalog': <property object>, 'is_interface_match': <function ServiceCatalog.is_interface_match>, 'normalize_interface': <staticmethod(<function ServiceCatalog.normalize_interface>)>, '_normalize_endpoints': <function ServiceCatalog._normalize_endpoints>, '_denormalize_endpoints': <function ServiceCatalog._denormalize_endpoints>, 'normalize_catalog': <function ServiceCatalog.normalize_catalog>, '_get_interface_list': <function ServiceCatalog._get_interface_list>, 'get_endpoints_data': <function ServiceCatalog.get_endpoints_data>, '_endpoints_by_type': <function ServiceCatalog._endpoints_by_type>, 'get_endpoints': <function ServiceCatalog.get_endpoints>, 'get_endpoint_data_list': <function ServiceCatalog.get_endpoint_data_list>, 'get_urls': <function ServiceCatalog.get_urls>, 'url_for': <function ServiceCatalog.url_for>, 'endpoint_data_for': <function ServiceCatalog.endpoint_data_for>, '__dict__': <attribute '__dict__' of 'ServiceCatalog' objects>, '__weakref__': <attribute '__weakref__' of 'ServiceCatalog' objects>, '__abstractmethods__': frozenset({'is_interface_match', 'from_token'}), '_abc_impl': <_abc._abc_data object>, '__annotations__': {}})
__doc__ = 'Helper methods for dealing with a Keystone Service Catalog.'
__init__(catalog: list[dict[str, Any]])
__module__ = 'keystoneauth1.access.service_catalog'
__weakref__

对该对象的弱引用列表

_abc_impl = <_abc._abc_data object>
_denormalize_endpoints(endpoints: list[EndpointData]) list[str | None]

返回原始端点描述字典。

接受 EndpointData 对象列表,并返回目录中返回的原始字典。

参数:

endpoints (list) – keystoneauth1.discover.EndpointData 的列表

返回值:

原始目录格式的端点描述字典列表

_endpoints_by_type(requested: str | None, endpoints: dict[str, list[EndpointData]]) dict[str, list[EndpointData]]

从给定的端点列表中获取适当的端点。

根据服务类型别名规则

如果用户通过其正确名称请求服务,并且该名称匹配,则获胜。

如果用户通过其正确名称请求服务,并且只有一个别名匹配,则获胜。

如果用户通过其正确名称请求服务,并且有多个别名匹配,则从列表中选择第一个别名。

在其他过滤器之后执行“第一个别名”匹配,因为它们可能会以其他方式限制我们的选择。

参数:
  • requested (str) – 用户请求的服务类型。

  • endpoints (dict) – 按找到的服务类型键化的字典。值对此方法不透明。

返回值:

基于别名匹配规则,根据适当的服务类型过滤的服务类型/端点的字典。

_get_endpoint_region(endpoint: dict[str, str]) str | None
_get_interface_list(interface: str | list[str] | tuple[str] | set[str] | None) list[str]
_normalize_endpoints(endpoints: list[dict[str, Any]]) list[dict[str, Any]]

将端点描述字典转换为 v3 格式。

接受来自目录的原始端点描述,并将其更改为 v3 格式。它还将数据副本保存在 raw_endpoint 中,以便可以由期望实际原始数据的那些方法返回。

参数:

endpoints (list) – 端点描述字典列表

返回值:

v3 格式的端点描述字典列表

property catalog: list[dict[str, Any]]

返回原始服务目录内容,主要用于调试。

应用程序应避免使用此方法,而是使用访问器方法。但是,有时检查原始目录对于分析和其他原因很有用。

endpoint_data_for(service_type: str | None = None, interface: str | list[str] | tuple[str] | set[str] | None = 'public', region_name: str | None = None, service_name: str | None = None, service_id: str | None = None, endpoint_id: str | None = None) EndpointData

从服务目录中获取端点数据。

从服务目录中为特定的端点属性获取指定的端点数据。如果未给出属性,则返回指定类型的第一个端点。

有效的接口类型:publicpublicURL

internalinternalURLadmin 或 ‘adminURL`

参数:
  • service_type (string) – 端点的服务类型。

  • interface – 端点类型。可以是单个值或值列表。如果它是值列表,它们将按首选项顺序查找。

  • region_name (string) – 端点的区域。

  • service_name (string) – 服务的分配名称。

  • service_id (string) – 服务的标识符。

  • endpoint_id (string) – 端点的标识符。

abstract classmethod from_token(token: dict[str, Any]) Self

从令牌中检索服务目录。

参数:

令牌

返回值:

服务目录。

get_endpoint_data_list(service_type: str | None = None, interface: str | list[str] | tuple[str] | set[str] | None = 'public', region_name: str | None = None, service_name: str | None = None, service_id: str | None = None, endpoint_id: str | None = None) list[EndpointData]

获取匹配的 EndpointData 对象的扁平列表。

从服务目录中为特定的端点属性获取端点。如果未给出属性,则返回指定类型的第一个端点。

有效的接口类型:publicpublicURL

internalinternalURLadmin 或 ‘adminURL`

参数:
  • service_type (string) – 端点的服务类型。

  • interface – 端点类型。可以是单个值或值列表。如果它是值列表,它们将按首选项顺序查找。

  • region_name (string) – 端点的区域。

  • service_name (string) – 服务的分配名称。

  • service_id (string) – 服务的标识符。

  • endpoint_id (string) – 端点的标识符。

返回值:

匹配的 EndpointData 对象列表

返回类型:

list(keystoneauth1.discover.EndpointData)

get_endpoints(service_type: str | None = None, interface: str | list[str] | tuple[str] | set[str] | None = None, region_name: str | None = None, service_name: str | None = None, service_id: str | None = None, endpoint_id: str | None = None) dict[str, list[str | None]]

为指定的服务(或所有服务)获取和过滤端点数据,包含指定的类型(或所有类型)和区域(或所有区域)以及服务名称。

返回指定服务(或所有服务)的端点,包含指定的类型(或所有类型)和区域(或所有区域)以及服务名称。

如果服务目录中没有名称,则跳过 service_name 检查。这允许与服务名称在目录中不可用的早期服务兼容。

返回一个由 service_type 键化的字典,其中包含端点字典列表

get_endpoints_data(service_type: str | None = None, interface: str | list[str] | tuple[str] | set[str] | None = None, region_name: str | None = None, service_name: str | None = None, service_id: str | None = None, endpoint_id: str | None = None) dict[str, list[EndpointData]]

为指定的服务(或所有服务)获取和过滤端点数据,包含指定的类型(或所有类型)和区域(或所有区域)以及服务名称。

返回指定服务(或所有服务)的端点,包含指定的类型(或所有类型)和区域(或所有区域)以及服务名称。

如果服务目录中没有名称,则跳过 service_name 检查。这允许与服务名称在目录中不可用的早期服务兼容。

有效的接口类型:publicpublicURL

internalinternalURLadmin 或 ‘adminURL`

参数:
  • service_type (string) – 端点的服务类型。

  • interface – 端点类型。可以是单个值或值列表。如果它是值列表,它们将按首选项顺序查找。

  • region_name (string) – 端点的区域。

  • service_name (string) – 服务的分配名称。

  • service_id (string) – 服务的标识符。

  • endpoint_id (string) – 端点的标识符。

返回值:

一个由 service_type 键化的字典,包含 EndpointData 列表

get_urls(service_type: str | None = None, interface: str | list[str] | tuple[str] | set[str] | None = 'public', region_name: str | None = None, service_name: str | None = None, service_id: str | None = None, endpoint_id: str | None = None) tuple[str | None, ...]

从服务目录中获取端点 URL。

从服务目录中获取特定端点属性的端点 URL。如果未给出属性,则返回指定类型的第一个端点的 URL。

有效的接口类型:publicpublicURL

internalinternalURLadmin 或 ‘adminURL`

参数:
  • service_type (string) – 端点的服务类型。

  • interface – 端点类型。可以是单个值或值列表。如果它是值列表,它们将按首选项顺序查找。

  • region_name (string) – 端点的区域。

  • service_name (string) – 服务的分配名称。

  • service_id (string) – 服务的标识符。

  • endpoint_id (string) – 端点的标识符。

返回值:

URL 元组

abstract is_interface_match(endpoint: dict[str, str], interface: str) bool

用于跨 v2 和 v3 规范化端点匹配的辅助函数。

返回值:

如果提供的端点匹配所需接口,则为 True,否则为 False。

normalize_catalog() list[dict[str, Any]]

返回已规范化为 v3 格式的目录。

static normalize_interface(interface: str) str

处理 v2 和 v3 目录指定端点方式的差异。

v2 和 v3 都必须能够处理对方的端点风格。例如,v2 必须能够处理“public”接口,v3 必须能够处理“publicURL”接口。

返回值:

适用于此服务目录格式的端点字符串。

url_for(service_type: str | None = None, interface: str | list[str] | tuple[str] | set[str] | None = 'public', region_name: str | None = None, service_name: str | None = None, service_id: str | None = None, endpoint_id: str | None = None) str | None

从服务目录中获取端点。

从服务目录中为特定的端点属性获取指定的端点。如果未给出属性,则返回指定类型的第一个端点。

有效的接口类型:publicpublicURL

internalinternalURLadmin 或 ‘adminURL`

参数:
  • service_type (string) – 端点的服务类型。

  • interface – 端点类型。可以是单个值或值列表。如果它是值列表,它们将按首选项顺序查找。

  • region_name (string) – 端点的区域。

  • service_name (string) – 服务的分配名称。

  • service_id (string) – 服务的标识符。

  • endpoint_id (string) – 端点的标识符。

class keystoneauth1.access.service_catalog.ServiceCatalogV2(catalog: list[dict[str, Any]])

Bases: ServiceCatalog

用于封装 v2 服务目录的对象。

该对象使用 Keystone 的原始 v2 认证令牌创建。

__abstractmethods__ = frozenset({})
__annotations__ = {}
__doc__ = 'An object for encapsulating the v2 service catalog.\n\n    The object is created using raw v2 auth token from Keystone.\n    '
__module__ = 'keystoneauth1.access.service_catalog'
_abc_impl = <_abc._abc_data object>
_denormalize_endpoints(endpoints: list[EndpointData]) list[str | None]

返回原始端点描述字典。

接受 EndpointData 对象列表,并返回目录中返回的原始字典。

参数:

endpoints (list) – keystoneauth1.discover.EndpointData 的列表

返回值:

原始目录格式的端点描述字典列表

_normalize_endpoints(endpoints: list[dict[str, Any]]) list[dict[str, Any]]

将端点描述字典转换为 v3 格式。

接受来自目录的原始端点描述,并将其更改为 v3 格式。它还将数据副本保存在 raw_endpoint 中,以便可以由期望实际原始数据的那些方法返回。

参数:

endpoints (list) – 端点描述字典列表

返回值:

v3 格式的端点描述字典列表

classmethod from_token(token: dict[str, Any]) Self

从令牌中检索服务目录。

参数:

令牌

返回值:

服务目录。

is_interface_match(endpoint: dict[str, str], interface: str) bool

用于跨 v2 和 v3 规范化端点匹配的辅助函数。

返回值:

如果提供的端点匹配所需接口,则为 True,否则为 False。

static normalize_interface(interface: str) str

处理 v2 和 v3 目录指定端点方式的差异。

v2 和 v3 都必须能够处理对方的端点风格。例如,v2 必须能够处理“public”接口,v3 必须能够处理“publicURL”接口。

返回值:

适用于此服务目录格式的端点字符串。

class keystoneauth1.access.service_catalog.ServiceCatalogV3(catalog: list[dict[str, Any]])

Bases: ServiceCatalog

用于封装 v3 服务目录的对象。

该对象使用 Keystone 的原始 v3 认证令牌创建。

__abstractmethods__ = frozenset({})
__annotations__ = {}
__doc__ = 'An object for encapsulating the v3 service catalog.\n\n    The object is created using raw v3 auth token from Keystone.\n    '
__module__ = 'keystoneauth1.access.service_catalog'
_abc_impl = <_abc._abc_data object>
classmethod from_token(token: dict[str, Any]) Self

从令牌中检索服务目录。

参数:

令牌

返回值:

服务目录。

is_interface_match(endpoint: dict[str, str], interface: str) bool

用于跨 v2 和 v3 规范化端点匹配的辅助函数。

返回值:

如果提供的端点匹配所需接口,则为 True,否则为 False。

static normalize_interface(interface: str) str

处理 v2 和 v3 目录指定端点方式的差异。

v2 和 v3 都必须能够处理对方的端点风格。例如,v2 必须能够处理“public”接口,v3 必须能够处理“publicURL”接口。

返回值:

适用于此服务目录格式的端点字符串。