Merge remote-tracking branch 'upstream/master' into merge-branch

Change-Id: If7690fd215012ed2252528ec99a66eaff193928a
diff --git a/metadata/service/compute/cluster.yml b/metadata/service/compute/cluster.yml
new file mode 100644
index 0000000..05ca1bc
--- /dev/null
+++ b/metadata/service/compute/cluster.yml
@@ -0,0 +1,17 @@
+applications:
+- opencontrail
+classes:
+- service.opencontrail.support
+parameters:
+  _param:
+    opencontrail_version: 2.2
+  opencontrail:
+    compute:
+      version: ${_param:opencontrail_version}
+      enabled: true
+  nova:
+    compute:
+      networking: contrail
+  neutron:
+    switch:
+      enabled: false
diff --git a/metadata/service/compute/single.yml b/metadata/service/compute/single.yml
new file mode 100644
index 0000000..05ca1bc
--- /dev/null
+++ b/metadata/service/compute/single.yml
@@ -0,0 +1,17 @@
+applications:
+- opencontrail
+classes:
+- service.opencontrail.support
+parameters:
+  _param:
+    opencontrail_version: 2.2
+  opencontrail:
+    compute:
+      version: ${_param:opencontrail_version}
+      enabled: true
+  nova:
+    compute:
+      networking: contrail
+  neutron:
+    switch:
+      enabled: false
diff --git a/metadata/service/support.yml b/metadata/service/support.yml
index 83734c0..caa7736 100644
--- a/metadata/service/support.yml
+++ b/metadata/service/support.yml
@@ -2,12 +2,12 @@
   opencontrail:
     _support:
       collectd:
-        enabled: false
+        enabled: true
       heka:
-        enabled: false
+        enabled: true
       sensu:
         enabled: true
       sphinx:
         enabled: true
       config:
-        enabled: true
\ No newline at end of file
+        enabled: true
diff --git a/opencontrail/client.sls b/opencontrail/client.sls
index af6e339..bece6f1 100644
--- a/opencontrail/client.sls
+++ b/opencontrail/client.sls
@@ -1,5 +1,5 @@
 {%- from "opencontrail/map.jinja" import client with context %}
-{%- if client.enabled %}
+{%- if client.get('enabled', False) %}
 
 opencontrail_client_packages:
   pkg.installed:
diff --git a/opencontrail/common.sls b/opencontrail/common.sls
index 2143766..1ff96cc 100644
--- a/opencontrail/common.sls
+++ b/opencontrail/common.sls
@@ -14,6 +14,7 @@
   service.dead:
   - enable: false
   - name: iptables
+  - onlyif: service iptables status
 
 net.ipv4.ip_forward:
   sysctl.present:
diff --git a/opencontrail/database.sls b/opencontrail/database.sls
index 9640d9f..7c9e7cc 100644
--- a/opencontrail/database.sls
+++ b/opencontrail/database.sls
@@ -37,6 +37,16 @@
     - pkg: opencontrail_database_packages
 {% endif %}
 
+{{ database.cassandra_config }}logback.xml:
+  file.managed:
+  - source: salt://opencontrail/files/{{ database.version }}/database/logback.xml
+  - template: jinja
+  - makedirs: True
+{% if grains.os_family == "RedHat" %}
+  - require:
+    - pkg: opencontrail_database_packages
+{% endif %}
+
 {{ database.cassandra_config }}cassandra-env.sh:
   file.managed:
   - source: salt://opencontrail/files/{{ database.version }}/database/cassandra-env.sh
@@ -56,6 +66,7 @@
   - require:
     - file: {{ database.cassandra_config }}cassandra.yaml
     - file: {{ database.cassandra_config }}cassandra-env.sh
+    - file: {{ database.cassandra_config }}logback.xml
 {% endif %}
 
 /etc/zookeeper/conf/log4j.properties:
@@ -124,6 +135,7 @@
   - watch: 
     - file: {{ database.cassandra_config }}cassandra.yaml
     - file: {{ database.cassandra_config }}cassandra-env.sh
