openstackopenstack-heat

Configure network MTU in Openstack with Heat


Is it possible to configure the mtu of a network while creating it with a heat template in Openstack?

I can set the mtu through the CLI openstack network --mtu <value> <network_id>

I see a reference to mtu in the heat guide but it doesn't appear to allow setting of the value.


Solution

  • Yes, it is possible to set the MTU with heat-templates. You have to use the value_specs-field, which allows you additional properties. See its really bad documentation here:

    https://docs.openstack.org/heat/pike/template_guide/openstack.html#OS::Neutron::Subnet-prop-value_specs

    I tested it with the following simple heat-template:

    heat_template_version: 2013-05-23
    description: tests network
    
    resources:
      demo-network:
        type: OS::Neutron::Net
        properties:
          name: demo-network
          value_specs: { mtu: 1400 }
    

    It really created a network with an MTU of 1400 like set in the template. Checked it with a show-command:

    root@test-node:~# openstack network show demo-network
    +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Field                     | Value                                                                                                                                                            |
    +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | admin_state_up            | UP                                                                                                                                                               |
    | availability_zone_hints   |                                                                                                                                                                  |
    | availability_zones        |                                                                                                                                                                  |
    | created_at                | 2020-05-16T13:33:53Z                                                                                                                                             |
    | description               |                                                                                                                                                                  |
    | dns_domain                | None                                                                                                                                                             |
    | id                        | 965d890f-0c37-400e-8ee0-ec6ce1fcf4e6                                                                                                                             |
    | ipv4_address_scope        | None                                                                                                                                                             |
    | ipv6_address_scope        | None                                                                                                                                                             |
    | is_default                | None                                                                                                                                                             |
    | is_vlan_transparent       | None                                                                                                                                                             |
    | location                  | cloud='', project.domain_id=, project.domain_name='Default', project.id='2dacaa8f6d3348f28e126b371bf1dfab', project.name='admin', region_name='RegionOne', zone= |
    | mtu                       | 1400                                                                                                                                                             |
    | name                      | demo-network                                                                                                                                                     |
    | port_security_enabled     | True                                                                                                                                                             |
    | project_id                | 2dacaa8f6d3348f28e126b371bf1dfab                                                                                                                                 |
    | provider:network_type     | vxlan                                                                                                                                                            |
    | provider:physical_network | None                                                                                                                                                             |
    | provider:segmentation_id  | 60                                                                                                                                                               |
    | qos_policy_id             | None                                                                                                                                                             |
    | revision_number           | 1                                                                                                                                                                |
    | router:external           | Internal                                                                                                                                                         |
    | segments                  | None                                                                                                                                                             |
    | shared                    | False                                                                                                                                                            |
    | status                    | ACTIVE                                                                                                                                                           |
    | subnets                   |                                                                                                                                                                  |
    | tags                      |                                                                                                                                                                  |
    | updated_at                | 2020-05-16T13:33:53Z                                                                                                                                             |
    +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+