第 14 章 更新网络配置

您必须完成一些网络配置,以便为 overcloud 升级准备。

14.1. 更新网络接口模板

Red Hat OpenStack Platform 包含一个脚本,可自动将缺少的参数添加到 NIC 模板文件中。

流程

  1. stack 用户的身份登录 undercloud。
  2. source stackrc 文件:

    $ source ~/stackrc
  3. 在 undercloud 上,创建一个名为 update-nic-templates.sh 的文件,并在文件中包含以下内容:

    #!/bin/bash
    STACK_NAME="overcloud"
    ROLES_DATA="/usr/share/openstack-tripleo-heat-templates/roles_data.yaml"
    NETWORK_DATA="/usr/share/openstack-tripleo-heat-templates/network_data.yaml"
    NIC_CONFIG_LINES=$(openstack stack environment show $STACK_NAME | grep "::Net::SoftwareConfig" | sed -E 's/ *OS::TripleO::// ; s/::Net::SoftwareConfig:// ; s/ http.*user-files/ /')
    echo "$NIC_CONFIG_LINES" | while read LINE; do
        ROLE=$(echo "$LINE" | awk '{print $1;}')
        NIC_CONFIG=$(echo "$LINE" | awk '{print $2;}')
    
        if [ -f "$NIC_CONFIG" ]; then
            echo "Updating template for $ROLE role."
            python3 /usr/share/openstack-tripleo-heat-templates/tools/merge-new-params-nic-config-script.py \
                --tht-dir /usr/share/openstack-tripleo-heat-templates \
                --roles-data $ROLES_DATA \
                --network-data $NETWORK_DATA \
                --role-name "$ROLE" \
                --discard-comments yes \
                --template "$NIC_CONFIG"
        else
            echo "No NIC template detected for $ROLE role. Skipping $ROLE role."
        fi
    done
    • 如果使用自定义 overcloud 名称,请将 STACK_NAME 变量设置为 overcloud 的名称。overcloud 堆栈的默认名称为 overcloud
    • 如果您使用自定义 roles_data 文件,请将 ROLES_DATA 变量设置为自定义文件的位置。如果您使用默认的 roles_data 文件,请将变量保留为 /usr/share/openstack-tripleo-heat-templates/roles_data.yaml
    • 如果您使用自定义 network_data 文件,请将 NETWORK_DATA 变量设置为自定义文件的位置。如果您使用默认的 network_data 文件,请将变量保留为 /usr/share/openstack-tripleo-heat-templates/network_data.yaml
    • 运行 /usr/share/openstack-tripleo-heat-templates/tools/merge-new-params-nic-config-script.py -h 以查看添加到脚本的选项列表。
  4. 在脚本中添加可执行权限:

    $ chmod +x update-nic-templates.sh
  5. 可选:如果您为 RHOSP 环境使用 spine-leaf 网络拓扑,请检查 roles_data.yaml 文件,并确保它为您的部署的 NIC 模板使用正确的角色名称。该脚本使用 roles_data.yaml 文件中的 deprecated_nic_config_name 参数的值。
  6. 运行脚本:

    $ ./update-nic-templates.sh

    该脚本保存每个自定义 NIC 模板的副本,并使用缺少的参数更新每个模板。该脚本还会跳过任何没有自定义模板的角色:

    No NIC template detected for BlockStorage role. Skipping BlockStorage role.
    Updating template for CephStorage role.
    The original template was saved as: /home/stack/templates/custom-nics/ceph-storage.yaml.20200903144835
    The update template was saved as: /home/stack/templates/custom-nics/ceph-storage.yaml
    Updating template for Compute role.
    The original template was saved as: /home/stack/templates/custom-nics/compute.yaml.20200903144838
    The update template was saved as: /home/stack/templates/custom-nics/compute.yaml
    Updating template for Controller role.
    The original template was saved as: /home/stack/templates/custom-nics/controller.yaml.20200903144841
    The update template was saved as: /home/stack/templates/custom-nics/controller.yaml
    No NIC template detected for ObjectStorage role. Skipping ObjectStorage role.