支持 Neutron Trunk 资源

https://blueprints.launchpad.net/heat/+spec/support-trunk-port/

为 Neutron trunk 资源添加 Heat 支持。

问题描述

Neutron 在 Newton 版本中引入了一种名为 trunk 的新资源。该资源使得能够使用单个名为 trunk 父端口的端口将 VM 连接到多个 Neutron 网络。

使用 trunk 的典型流程如下

  • 准备使用的网络和端口

openstack network create net0
openstack network create net1
openstack network create net2
openstack port create --network net0 port0
openstack port create --network net1 port1
openstack port create --network net2 port2
  • 创建一个 trunk 并将 port0 设置为父端口

openstack network trunk create --parent-port port0 trunk0
  • port1port2 添加到 trunk,并设置分段类型和 ID

openstack network trunk set \
    --subport port=port1,segmentation-type=vlan,segmentation-id=101 trunk0
openstack network trunk set \
    --subport port=port2,segmentation-type=vlan,segmentation-id=102 trunk0
  • 通过仅添加父端口 (port0) 来启动 VM。

  • VM 可以使用未标记的流量访问 net0,使用 VLAN ID 101 访问 net1,并使用 VLAN ID 102 访问 net2

此蓝图提出了一项更改,以通过引入新的 Heat 资源 OS::Neutron::Trunk 来支持 Heat 中的 Neutron trunk

提议的变更

engine/resources/openstack/neutron/ 下实现一个新的 OS::Neutron::Trunk 资源,具有以下属性和特性

属性

  • name
    • description: trunk 的名称

    • required: True

    • type: String

    • update_allowed: True

  • parent_port
    • description: 父端口的 ID 或名称

    • required: True

    • type: String

    • update_allowed: False

    • constraints: ‘neutron.port’

  • subports
    • description: 包含子端口详细信息的 0 个或多个映射元素的列表

    • required: False

    • update_allowed: True

    • type: list; 列表内容: 预期映射值

    Map 属性

    • port
      • description: 用作子端口的端口的 ID 或名称

      • required: True

      • update_allowed: True

      • type: String

      • constraints: ‘neutron.port’

    • segmentation_type
      • description: 可能需要某些驱动程序(如 OVS),尽管目前仅支持 vlan

      • required: True

      • update_allowed: True

      • type: String

      • constraints: 自定义约束 ‘neutron.trunk_segmentation_type’

    • segmentation_id
      • description: 子端口网络在实例上呈现的分段 ID

      • required: True

      • update_allowed: True

      • type: Integer

      • constraints: 自定义约束 ‘neutron.trunk_segmentation_id’

  • description
    • description: trunk 的描述

    • required: False

    • type: String

    • update_allowed: True

  • admin_state_up
    • description: trunk 的管理状态

    • required: False

    • type: Boolean

    • default: True

    • update_allowed: True

属性

  • admin_state_up: trunk 的管理状态

  • description: trunk 的描述

  • name: trunk 的名称

  • port_id: trunk 父端口的 ID

  • revision_number: trunk 的修订号

  • sub_ports: 包含与 trunk 关联的端口详细信息的映射列表

通过上述更改,用户可以通过创建类似于以下内容的 HOT 模板来使用 trunk

resources:
   ...
  my_trunk:
    type: OS::Neutron::Trunk
    properties:
      name: My_Trunk
      parent_port: {get_resource: my_parent_port}
      subports:
        - {port: my_subport,
          segmentation_type: vlan,
          segmentation_id: 101}
        - {port: {get_resource: my_2nd_subport},
          segmentation_type: vlan,
          segmentation_id: 102}
   ...

Neutron 允许其后端拒绝带有已绑定父端口的 trunk 创建。从 Newton 和 Ocata 开始,只有 Open vSwitch 后端具有此限制。其他后端可以在已绑定和未绑定的父端口上创建 trunk。但是使用 OVS 后端,必须在启动实例之前创建 trunk。

如果用户想要编写与后端无关的模板,并且至少有一个具有上述限制的后端,他们应该始终在启动实例之前创建 trunk。

为了确保首先创建 trunk,应如以下示例所示,通过 get_attr 引用 trunk 父端口

resources:
   ...
  my_instance:
    type: OS::Nova::Server
    properties:
      networks:
        port: {get_attr: [my_trunk, parent_port]}

注意

应仔细记录引用方法,因为没有任何东西可以阻止用户将 trunk 的父端口直接分配给实例,这将导致缺少依赖关系。

备选方案

实现

负责人

主要负责人
  • nilles

其他指派人
  • botond-zoltan

  • etthdvi

里程碑

完成目标里程碑

pike-1

工作项

  • 实现新的资源类型: OS::Neutron::Trunk

  • 实现自定义约束: neutron.trunk_segmentation_type

  • 实现自定义约束 neutron.trunk_segmentation_id

  • 实现单元测试

  • 实现功能测试

  • 将示例模板添加到 heat-templates 仓库
    • 一个带有 trunk 资源和一些支持的模板

    • 一个示例,其中子端口和父端口具有相同的 MAC 地址;在注释中解释为什么这很有用,参考相关的 Neutron 文档 [1]。

  • 记录更改
    • 将发布说明添加到 releasenotes/notes 关于新的资源类型

    • 将一个子部分添加到 Hot 模板指南中,关于新的 trunk 资源,并解释

      • trunk 的正确引用: 使用 get_attr

      • 如果将端口定义为 trunk 子端口,则可能无法将其添加到实例

      • 提及子端口和父端口的 MAC 地址可能相同,否则用户可能会遇到连接问题;参考相关的 Neutron 文档 [1]。

参考文献:

[1]: https://github.com/openstack/openstack-manuals/blob/master/doc/networking-guide/source/config-trunking.rst#using-trunks-and-subports-inside-an-instance

依赖项