Add noifupdown for all br-floating
[fuel.git] / mcp / patches / salt-formula-linux / 0002-Set-ovs-bridges-as-L3-interfaces.patch
1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2018 Mirantis Inc., Enea AB and others.
3 :
4 : All rights reserved. This program and the accompanying materials
5 : are made available under the terms of the Apache License, Version 2.0
6 : which accompanies this distribution, and is available at
7 : http://www.apache.org/licenses/LICENSE-2.0
8 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
9 From: Michael Polenchuk <mpolenchuk@mirantis.com>
10 Date: Wed, 28 Feb 2018 17:54:28 +0400
11 Subject: [PATCH] Set ovs bridges as L3 interfaces
12
13 Change-Id: I1e83129cc184cf481bea21d7aa452bf60d9e0499
14 ---
15  linux/files/ovs_bridge      | 19 +++++++++++++++++++
16  linux/files/ovs_port        |  7 ++++++-
17  linux/network/interface.sls | 28 ++++++++++++++++++++++++++++
18  3 files changed, 53 insertions(+), 1 deletion(-)
19  create mode 100644 linux/files/ovs_bridge
20
21 diff --git a/linux/files/ovs_bridge b/linux/files/ovs_bridge
22 new file mode 100644
23 index 0000000..073c91c
24 --- /dev/null
25 +++ b/linux/files/ovs_bridge
26 @@ -0,0 +1,19 @@
27 +auto {{ bridge_name }}
28 +allow-ovs {{ bridge_name }}
29 +iface {{ bridge_name }} inet static
30 +  ovs_type OVSBridge
31 +  address {{ bridge.address }}
32 +  netmask {{ bridge.netmask }}
33 +  mtu {{ bridge.get('mtu', '1500') }}
34 +  {%- if bridge.use_interfaces is defined %}
35 +  ovs_ports {{ bridge.use_interfaces|join(' ') }}
36 +  {%- endif %}
37 +  {%- if bridge.datapath_type is defined %}
38 +  ovs_extra set Bridge ${IFACE} datapath_type={{ bridge.datapath_type }}
39 +  {%- endif %}
40 +  {%- if bridge.gateway is defined %}
41 +  gateway {{ bridge.gateway }}
42 +  {%- endif %}
43 +  {%- if bridge.name_servers is defined %}
44 +  dns-nameservers {{ bridge.name_servers | join(' ') }}
45 +  {%- endif %}
46 diff --git a/linux/files/ovs_port b/linux/files/ovs_port
47 index 222ca8e..03072cd 100644
48 --- a/linux/files/ovs_port
49 +++ b/linux/files/ovs_port
50 @@ -1,6 +1,11 @@
51 -auto {{ port_name }}
52 +# With systemd, adding OVS bridges as 'auto' can cause race conditions
53 +# https://github.com/openvswitch/ovs/blob/master/debian/openvswitch-switch.README.Debian
54 +# auto {{ port_name }}
55  allow-{{ port.bridge }} {{ port_name }}
56  iface {{ port_name }} inet {{ port.get('proto', 'manual') }}
57 +{%- if '.' in port_name %}
58 +vlan-raw-device {{ port_name.split('.')[0] }}
59 +{%- endif %}
60  ovs_type {{ port.get('ovs_port_type', 'OVSIntPort') }}
61  mtu {{ port.get('mtu', '1500') }}
62  ovs_bridge {{ port.bridge }}
63 diff --git a/linux/network/interface.sls b/linux/network/interface.sls
64 index c2d2a23..7efdc80 100644
65 --- a/linux/network/interface.sls
66 +++ b/linux/network/interface.sls
67 @@ -91,6 +91,34 @@ add_int_{{ int_name }}_to_ovs_dpdk_bridge_{{ interface_name }}:
68  ovs_bridge_{{ interface_name }}:
69    openvswitch_bridge.present:
70    - name: {{ interface_name }}
71 +{%- if interface.get('proto', 'manual') == 'static' %}
72 +  file.managed:
73 +  - name: /etc/network/interfaces.u/ifcfg-{{ interface_name }}
74 +  - makedirs: True
75 +  - source: salt://linux/files/ovs_bridge
76 +  - defaults:
77 +      bridge: {{ interface|yaml }}
78 +      bridge_name: {{ interface_name }}
79 +  - template: jinja
80 +
81 +linux_interfaces_include_{{ interface_name }}:
82 +  file.prepend:
83 +  - name: /etc/network/interfaces
84 +  - text: |
85 +      source /etc/network/interfaces.d/*
86 +      # Workaround for Upstream-Bug: https://github.com/saltstack/salt/issues/40262
87 +      source /etc/network/interfaces.u/*
88 +
89 +ovs_bridge_up_{{ interface_name }}:
90 +  cmd.run:
91 +  - name: ifup --ignore-errors {{ interface_name }}
92 +  - require:
93 +    - file: ovs_bridge_{{ interface_name }}
94 +    - openvswitch_bridge: ovs_bridge_{{ interface_name }}
95 +    - file: linux_interfaces_final_include
96 +  - unless:
97 +    - ip link show {{ interface_name }} | grep -q '\<UP\>'
98 +{%- endif %}
99
100  {# add linux network interface into OVS bridge #}
101  {%- for int_name, int in network.interface.items() %}