Browse Source

OVS improvements

tags/mcp0.5
Jakub Pavlik 8 years ago
parent
commit
fc60eb0668
3 changed files with 41 additions and 4 deletions
  1. +3
    -0
      linux/files/ovs_port
  2. +4
    -0
      linux/map.jinja
  3. +34
    -4
      linux/network/interface.sls

+ 3
- 0
linux/files/ovs_port View File

@@ -8,6 +8,9 @@ ovs_bridge {{ port.bridge }}
address {{ port.address }}
netmask {{ port.netmask }}
{%- endif %}
{%- if port.gateway is defined %}
gateway {{ port.gateway }}
{%- endif %}
{%- if port.ovs_options is defined %}
ovs_options {{ port.ovs_options }}
{%- endif %}

+ 4
- 0
linux/map.jinja View File

@@ -55,7 +55,11 @@
'broadcast',
'master',
'miimon',
'ovs_ports',
'ovs_bridge',
'mode',
'port_type',
'peer',
'lacp-rate',
'dns-search',
'up_cmds',

+ 34
- 4
linux/network/interface.sls View File

@@ -34,18 +34,46 @@ ovs_bridge_{{ interface_name }}:
openvswitch_bridge.present:
- name: {{ interface_name }}

{# add linux network interface into OVS bridge #}
{%- for int_name, int in network.interface.iteritems() %}

{%- set int_name = int.get('name', int_name) %}

{%- if int.ovs_bridge is defined %}

add_int_to_ovs_bridge_{{ interface_name }}:
cmd.run:
- unless: ovs-vsctl show | grep {{ int_name }}
- name: ovs-vsctl add-port {{ interface_name }} {{ int_name }}

{%- endif %}

{%- endfor %}

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

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

ovs_port_{{ interface_name }}:
openvswitch_port.present:
- name: {{ interface_name }}
- bridge: {{ interface.bridge }}
- require:
- openvswitch_bridge: ovs_bridge_{{ interface.bridge }}
#}

linux_interfaces_include:
ovs_port_set_type_{{ interface_name }}:
cmd.run:
- name: ovs-vsctl set interface {{ interface_name }} type=patch
- unless: ovs-vsctl show | grep -A 1 'Interface {{ interface_name }}' | grep patch

ovs_port_set_peer_{{ interface_name }}:
cmd.run:
- name: ovs-vsctl set interface {{ interface_name }} options:peer={{ interface.peer }}
- unless: ovs-vsctl show | grep -A 2 'Interface floating-to-prv' | grep {{ interface.peer }}

{%- else %}

linux_interfaces_include_{{ interface_name }}:
file.prepend:
- name: /etc/network/interfaces
- text: 'source /etc/network/interfaces.d/*'
@@ -68,7 +96,7 @@ ovs_port_{{ interface_name }}_line1:
ovs_port_{{ interface_name }}_line2:
file.replace:
- name: /etc/network/interfaces
- pattern: iface {{ interface_name }} inet manual
- pattern: 'iface {{ interface_name }} inet .*'
- repl: ""

ovs_port_up_{{ interface_name }}:
@@ -80,6 +108,8 @@ ovs_port_up_{{ interface_name }}:
- file: ovs_port_{{ interface_name }}_line2
- openvswitch_bridge: ovs_bridge_{{ interface.bridge }}

{%- endif %}

{%- else %}

linux_interface_{{ interface_name }}:

Loading…
Cancel
Save