+    - file: {{ database.cassandra_config }}logback.xml
     - file: /etc/zookeeper/conf/zoo.cfg
     - file: /etc/contrail/contrail-database-nodemgr.conf
     - file: /var/lib/zookeeper/myid
diff --git a/opencontrail/files/2.2/config/log4j.properties b/opencontrail/files/2.2/config/log4j.properties
index 6c55393..8a1fa76 100644
--- a/opencontrail/files/2.2/config/log4j.properties
+++ b/opencontrail/files/2.2/config/log4j.properties
@@ -8,19 +8,19 @@
 
 log4j.appender.A1=org.apache.log4j.ConsoleAppender
 log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %x - %m%n
+log4j.appender.A1.layout.ConversionPattern=%d - %-5p - [%t] %x - %m%n
 
 log4j.appender.A2=org.apache.log4j.FileAppender
 log4j.appender.A2.File=/var/log/contrail/ifmap-server.log
 log4j.appender.A2.layout=org.apache.log4j.PatternLayout
-log4j.appender.A2.layout.ConversionPattern=%d [%t] %-5p %x - %m%n
+log4j.appender.A2.layout.ConversionPattern=%d - %-5p - [%t] %x - %m%n
 
 log4j.logger.de.fhhannover.inform.irond.rawrequests=TRACE, A3
 log4j.additivity.de.fhhannover.inform.irond.rawrequests=false
 log4j.appender.A3=org.apache.log4j.FileAppender
 log4j.appender.A3.file=irond_raw.log
 log4j.appender.A3.layout=org.apache.log4j.PatternLayout
-log4j.appender.A3.layout.ConversionPattern=%d %-5p %x - %m%n
+log4j.appender.A3.layout.ConversionPattern=%d - %-5p - %x - %m%n
 
 log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
 log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
diff --git a/opencontrail/files/2.2/database/logback.xml b/opencontrail/files/2.2/database/logback.xml
new file mode 100644
index 0000000..47b357f
--- /dev/null
+++ b/opencontrail/files/2.2/database/logback.xml
@@ -0,0 +1,53 @@
+    <!--
+     Licensed to the Apache Software Foundation (ASF) under one
+     or more contributor license agreements.  See the NOTICE file
+     distributed with this work for additional information
+     regarding copyright ownership.  The ASF licenses this file
+     to you under the Apache License, Version 2.0 (the
+     "License"); you may not use this file except in compliance
+     with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing,
+     software distributed under the License is distributed on an
+     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+     KIND, either express or implied.  See the License for the
+     specific language governing permissions and limitations
+     under the License.
+    -->
+
+    <configuration scan="true">
+      <jmxConfigurator />
+      <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${cassandra.logdir}/system.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+          <fileNamePattern>${cassandra.logdir}/system.log.%i.zip</fileNamePattern>
+          <minIndex>1</minIndex>
+          <maxIndex>20</maxIndex>
+        </rollingPolicy>
+
+        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+          <maxFileSize>20MB</maxFileSize>
+        </triggeringPolicy>
+        <encoder>
+          <pattern>%date{ISO8601} - %-5level - [%thread] %F:%L - %msg%n</pattern>
+          <!-- old-style log format
+          <pattern>%5level [%thread] %date{ISO8601} %F (line %L) %msg%n</pattern>
+          -->
+        </encoder>
+      </appender>
+
+      <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+          <pattern>%-5level %date{HH:mm:ss,SSS} %msg%n</pattern>
+        </encoder>
+      </appender>
+
+      <root level="INFO">
+        <appender-ref ref="FILE" />
+        <appender-ref ref="STDOUT" />
+      </root>
+
+      <logger name="com.thinkaurelius.thrift" level="ERROR"/>
+    </configuration>
diff --git a/opencontrail/files/3.0/config/log4j.properties b/opencontrail/files/3.0/config/log4j.properties
index 6c55393..8a1fa76 100644
--- a/opencontrail/files/3.0/config/log4j.properties
+++ b/opencontrail/files/3.0/config/log4j.properties
@@ -8,19 +8,19 @@
 
 log4j.appender.A1=org.apache.log4j.ConsoleAppender
 log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %x - %m%n
