Adding ability to configure OVS logging
The patch adds ability to configure variety logging options
for OVS. In order to configure OVS log options the below pillar
sctructure should be used:
linux:
network:
openvswitch:
enabled: true
logging:
enabled: true
ovsdb:
console: emer
syslog: err
file: info
facility: local0
vswitchd:
console: emer
syslog: err
file: info
facility: local1
Change-Id: I59ef0636447a974215d872259a26beb858495cfb
Related-PROD: PROD-19980
diff --git a/linux/files/openvswitch-switch.default b/linux/files/openvswitch-switch.default
new file mode 100644
index 0000000..06c769d
--- /dev/null
+++ b/linux/files/openvswitch-switch.default
@@ -0,0 +1,44 @@
+{%- from "linux/map.jinja" import network with context %}
+{%- set openvswitch = network.openvswitch %}
+# This is a POSIX shell fragment -*- sh -*-
+
+# FORCE_COREFILES: If 'yes' then core files will be enabled.
+# FORCE_COREFILES=yes
+
+# OVS_CTL_OPTS: Extra options to pass to ovs-ctl. This is, for example,
+# a suitable place to specify --ovs-vswitchd-wrapper=valgrind.
+# OVS_CTL_OPTS=
+
+# OVS_VSWITCHD_OPTS: Extra options to pass to ovs-ctl.
+# Options to start Open vSwitch daemon with.
+# Example: '-vconsole:dbg -vsyslog:dbg -vfile:dbg -vFACILITY:clock2'
+# OVS_VSWITCHD_OPTS=
+{%- if openvswitch.get('logging', {}).vswitchd is defined %}
+ {%- set _vswitchd_opts = [] %}
+ {%- for opt in ['console', 'file', 'syslog'] %}
+ {%- if openvswitch.logging.vswitchd.get(opt) %}
+ {%- do _vswitchd_opts.append("-v"+ opt + ":" + openvswitch.logging.vswitchd.get(opt)) %}
+ {%- endif %}
+ {%- endfor %}
+ {%- if openvswitch.logging.vswitchd.facility is defined %}
+ {%- do _vswitchd_opts.append("-vFACILITY:" + openvswitch.logging.vswitchd.facility) %}
+ {%- endif %}
+OVS_VSWITCHD_OPTS="{{ ' '.join(_vswitchd_opts) }}"
+{%- endif %}
+
+# OVSDB_OPTS: Extra options to pass to ovs-ctl.
+# Options to start Open vSwitch DB daemon with.
+# Example: '-vconsole:dbg -vsyslog:dbg -vfile:dbg -vFACILITY:clock2'
+# OVSDB_OPTS=
+{%- if openvswitch.get('logging', {}).ovsdb is defined %}
+ {%- set _ovsdb_opts = [] %}
+ {%- for opt in ['console', 'file', 'syslog'] %}
+ {%- if openvswitch.logging.ovsdb.get(opt) %}
+ {%- do _ovsdb_opts.append("-v" + opt + ":" + openvswitch.logging.ovsdb.get(opt)) %}
+ {%- endif %}
+ {%- endfor %}
+ {%- if openvswitch.logging.ovsdb.facility is defined %}
+ {%- do _ovsdb_opts.append("-vFACILITY:" + openvswitch.logging.ovsdb.facility) %}
+ {%- endif %}
+OVSDB_OPTS="{{ ' '.join(_ovsdb_opts) }}"
+{%- endif %}
diff --git a/linux/network/init.sls b/linux/network/init.sls
index 56b05a5..8a7d458 100644
--- a/linux/network/init.sls
+++ b/linux/network/init.sls
@@ -16,6 +16,9 @@
{%- if network.systemd|length > 0 %}
- linux.network.systemd
{%- endif %}
+{%- if network.openvswitch is defined %}
+- linux.network.openvswitch
+{%- endif %}
{%- if network.interface|length > 0 %}
- linux.network.interface
{%- endif %}
diff --git a/linux/network/openvswitch.sls b/linux/network/openvswitch.sls
new file mode 100644
index 0000000..474a84c
--- /dev/null
+++ b/linux/network/openvswitch.sls
@@ -0,0 +1,26 @@
+{%- from "linux/map.jinja" import network with context %}
+
+{%- if network.get('openvswitch', {}).get('enabled', False) %}
+
+openvswitch_pkgs:
+ pkg.installed:
+ - pkgs: {{ network.ovs_pkgs }}
+
+/etc/default/openvswitch-switch:
+ file.managed:
+ - source: salt://linux/files/openvswitch-switch.default
+ - template: jinja
+ - require:
+ - pkg: openvswitch_pkgs
+
+openvswitch_switch_service:
+ service.running:
+ - name: openvswitch-switch
+ - enable: true
+ {%- if grains.get('noservices') %}
+ - onlyif: /bin/false
+ {%- endif %}
+ - watch:
+ - file: /etc/default/openvswitch-switch
+
+{%- endif %}