1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2018 Mirantis Inc., Enea AB and others.
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
13 Change-Id: I1e83129cc184cf481bea21d7aa452bf60d9e0499
15 diff --git a/linux/files/ovs_bridge b/linux/files/ovs_bridge
17 index 0000000..8c0f468
19 +++ b/linux/files/ovs_bridge
21 +auto {{ bridge_name }}
22 +allow-ovs {{ bridge_name }}
23 +iface {{ bridge_name }} inet {{ bridge.get('proto', 'manual') }}
25 + {%- if bridge.get('proto', 'manual') == 'static' %}
26 + address {{ bridge.address }}
27 + netmask {{ bridge.netmask }}
29 + {%- if bridge.gateway is defined %}
30 + gateway {{ bridge.gateway }}
32 + {%- if bridge.ovs_options is defined %}
33 + ovs_options {{ bridge.ovs_options }}
35 diff --git a/linux/files/ovs_port b/linux/files/ovs_port
36 index 222ca8e..efb0307 100644
37 --- a/linux/files/ovs_port
38 +++ b/linux/files/ovs_port
41 allow-{{ port.bridge }} {{ port_name }}
42 iface {{ port_name }} inet {{ port.get('proto', 'manual') }}
43 +{%- if '.' in port_name %}
44 +vlan-raw-device {{ port_name.split('.')[0] }}
46 ovs_type {{ port.get('ovs_port_type', 'OVSIntPort') }}
47 mtu {{ port.get('mtu', '1500') }}
48 ovs_bridge {{ port.bridge }}
49 diff --git a/linux/network/interface.sls b/linux/network/interface.sls
50 index 7375b04..bbf2fa0 100644
51 --- a/linux/network/interface.sls
52 +++ b/linux/network/interface.sls
53 @@ -67,6 +67,32 @@ remove_cloud_init_file:
54 ovs_bridge_{{ interface_name }}:
55 openvswitch_bridge.present:
56 - name: {{ interface_name }}
58 + - name: /etc/network/interfaces.u/ifcfg-{{ interface_name }}
60 + - source: salt://linux/files/ovs_bridge
62 + bridge: {{ interface|yaml }}
63 + bridge_name: {{ interface_name }}
66 +linux_interfaces_include_{{ interface_name }}:
68 + - name: /etc/network/interfaces
70 + source /etc/network/interfaces.d/*
71 + # Workaround for Upstream-Bug: https://github.com/saltstack/salt/issues/40262
72 + source /etc/network/interfaces.u/*
74 +ovs_bridge_up_{{ interface_name }}:
76 + - name: ifup {{ interface_name }}
78 + - file: ovs_bridge_{{ interface_name }}
79 + - openvswitch_bridge: ovs_bridge_{{ interface_name }}
80 + - file: linux_interfaces_final_include
82 + - ip link show {{ interface_name }} | grep -q '\<UP\>'
84 {# add linux network interface into OVS bridge #}
85 {%- for int_name, int in network.interface.items() %}