+log4j.appender.A1.layout.ConversionPattern=%d - %-5p - [%t] %x - %m%n
 
 log4j.appender.A2=org.apache.log4j.FileAppender
 log4j.appender.A2.File=/var/log/contrail/ifmap-server.log
 log4j.appender.A2.layout=org.apache.log4j.PatternLayout
-log4j.appender.A2.layout.ConversionPattern=%d [%t] %-5p %x - %m%n
+log4j.appender.A2.layout.ConversionPattern=%d - %-5p - [%t] %x - %m%n
 
 log4j.logger.de.fhhannover.inform.irond.rawrequests=TRACE, A3
 log4j.additivity.de.fhhannover.inform.irond.rawrequests=false
 log4j.appender.A3=org.apache.log4j.FileAppender
 log4j.appender.A3.file=irond_raw.log
 log4j.appender.A3.layout=org.apache.log4j.PatternLayout
-log4j.appender.A3.layout.ConversionPattern=%d %-5p %x - %m%n
+log4j.appender.A3.layout.ConversionPattern=%d - %-5p - %x - %m%n
 
 log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
 log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
diff --git a/opencontrail/files/3.0/database/logback.xml b/opencontrail/files/3.0/database/logback.xml
new file mode 100644
index 0000000..47b357f
--- /dev/null
+++ b/opencontrail/files/3.0/database/logback.xml
@@ -0,0 +1,53 @@
+    <!--
+     Licensed to the Apache Software Foundation (ASF) under one
+     or more contributor license agreements.  See the NOTICE file
+     distributed with this work for additional information
+     regarding copyright ownership.  The ASF licenses this file
+     to you under the Apache License, Version 2.0 (the
+     "License"); you may not use this file except in compliance
+     with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing,
+     software distributed under the License is distributed on an
+     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+     KIND, either express or implied.  See the License for the
+     specific language governing permissions and limitations
+     under the License.
+    -->
+
+    <configuration scan="true">
+      <jmxConfigurator />
+      <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${cassandra.logdir}/system.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+          <fileNamePattern>${cassandra.logdir}/system.log.%i.zip</fileNamePattern>
+          <minIndex>1</minIndex>
+          <maxIndex>20</maxIndex>
+        </rollingPolicy>
+
+        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+          <maxFileSize>20MB</maxFileSize>
+        </triggeringPolicy>
+        <encoder>
+          <pattern>%date{ISO8601} - %-5level - [%thread] %F:%L - %msg%n</pattern>
+          <!-- old-style log format
+          <pattern>%5level [%thread] %date{ISO8601} %F (line %L) %msg%n</pattern>
+          -->
+        </encoder>
+      </appender>
+
+      <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+          <pattern>%-5level %date{HH:mm:ss,SSS} %msg%n</pattern>
+        </encoder>
+      </appender>
+
+      <root level="INFO">
+        <appender-ref ref="FILE" />
+        <appender-ref ref="STDOUT" />
+      </root>
+
+      <logger name="com.thinkaurelius.thrift" level="ERROR"/>
+    </configuration>
diff --git a/opencontrail/files/collectd_contrail_apis.conf b/opencontrail/files/collectd_contrail_apis.conf
new file mode 100644
index 0000000..5bfea5d
--- /dev/null
+++ b/opencontrail/files/collectd_contrail_apis.conf
@@ -0,0 +1,18 @@
+
+Import "contrail_apis"
+
+<Module "contrail_apis">
+  {%- for api_check_name, api_check in plugin.api_checks.iteritems() %}
+  {%- if api_check.url is defined and api_check.xml_element is defined %}
+  Url "{{ api_check_name }}" "{{ api_check.url }}"
+  XmlElement: "{{ api_check_name }}" "{{ api_check.xml_element }}"
+  {%- if api_check.result_type is defined %}
+  ResultType: "{{ api_check_name }}" "{{ api_check.result_type }}"
+  {%- endif %}
+  {%- if api_check.state is defined %}
+  State: "{{ api_check_name }}" "{{ api_check.state }}"
+  {%- endif %}
+  {%- endif %}
+  {%- endfor %}
+</Module>
+
diff --git a/opencontrail/files/collectd_contrail_ifmap_elements_count.conf b/opencontrail/files/collectd_contrail_ifmap_elements_count.conf
new file mode 100644
index 0000000..e733542
--- /dev/null
+++ b/opencontrail/files/collectd_contrail_ifmap_elements_count.conf
@@ -0,0 +1,6 @@
+
+Import "contrail_ifmap_elements_count"
+
+<Module "contrail_ifmap_elements_count">
+</Module>
+
diff --git a/opencontrail/meta/collectd.yml b/opencontrail/meta/collectd.yml
new file mode 100644
index 0000000..c1aab4f
--- /dev/null
+++ b/opencontrail/meta/collectd.yml
@@ -0,0 +1,187 @@
+{%- if pillar.opencontrail is defined %}
+{%- if pillar.opencontrail.control is defined %}
+{%- from "opencontrail/map.jinja" import control, collector, config with context %}
+local_plugin:
+{%- if control.get('enabled', False) %}
+{%- set bind_addr=control.bind.address|replace('0.0.0.0', '127.0.0.1') %}
+  contrail_apis:
+    plugin: python
+    template: opencontrail/files/collectd_contrail_apis.conf
+    api_checks:
+      bgp-session-count:
+        url: "http://{{ bind_addr }}:8083/Snh_ShowNeighborStatisticsReq?bgp_or_xmpp=bgp"
+        xml_element: "ShowNeighborStatisticsResp"
+        result_type: "count"
+      bgp-session-up-count:
+        url: "http://{{ bind_addr }}:8083/Snh_ShowNeighborStatisticsReq?bgp_or_xmpp=bgp&up_or_down=up"
+        xml_element: "ShowNeighborStatisticsResp"
+        result_type: "count"
+      bgp-session-down-count:
+        url: "http://{{ bind_addr }}:8083/Snh_ShowNeighborStatisticsReq?bgp_or_xmpp=bgp&up_or_down=down"
+        xml_element: "ShowNeighborStatisticsResp"
+        result_type: "count"
+      xmpp-session-count:
+        url: "http://{{ bind_addr }}:8083/Snh_ShowNeighborStatisticsReq?bgp_or_xmpp=xmpp"
+        xml_element: "ShowNeighborStatisticsResp"
+        result_type: "count"
+      xmpp-session-up-count:
+        url: "http://{{ bind_addr }}:8083/Snh_ShowNeighborStatisticsReq?bgp_or_xmpp=xmpp&up_or_down=up"
+        xml_element: "ShowNeighborStatisticsResp"
+        result_type: "count"
+      xmpp-session-down-count:
+        url: "http://{{ bind_addr }}:8083/Snh_ShowNeighborStatisticsReq?bgp_or_xmpp=xmpp&up_or_down=down"
+        xml_element: "ShowNeighborStatisticsResp"
+        result_type: "count"
+{%- endif %}
+  collectd_check_local_endpoint:
+    endpoint:
+{%- if config.get('enabled', False) %}
+{%- set bind_addr=config.bind.address|replace('0.0.0.0', '127.0.0.1') %}
+      contrail-api:
+        expected_code: 401
+        url: "http://{{ bind_addr }}:{{ config.bind.api_port }}/"
+      contrail-discovery:
+        expected_code: 200
+        url: "http://{{ bind_addr }}:{{ config.bind.discovery_port }}/"
+{%- endif %}
+{%- if collector.get('enabled', False) %}
+      contrail-collector:
+        expected_code: 200
+        url: "http://{{ collector.bind.address|replace('0.0.0.0', '127.0.0.1') }}:{{ collector.bind.port }}/"
+{%- endif %}
+  collectd_processes:
+    process:
+      contrail-alarm-gen:
+        match: 'python.*contrail-alarm-gen'
+      contrail-analytics-api:
+        match: 'python.*contrail-analytics-api'
+      contrail-api:
+        match: 'python.*contrail-api'
+      contrail-collector:
+        match: 'contrail-collector'
+      contrail-control:
+        match: 'contrail-control'
+      contrail-device-manager:
+        match: 'python.*contrail-device-manager'
+      contrail-discovery:
+        match: 'python.*contrail-discovery'
+      contrail-dns:
+        match: 'contrail-dns'
+      contrail-ifmap-server:
+        match: 'sh.*ifmap-server'
+      contrail-irond:
+        match: 'java.*irond'
+      contrail-job-server:
+        match: 'node.*jobServerStart'
+      contrail-named:
+        match: 'contrail-named'
+      contrail-nodemgr:
+        match: 'python.*contrail-nodemgr'
+      contrail-query-engine:
+        match: 'contrail-query-engine'
+      contrail-schema:
+        match: 'python.*contrail-schema'
+      contrail-snmp-collector:
+        match: 'python.*contrail-snmp-collector'
+      contrail-supervisord:
+        match: 'python.*supervisord'
+      contrail-svc-monitor:
+        match: 'python.*contrail-svc-monitor'
+      contrail-topology:
+        match: 'python.*contrail-topology'
+      contrail-web-server:
+        match: 'node.*webServerStart'
+      zookeeper:
+        match: 'java.*zookeeper.server'
+      kafka-zookeeper:
+        match: 'java.*kafka.Kafka'
+      redis-server:
+        match: 'redis-server'
+      cassandra-server:
+        match: 'java.*service.CassandraDaemon'
+{%- elif pillar.opencontrail.compute is defined %}
+{%- from "opencontrail/map.jinja" import compute with context %}
+{%- if compute.get('enabled', False) %}
+{%- set bind_addr=compute.interface.address|replace('0.0.0.0', '127.0.0.1') %}
+local_plugin:
+  contrail_ifmap_elements_count:
+    plugin: python
+    template: opencontrail/files/collectd_contrail_ifmap_elements_count.conf
+  contrail_apis:
+    plugin: python
+    template: opencontrail/files/collectd_contrail_apis.conf
+    api_checks:
+      vrouter-flows-active:
+        url: "http://{{ bind_addr }}:8085/Snh_AgentStatsReq"
+        xml_element: "FlowStatsResp"
+        result_type: "flow_active"
+      vrouter-flows-aged:
+        url: "http://{{ bind_addr }}:8085/Snh_AgentStatsReq"
+        xml_element: "FlowStatsResp"
+        result_type: "flow_aged"
+      vrouter-flows-created:
+        url: "http://{{ bind_addr }}:8085/Snh_AgentStatsReq"
+        xml_element: "FlowStatsResp"
+        result_type: "flow_created"
+      vrouter-flows-composite-invalid-interface:
+        url: "http://{{ bind_addr }}:8085/Snh_KDropStatsReq"
+        xml_element: "KDropStatsResp"
+        result_type: "ds_invalid_if"
+      vrouter-flows-discard:
+        url: "http://{{ bind_addr }}:8085/Snh_KDropStatsReq"
+        xml_element: "KDropStatsResp"
+        result_type: "ds_discard"
+      vrouter-flows-flow-action-drop:
+        url: "http://{{ bind_addr }}:8085/Snh_KDropStatsReq"
+        xml_element: "KDropStatsResp"
+        result_type: "ds_flow_action_drop"
+      vrouter-flows-flow-queue-limit-exceeded:
+        url: "http://{{ bind_addr }}:8085/Snh_KDropStatsReq"
+        xml_element: "KDropStatsResp"
+        result_type: "ds_flow_queue_limit_exceeded"
+      vrouter-flows-flow-table-full:
+        url: "http://{{ bind_addr }}:8085/Snh_KDropStatsReq"
+        xml_element: "KDropStatsResp"
+        result_type: "ds_flow_table_full"
+      vrouter-flows-frag-err:
+        url: "http://{{ bind_addr }}:8085/Snh_KDropStatsReq"
+        xml_element: "KDropStatsResp"
+        result_type: "ds_frag_err"
+      vrouter-flows-invalid-label:
+        url: "http://{{ bind_addr }}:8085/Snh_KDropStatsReq"
+        xml_element: "KDropStatsResp"
+        result_type: "ds_invalid_label"
+      vrouter-flows-invalid-nh:
+        url: "http://{{ bind_addr }}:8085/Snh_KDropStatsReq"
+        xml_element: "KDropStatsResp"
+        result_type: "ds_invalid_nh"
+      vrouter-dns-xmpp:
+        url: "http://{{ bind_addr }}:8085/Snh_AgentDnsXmppConnectionStatusReq"
+        xml_element: "AgentXmppDnsData"
+        state: "Established"
+      vrouter-lls:
+        url: "http://{{ bind_addr }}:8085/Snh_LinkLocalServiceInfo"
+        xml_element: "LinkLocalServiceData"
+      vrouter-xmpp:
+        url: "http://{{ bind_addr }}:8085/Snh_AgentXmppConnectionStatusReq"
+        xml_element: "AgentXmppData"
+        state: "Established"
+  collectd_check_local_endpoint:
+    endpoint:
+      contrail-node-manager:
+        expected_code: 200
+        url: "http://127.0.0.1:8102/"
+      contrail-vrouter:
+        expected_code: 200
+        url: "http://127.0.0.1:8085/"
+  collectd_processes:
+    process:
+      contrail-nodemgr:
+        match: 'python.*contrail-nodemgr'
+      contrail-supervisord:
+        match: 'python.*supervisord'
+      contrail-vrouter-agent:
+        match: 'contrail-vrouter-agent'
+{%- endif %}
+{%- endif %}
+{%- endif %}
diff --git a/opencontrail/meta/config.yml b/opencontrail/meta/config.yml
index 8d294dc..d28e7d3 100644
--- a/opencontrail/meta/config.yml
+++ b/opencontrail/meta/config.yml
@@ -60,6 +60,9 @@
   cassandra.yaml:
     source: "salt://opencontrail/files/{{ database.version }}/cassandra.yaml"
     template: jinja
