Add logrotate meta configuration for Openvswitch

	- parametrize interval and rotate
	- parametrize also for atop
	- optimize conditions

Related: PROD-29848

Change-Id: Ic3c6d7740797b7de5c16545dc4449785913d2613
diff --git a/linux/meta/logrotate.yml b/linux/meta/logrotate.yml
index cd980f7..08e9040 100644
--- a/linux/meta/logrotate.yml
+++ b/linux/meta/logrotate.yml
@@ -1,7 +1,15 @@
-{%- from "linux/map.jinja" import system with context -%}
+{%- from "linux/map.jinja" import system, network with context -%}
 
-{%- if system.atop.enabled %}
+{%- if system.get('enabled', False) and system.get('atop', {}).get('enabled', False) %}
+{%- set atop_enabled = True %}
+{%- endif %}
+{%- if network.get('enabled', False) and network.bridge == 'openvswitch' %}
+{%- set ovs_enabled = True %}
+{%- endif %}
+
+{%- if atop_enabled|default(False) or ovs_enabled|default(False) %}
 job:
+{%- if atop_enabled|default(False) %}
   atop:
     - files:
         - {{ system.atop.logpath }}/atop*
@@ -12,9 +20,23 @@
         - delaycompress
         - missingok
         - notifempty
-        - rotate: 10
-        - daily
+        - rotate: {{ system.atop.get('logrotate', {}).get('rotate', 10)}}
+        - {{ system.atop.get('logrotate', {}).get('interval', 'daily')}}
         - minsize: 20M
         - maxsize: 500M
         - postrotate: "if ! service atop status > /dev/null; then service atop restart > /dev/null; fi"
 {%- endif %}
+{%- if ovs_enabled|default(False) %}
+  openvswitch-switch:
+    - files:
+        - /var/log/openvswitch/*.log
+      options:
+        - {{ network.get('openvswitch', {}).get('logrotate', {}).get('interval', 'daily') }}
+        - rotate: {{ network.get('openvswitch', {}).get('logrotate', {}).get('rotate', 30) }}
+        - compress
+        - sharedscripts
+        - create 640 root adm
+        - missingok
+        - postrotate: if [ -d /var/run/openvswitch ]; then for pidfile in `cd /var/run/openvswitch && echo *.pid`; do ovs-appctl -t "${pidfile%%.pid}" vlog/reopen 2>/dev/null || :; done; fi
+{%- endif %}
+{%- endif %}