[MaaS] Adopt boot-resources control from maasng
[fuel.git] / mcp / patches / 0015-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 diff --git a/linux/files/ovs_bridge b/linux/files/ovs_bridge
16 new file mode 100644
17 index 0000000..c609e45
18 --- /dev/null
19 +++ b/linux/files/ovs_bridge
20 @@ -0,0 +1,19 @@
21 +auto {{ bridge_name }}
22 +allow-ovs {{ bridge_name }}
23 +iface {{ bridge_name }} inet static
24 +  ovs_type OVSBridge
25 +  address {{ bridge.address }}
26 +  netmask {{ bridge.netmask }}
27 +  mtu {{ bridge.get('mtu', '1500') }}
28 +  {%- if bridge.use_interfaces is defined %}
29 +  ovs_ports {{ bridge.use_interfaces|join(' ') }}
30 +  {%- endif %}
31 +  {%- if bridge.datapath_type is defined %}
32 +  ovs_extra set Bridge ${IFACE} datapath_type={{ bridge.datapath_type }}
33 +  {%- endif %}
34 +  {%- if bridge.gateway is defined %}
35 +  gateway {{ bridge.gateway }}
36 +  {%- endif %}
37 +  {%- if bridge.name_servers is defined %}
38 +  dns-nameservers {{ bridge.name_servers | join(' ') }}
39 +  {%- endif %}
40 diff --git a/linux/files/ovs_port b/linux/files/ovs_port
41 index 222ca8e..efb0307 100644
42 --- a/linux/files/ovs_port
43 +++ b/linux/files/ovs_port
44 @@ -1,6 +1,11 @@
45 +# With systemd, adding OVS bridges as 'auto' can cause race conditions
46 +# https://github.com/openvswitch/ovs/blob/master/debian/openvswitch-switch.README.Debian
47 +# auto {{ port_name }}
48 -auto {{ port_name }}
49  allow-{{ port.bridge }} {{ port_name }}
50  iface {{ port_name }} inet {{ port.get('proto', 'manual') }}
51 +{%- if '.' in port_name %}
52 +vlan-raw-device {{ port_name.split('.')[0] }}
53 +{%- endif %}
54  ovs_type {{ port.get('ovs_port_type', 'OVSIntPort') }}
55  mtu {{ port.get('mtu', '1500') }}
56  ovs_bridge {{ port.bridge }}
57 diff --git a/linux/network/interface.sls b/linux/network/interface.sls
58 index 180f912..dcb295b 100644
59 --- a/linux/network/interface.sls
60 +++ b/linux/network/interface.sls
61 @@ -91,6 +91,34 @@ add_int_{{ int_name }}_to_ovs_dpdk_bridge_{{ interface_name }}:
62  ovs_bridge_{{ interface_name }}:
63    openvswitch_bridge.present:
64    - name: {{ interface_name }}
65 +{%- if interface.get('proto', 'manual') == 'static' %}
66 +  file.managed:
67 +  - name: /etc/network/interfaces.u/ifcfg-{{ interface_name }}
68 +  - makedirs: True
69 +  - source: salt://linux/files/ovs_bridge
70 +  - defaults:
71 +      bridge: {{ interface|yaml }}
72 +      bridge_name: {{ interface_name }}
73 +  - template: jinja
74 +
75 +linux_interfaces_include_{{ interface_name }}:
76 +  file.prepend:
77 +  - name: /etc/network/interfaces
78 +  - text: |
79 +      source /etc/network/interfaces.d/*
80 +      # Workaround for Upstream-Bug: https://github.com/saltstack/salt/issues/40262
81 +      source /etc/network/interfaces.u/*
82 +
83 +ovs_bridge_up_{{ interface_name }}:
84 +  cmd.run:
85 +  - name: ifup {{ interface_name }}
86 +  - require:
87 +    - file: ovs_bridge_{{ interface_name }}
88 +    - openvswitch_bridge: ovs_bridge_{{ interface_name }}
89 +    - file: linux_interfaces_final_include
90 +  - unless:
91 +    - ip link show {{ interface_name }} | grep -q '\<UP\>'
92 +{%- endif %}
93
94  {# add linux network interface into OVS bridge #}
95  {%- for int_name, int in network.interface.items() %}