ソースを参照

Always bring up OVS bridges

Linux bridges are automatically set UP when
any parent interface is UP.

But for OVS bridges it doesn't work.

For dpdk and non-dpdk bridges, always create a
config file in /etc/network/interfaces.u/ and
bring the bridge interface up after it is configured,
even if it doesn't have IP address.

Change-Id: I92888ce0d373e412dfb7ed2e2398c0d4d008e301
Closes-Bug: https://mirantis.jira.com/browse/PROD-24343
pull/171/head
Dennis Dmitriev 6年前
コミット
f4d2d7ddce
3個のファイルの変更84行の追加52行の削除
  1. +14
    -0
      linux/files/ovs_bridge
  2. +0
    -31
      linux/network/dpdk.sls
  3. +70
    -21
      linux/network/interface.sls

+ 14
- 0
linux/files/ovs_bridge ファイルの表示

auto {{ bridge_name }}
iface {{ bridge_name }} inet {{ bridge.get('proto', 'static' if bridge.address is defined else 'manual') }}
ovs_type {{ bridge.get('ovs_bridge_type', 'OVSBridge') }}
mtu {{ bridge.get('mtu', '1500') }}
{%- if bridge.address is defined %}
address {{ bridge.address }}
netmask {{ bridge.netmask }}
{%- endif %}
{%- if bridge.gateway is defined %}
gateway {{ bridge.gateway }}
{%- endif %}
{%- if bridge.ovs_options is defined %}
ovs_options {{ bridge.ovs_options }}
{%- endif %}

+ 0
- 31
linux/network/dpdk.sls ファイルの表示

- name: "ovs-vsctl{%- if network.ovs_nowait %} --no-wait{%- endif %} add-br {{ interface_name }} -- set bridge {{ interface_name }} datapath_type=netdev{% if interface.tag is defined %} -- set port {{ interface_name }} tag={{ interface.tag }}{% endif %}" - name: "ovs-vsctl{%- if network.ovs_nowait %} --no-wait{%- endif %} add-br {{ interface_name }} -- set bridge {{ interface_name }} datapath_type=netdev{% if interface.tag is defined %} -- set port {{ interface_name }} tag={{ interface.tag }}{% endif %}"
- unless: "ovs-vsctl show | grep {{ interface_name }}" - unless: "ovs-vsctl show | grep {{ interface_name }}"


