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

address {{ port.address }} address {{ port.address }}
netmask {{ port.netmask }} netmask {{ port.netmask }}
{%- endif %} {%- endif %}
{%- if port.gateway is defined %}
gateway {{ port.gateway }}
{%- endif %}
{%- if port.ovs_options is defined %} {%- if port.ovs_options is defined %}
ovs_options {{ port.ovs_options }} ovs_options {{ port.ovs_options }}
{%- endif %} {%- endif %}

+ 4
- 0
linux/map.jinja View File

'broadcast', 'broadcast',
'master', 'master',
'miimon', 'miimon',
'ovs_ports',
'ovs_bridge',
'mode', 'mode',
'port_type',
'peer',
'lacp-rate', 'lacp-rate',
'dns-search', 'dns-search',
'up_cmds', 'up_cmds',

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

openvswitch_bridge.present: openvswitch_bridge.present:
- name: {{ interface_name }} - 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' %} {%- elif interface.type == 'ovs_port' %}


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

ovs_port_{{ interface_name }}: ovs_port_{{ interface_name }}:
openvswitch_port.present: openvswitch_port.present:
- name: {{ interface_name }} - name: {{ interface_name }}
- bridge: {{ interface.bridge }} - bridge: {{ interface.bridge }}
- require: - require:
- openvswitch_bridge: ovs_bridge_{{ interface.bridge }} - 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: file.prepend:
- name: /etc/network/interfaces - name: /etc/network/interfaces
- text: 'source /etc/network/interfaces.d/*' - text: 'source /etc/network/interfaces.d/*'
ovs_port_{{ interface_name }}_line2: ovs_port_{{ interface_name }}_line2:
file.replace: file.replace:
- name: /etc/network/interfaces - name: /etc/network/interfaces
- pattern: iface {{ interface_name }} inet manual
- pattern: 'iface {{ interface_name }} inet .*'
- repl: "" - repl: ""


ovs_port_up_{{ interface_name }}: ovs_port_up_{{ interface_name }}:
- file: ovs_port_{{ interface_name }}_line2 - file: ovs_port_{{ interface_name }}_line2
- openvswitch_bridge: ovs_bridge_{{ interface.bridge }} - openvswitch_bridge: ovs_bridge_{{ interface.bridge }}


{%- endif %}

{%- else %} {%- else %}


linux_interface_{{ interface_name }}: linux_interface_{{ interface_name }}:

Loading…
Cancel
Save