+  logback.xml:
+    source: "salt://opencontrail/files/{{ database.version }}/database/logback.xml"
+    template: jinja
   cassandra-env.sh:
     source: "salt://opencontrail/files/{{ database.version }}/database/cassandra-env.sh"
     template: jinja
@@ -126,4 +129,4 @@
   contrail-vrouter-nodemgr.ini:
     source: "salt://opencontrail/files/{{ compute.version }}/contrail-vrouter-nodemgr.ini"
     template: jinja
-  {%- endif %}
\ No newline at end of file
+  {%- endif %}
diff --git a/opencontrail/meta/heka.yml b/opencontrail/meta/heka.yml
new file mode 100644
index 0000000..16cbaeb
--- /dev/null
+++ b/opencontrail/meta/heka.yml
@@ -0,0 +1,139 @@
+{%- if pillar.opencontrail is defined %}
+{%- if pillar.opencontrail.control is defined %}
+{%- from "opencontrail/map.jinja" import control with context %}
+{%- if control.get('enabled', False) %}
+{%- set controller_ref = control %}
+{%- endif %}
+{%- elif pillar.opencontrail.compute is defined %}
+{%- from "opencontrail/map.jinja" import compute with context %}
+{%- if compute.get('enabled', False) %}
+{%- set compute_ref = compute %}
+{%- endif %}
+{%- endif %}
+{%- if pillar.opencontrail.web is defined %}
+{%- from "opencontrail/map.jinja" import web with context %}
+{%- if web.get('enabled', False) %}
+{%- set web_ref = web %}
+{%- endif %}
+{%- endif %}
+{%- endif %}
+
+{%- if controller_ref is defined or compute_ref is defined %}
+log_collector:
+{%- if controller_ref is defined %}
+  splitter:
+    java:
+      engine: regex
+      delimiter: '\n([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3} - )'
+      delimiter_eol: false
+{%- endif %}
+  decoder:
+    contrail:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/decoders/contrail_log.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+      adjust_timezone: true
+    contrail_supervisor:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/decoders/contrail_supervisor_log.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+      adjust_timezone: true
+{%- if controller_ref is defined %}
+    contrail_collector:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/decoders/contrail_collector_log.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+      adjust_timezone: true
+    contrail_api_stdout:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/decoders/contrail_api_stdout_log.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+      adjust_timezone: true
+    zookeeper:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/decoders/zookeeper.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+      adjust_timezone: true
+    cassandra:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/decoders/cassandra.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+      adjust_timezone: true
+{%- endif %}
+{%- if web_ref is defined %}
+    redis:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/decoders/redis.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+      adjust_timezone: true
+{%- endif %}
+  input:
+    contrail_supervisor_log:
+      engine: logstreamer
+      log_directory: "/var/log"
+      file_match: 'contrail/(?P<Service>supervisord-.+)\.log\.?(?P<Seq>\d*)$'
+      differentiator: ['contrail', '.', 'Service']
+      priority: ["^Seq"]
+      decoder: "contrail_supervisor_decoder"
+      splitter: "TokenSplitter"
+    contrail_named_log:
+      engine: logstreamer
+      log_directory: "/var/log"
+      file_match: 'contrail/contrail-(?P<Service>named)\.log\.?(?P<Seq>\d*)$'
+      differentiator: ['contrail', '.', 'Service']
+      priority: ["^Seq"]
+      decoder: "contrail_supervisor_decoder"
+      splitter: "TokenSplitter"
+{%- if controller_ref is defined %}
+    contrail_collector_log:
+      engine: logstreamer
+      log_directory: "/var/log"
+      file_match: 'contrail/contrail-(?P<Service>collector|control|dns|query-engine)\.log\.?(?P<Seq>\d*)$'
+      differentiator: ['contrail', '.', 'Service']
+      priority: ["^Seq"]
+      decoder: "contrail_collector_decoder"
+      splitter: "TokenSplitter"
+    contrail_api_stdout_log:
+      engine: logstreamer
+      log_directory: "/var/log"
+      file_match: 'contrail/contrail-(?P<Service>discovery-0-stdout)\.log\.?(?P<Seq>\d*)$'
+      differentiator: ['contrail', '.', 'Service']
+      priority: ["^Seq"]
+      decoder: "contrail_api_stdout_decoder"
+      splitter: "TokenSplitter"
+    zookeeper:
+      engine: logstreamer
+      log_directory: "/var/log"
+      file_match: 'zookeeper/(?P<Service>zookeeper)\.log\.?(?P<Seq>\d*)$'
+      differentiator: ['contrail', '.', 'Service']
+      priority: ["^Seq"]
+      decoder: "zookeeper_decoder"
+      splitter: "java_splitter"
+    cassandra:
+      engine: logstreamer
+      log_directory: "/var/log"
+      file_match: 'cassandra/(?P<Service>system|status)\.log\.?(?P<Seq>\d*)$'
+      differentiator: ['contrail.cassandra', '.', 'Service']
+      priority: ["^Seq"]
+      decoder: "cassandra_decoder"
+      splitter: "java_splitter"
+{%- endif %}
+    contrail_main_log:
+      engine: logstreamer
+      log_directory: "/var/log"
+      file_match: 'contrail/contrail-(?P<Service>alarm-gen.*|api|.*-stderr|.*svc-monitor.*|snmp.*)\.log\.?(?P<Seq>\d*)$'
+      differentiator: ['contrail', '.', 'Service']
+      priority: ["^Seq"]
+      decoder: "contrail_decoder"
+      splitter: "TokenSplitter"
+{%- if web_ref is defined and web_ref.get('cache', {}).get('engine', '') == 'redis' %}
+    redis_log:
+      engine: logstreamer
+      log_directory: "/var/log"
+      file_match: 'redis/(?P<Service>redis-server)\.log\.?(?P<Seq>\d*)$'
+      differentiator: ['contrail', '.', 'Service']
+      priority: ["^Seq"]
+      decoder: "redis_decoder"
+      splitter: "TokenSplitter"
+{%- endif %}
+{%- endif %}