{# OVS dpdk needs ip address for vxlan termination on bridge br-prv #}
{%- if interface.address is defined %}

{# create override for openvswitch dependency for dpdk br-prv #}
/etc/systemd/system/ifup@{{ interface_name }}.service.d/override.conf:
file.managed:
- makedirs: true
- require:
- cmd: linux_network_dpdk_bridge_interface_{{ interface_name }}
- contents: |
[Unit]
Requires=openvswitch-switch.service
After=openvswitch-switch.service

{# enforce ip address and mtu for ovs dpdk br-prv #}
/etc/network/interfaces.u/ifcfg-{{ interface_name }}:
file.managed:
- contents: |
auto {{ interface_name }}
iface {{ interface_name }} inet static
address {{ interface.address }}
netmask {{ interface.netmask }}
{%- if interface.mtu is defined %}
mtu {{ interface.mtu }}
{%- endif %}
- makedirs: True
- require:
- file: /etc/systemd/system/ifup@{{ interface_name }}.service.d/override.conf

{%- endif %}

{%- elif interface.type == 'dpdk_ovs_port' and interface.bridge is defined %} {%- elif interface.type == 'dpdk_ovs_port' and interface.bridge is defined %}


linux_network_dpdk_bridge_port_interface_{{ interface_name }}: linux_network_dpdk_bridge_port_interface_{{ interface_name }}:

+ 70
- 21
linux/network/interface.sls ファイルの表示

cmd.run: cmd.run:
- unless: ovs-vsctl show | grep -w {{ int_name }} - unless: ovs-vsctl show | grep -w {{ int_name }}
- name: ovs-vsctl{%- if network.ovs_nowait %} --no-wait{%- endif %} add-port {{ interface_name }} {{ int_name }} - name: ovs-vsctl{%- if network.ovs_nowait %} --no-wait{%- endif %} add-port {{ interface_name }} {{ int_name }}

{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}

linux_interfaces_include_{{ interface_name }}:
file.prepend:
- name: /etc/network/interfaces
- text: |
source /etc/network/interfaces.d/*
# Workaround for Upstream-Bug: https://github.com/saltstack/salt/issues/40262
source /etc/network/interfaces.u/*

{# create override for openvswitch dependency for dpdk br-prv #}
/etc/systemd/system/ifup@{{ interface_name }}.service.d/override.conf:
file.managed:
- makedirs: true
- require:
- cmd: linux_network_dpdk_bridge_interface_{{ interface_name }}
- contents: |
[Unit]
Requires=openvswitch-switch.service
After=openvswitch-switch.service

dpdk_ovs_bridge_{{ interface_name }}:
file.managed:
- name: /etc/network/interfaces.u/ifcfg-{{ interface_name }}
- makedirs: True
- source: salt://linux/files/ovs_bridge
- defaults:
bridge: {{ interface|yaml }}
bridge_name: {{ interface_name }}
- template: jinja

dpdk_ovs_bridge_up_{{ interface_name }}:
cmd.run:
- name: ifup {{ interface_name }}
- require:
- file: dpdk_ovs_bridge_{{ interface_name }}
- file: linux_interfaces_final_include

{%- endif %} {%- endif %}


{# it is not used for any interface with type preffix dpdk,eg. dpdk_ovs_port #} {# it is not used for any interface with type preffix dpdk,eg. dpdk_ovs_port #}


{%- if interface.type == 'ovs_bridge' %} {%- if interface.type == 'ovs_bridge' %}


ovs_bridge_{{ interface_name }}:
ovs_bridge_{{ interface_name }}_present:
openvswitch_bridge.present: openvswitch_bridge.present:
- name: {{ interface_name }} - name: {{ interface_name }}


cmd.run: cmd.run:
- unless: ovs-vsctl show | grep {{ int_name }} - unless: ovs-vsctl show | grep {{ int_name }}
- name: ovs-vsctl{%- if network.ovs_nowait %} --no-wait{%- endif %} add-port {{ interface_name }} {{ int_name }} - name: ovs-vsctl{%- if network.ovs_nowait %} --no-wait{%- endif %} add-port {{ interface_name }} {{ int_name }}

{%- endif %} {%- endif %}

{%- endfor %} {%- endfor %}


linux_interfaces_include_{{ interface_name }}:
file.prepend:
- name: /etc/network/interfaces
- text: |
source /etc/network/interfaces.d/*
# Workaround for Upstream-Bug: https://github.com/saltstack/salt/issues/40262
source /etc/network/interfaces.u/*

ovs_bridge_{{ interface_name }}:
file.managed:
- name: /etc/network/interfaces.u/ifcfg-{{ interface_name }}
- makedirs: True
- source: salt://linux/files/ovs_bridge
- defaults:
bridge: {{ interface|yaml }}
bridge_name: {{ interface_name }}
- template: jinja

ovs_bridge_up_{{ interface_name }}:
cmd.run:
- name: ifup {{ interface_name }}
- require:
- file: ovs_bridge_{{ interface_name }}
- file: linux_interfaces_final_include



{%- elif interface.type == 'ovs_port' %} {%- elif interface.type == 'ovs_port' %}


{%- if interface.get('port_type','internal') == 'patch' %} {%- if interface.get('port_type','internal') == 'patch' %}


ovs_port_{{ interface_name }}:
ovs_port_{{ interface_name }}_present:
openvswitch_port.present: openvswitch_port.present:
- name: {{ interface_name }} - name: {{ interface_name }}
- bridge: {{ interface.bridge }} - bridge: {{ interface.bridge }}
{%- if dpdk_enabled and network.interface.get(interface.bridge, {}).get('type', 'ovs_bridge') == 'dpdk_ovs_bridge' %} {%- if dpdk_enabled and network.interface.get(interface.bridge, {}).get('type', 'ovs_bridge') == 'dpdk_ovs_bridge' %}
- cmd: linux_network_dpdk_bridge_interface_{{ interface.bridge }} - cmd: linux_network_dpdk_bridge_interface_{{ interface.bridge }}
{%- else %} {%- else %}
- openvswitch_bridge: ovs_bridge_{{ interface.bridge }}
- openvswitch_bridge: ovs_bridge_{{ interface.bridge }}_present
{%- endif %} {%- endif %}


ovs_port_set_type_{{ interface_name }}: ovs_port_set_type_{{ interface_name }}:
- defaults: - defaults:
port: {{ interface|yaml }} port: {{ interface|yaml }}
port_name: {{ interface_name }} port_name: {{ interface_name }}
auto: ""
iface_inet: ""
- template: jinja - template: jinja


ovs_port_{{ interface_name }}_line1:
file.replace:
- name: /etc/network/interfaces
- pattern: auto {{ interface_name }}$
- repl: ""

ovs_port_{{ interface_name }}_line2:
file.replace:
- name: /etc/network/interfaces
- pattern: 'iface {{ interface_name }} inet .*'
- repl: ""

ovs_port_up_{{ interface_name }}: ovs_port_up_{{ interface_name }}:
cmd.run: cmd.run:
- name: ifup {{ interface_name }} - name: ifup {{ interface_name }}
- require: - require:
- file: ovs_port_{{ interface_name }} - file: ovs_port_{{ interface_name }}
- file: ovs_port_{{ interface_name }}_line1
- file: ovs_port_{{ interface_name }}_line2
- openvswitch_bridge: ovs_bridge_{{ interface.bridge }}
- openvswitch_bridge: ovs_bridge_{{ interface.bridge }}_present
- file: linux_interfaces_final_include - file: linux_interfaces_final_include


{%- endif %} {%- endif %}

読み込み中…
キャンセル
保存