overcloud 网络配置需要一组网络接口模板。这些模板是采用 YAML 格式的标准 heat 模板。每个角色都需要一个 NIC 模板,以便 director 能够正确配置该角色内的每个节点。
所有 NIC 模板都包含与标准 Heat 模板相同的部分:
heat_template_version
要使用的语法版本。
description
模板的字符串描述。
parameters
要在模板中包括的网络参数。
资源
取参数中定义的 参数 并将其应用到网络配置脚本。
输出
呈现用于配置的最终脚本。
/usr/share/openstack-tripleo-heat-templates/network/config 中的默认 NIC 模板利用 Jinja2 语法来帮助呈现模板。例如,以下片段来自 single-nic-vlans 配置中为每个网络呈现一组 VLAN:
{%- for network in networks if network.enabled|default(true) and network.name in role.networks %}
- type: vlan
vlan_id:
get_param: {{network.name}}NetworkVlanID
addresses:
- ip_netmask:
get_param: {{network.name}}IpSubnet
{%- if network.name in role.default_route_networks %}
{%- for network in networks if network.enabled|default(true) and network.name in role.networks %}
- type: vlan
vlan_id:
get_param: {{network.name}}NetworkVlanID
addresses:
- ip_netmask:
get_param: {{network.name}}IpSubnet
{%- if network.name in role.default_route_networks %}
Copy to ClipboardCopied!Toggle word wrapToggle overflow
对于默认 Compute 节点,这只为 Storage、Internal API 和 Tenant 网络呈现网络信息: