使用配置文件管理资源提供程序¶
为了便于管理 Placement API 中的资源提供程序信息,Nova 提供了 一种方法,允许管理员使用 YAML 文件添加自定义库存和特性到资源提供程序。
注意
只有 CUSTOM_* 资源类和特性可以通过这种方式进行管理。
文件放置¶
Nova-compute 将在 compute.provider_config_location 中指定的路径中搜索 *.yaml 文件。这些文件将在 nova-compute 启动时加载并验证错误。如果文件中存在任何错误,nova-compute 将无法启动。
管理员应确保资源提供程序配置文件具有适当的权限和所有权。请参阅 规范 和 管理员指南 以获取更多详细信息。
注意
文件在 nova-compute 启动时加载一次,任何更改或新文件在下次 nova-compute 启动之前都不会被识别。
示例¶
可以通过 UUID 或名称来识别要定位的资源提供程序。此外,可以在 UUID 字段中使用值 $COMPUTE_NODE 来识别由该服务管理的所有节点。
如果条目不包含任何额外的库存或特性,则会在加载时记录,但除此之外将被忽略。如果资源提供程序同时通过 $COMPUTE_NODE 和单个 UUID/名称标识,则如果显式条目包含库存或特性,则仅对该提供程序而言,$COMPUTE_NODE 条目中的值将被忽略。
注意
如果资源提供程序被显式 UUID/名称标识多次,nova-compute 服务将无法启动。这是所有提供的 provider.yaml 文件中的全局要求。
meta:
schema_version: '1.0'
providers:
- identification:
name: 'EXAMPLE_RESOURCE_PROVIDER'
# Additional valid identification examples:
# uuid: '$COMPUTE_NODE'
# uuid: '5213b75d-9260-42a6-b236-f39b0fd10561'
inventories:
additional:
- CUSTOM_EXAMPLE_RESOURCE_CLASS:
total: 100
reserved: 0
min_unit: 1
max_unit: 10
step_size: 1
allocation_ratio: 1.0
traits:
additional:
- 'CUSTOM_EXAMPLE_TRAIT'
模式示例¶
type: object
properties:
# This property is used to track where the provider.yaml file originated.
# It is reserved for internal use and should never be set in a provider.yaml
# file supplied by an end user.
__source_file:
not: {}
meta:
type: object
properties:
# Version ($Major, $minor) of the schema must successfully parse
# documents conforming to ($Major, 0..N). Any breaking schema change
# (e.g. removing fields, adding new required fields, imposing a stricter
# pattern on a value, etc.) must bump $Major.
schema_version:
type: string
pattern: '^1\.([0-9]|[1-9][0-9]+)$'
required:
- schema_version
additionalProperties: true
providers:
type: array
items:
type: object
properties:
identification:
$ref: '#/provider_definitions/provider_identification'
inventories:
$ref: '#/provider_definitions/provider_inventories'
traits:
$ref: '#/provider_definitions/provider_traits'
required:
- identification
additionalProperties: true
required:
- meta
additionalProperties: true
provider_definitions:
provider_identification:
# Identify a single provider to configure. Exactly one identification
# method should be used. Currently `uuid` or `name` are supported, but
# future versions may support others.
# The uuid can be set to the sentinel value `$COMPUTE_NODE` which will
# cause the consuming compute service to apply the configuration to
# to all compute node root providers it manages that are not otherwise
# specified using a uuid or name.
type: object
properties:
uuid:
oneOf:
# TODO(sean-k-mooney): replace this with type uuid when we can depend
# on a version of the jsonschema lib that implements draft 8 or later
# of the jsonschema spec.
- type: string
pattern: '^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$'
- type: string
const: '$COMPUTE_NODE'
name:
type: string
minLength: 1
# This introduces the possibility of an unsupported key name being used to
# get by schema validation, but is necessary to support forward
# compatibility with new identification methods. This should be checked
# after schema validation.
minProperties: 1
maxProperties: 1
additionalProperties: false
provider_inventories:
# Allows the admin to specify various adjectives to create and manage
# providers' inventories. This list of adjectives can be extended in the
# future as the schema evolves to meet new use cases. As of v1.0, only one
# adjective, `additional`, is supported.
type: object
properties:
additional:
type: array
items:
patternProperties:
# Allows any key name matching the resource class pattern,
# check to prevent conflicts with virt driver owned resources classes
# will be done after schema validation.
^[A-Z0-9_]{1,255}$:
type: object
properties:
# Any optional properties not populated will be given a default value by
# placement. If overriding a pre-existing provider values will not be
# preserved from the existing inventory.
total:
type: integer
reserved:
type: integer
min_unit:
type: integer
max_unit:
type: integer
step_size:
type: integer
allocation_ratio:
type: number
required:
- total
# The defined properties reflect the current placement data
# model. While defining those in the schema and not allowing
# additional properties means we will need to bump the schema
# version if they change, that is likely to be part of a large
# change that may have other impacts anyway. The benefit of
# stricter validation of property names outweighs the (small)
# chance of having to bump the schema version as described above.
additionalProperties: false
# This ensures only keys matching the pattern above are allowed
additionalProperties: false
additionalProperties: true
provider_traits:
# Allows the admin to specify various adjectives to create and manage
# providers' traits. This list of adjectives can be extended in the
# future as the schema evolves to meet new use cases. As of v1.0, only one
# adjective, `additional`, is supported.
type: object
properties:
additional:
type: array
items:
# Allows any value matching the trait pattern here, additional
# validation will be done after schema validation.
type: string
pattern: '^[A-Z0-9_]{1,255}$'
additionalProperties: true
注意
创建 provider.yaml 配置文件时,建议使用 nova 提供的模式来验证配置,使用简单的 jsonschema 验证器,而不是启动 nova compute 代理,以便更快地迭代。