Merge "Enabling log4j.rootLogger configuration parameter"
diff --git a/.kitchen.travis.yml b/.kitchen.travis.yml
new file mode 100644
index 0000000..f847543
--- /dev/null
+++ b/.kitchen.travis.yml
@@ -0,0 +1,6 @@
+suites:
+
+  - name: <%= ENV['SUITE'] %>
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/<%= ENV['SUITE'] %>.sls
diff --git a/.kitchen.yml b/.kitchen.yml
index e9ab514..755b36f 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -2,7 +2,7 @@
 driver:
   name: docker
   hostname: opencontrail
-  use_sudo: true
+  use_sudo: false
 
 provisioner:
   name: salt_solo
@@ -56,29 +56,53 @@
 
 suites:
 
-  # - name: single<%= ENV['OC_VERSION'] || '' %>
-  #   provisioner:
-  #     pillars-from-files:
-  #       opencontrail.sls: tests/pillar/single<%= ENV['OC_VERSION'] || '' %>.sls
-  - name: analytics<%= ENV['OC_VERSION'] || '' %>
+  - name: single
     provisioner:
       pillars-from-files:
-        opencontrail.sls: tests/pillar/analytics<%= ENV['OC_VERSION'] || '' %>.sls
-  - name: control<%= ENV['OC_VERSION'] || '' %>
+        opencontrail.sls: tests/pillar/single.sls
+  - name: single40
     provisioner:
       pillars-from-files:
-        opencontrail.sls: tests/pillar/control<%= ENV['OC_VERSION'] || '' %>.sls
-  # - name: cluster<%= ENV['OC_VERSION'] || '' %>
-  #   provisioner:
-  #     pillars-from-files:
-  #       opencontrail.sls: tests/pillar/cluster<%= ENV['OC_VERSION'] || '' %>.sls
-  # - name: tor<%= ENV['OC_VERSION'] || '' %>
-  #   provisioner:
-  #     pillars-from-files:
-  #       opencontrail.sls: tests/pillar/tor<%= ENV['OC_VERSION'] || '' %>.sls
-  - name: vrouter<%= ENV['OC_VERSION'] || '' %>
+        opencontrail.sls: tests/pillar/single40.sls
+  - name: analytics
     provisioner:
       pillars-from-files:
-        opencontrail.sls: tests/pillar/vrouter<%= ENV['OC_VERSION'] || '' %>.sls
+        opencontrail.sls: tests/pillar/analytics.sls
+  - name: analytics40
+    provisioner:
+      pillars-from-files:
+        opencontrail.sls: tests/pillar/analytics40.sls
+  - name: control
+    provisioner:
+      pillars-from-files:
+        opencontrail.sls: tests/pillar/control.sls
+  - name: control40
+    provisioner:
+      pillars-from-files:
+        opencontrail.sls: tests/pillar/control40.sls
+  - name: cluster
+    provisioner:
+      pillars-from-files:
+        opencontrail.sls: tests/pillar/cluster.sls
+  - name: cluster40
+    provisioner:
+      pillars-from-files:
+        opencontrail.sls: tests/pillar/cluster40.sls
+  - name: tor
+    provisioner:
+      pillars-from-files:
+        opencontrail.sls: tests/pillar/tor.sls
+  - name: tor40
+    provisioner:
+      pillars-from-files:
+        opencontrail.sls: tests/pillar/tor40.sls
+  - name: vrouter
+    provisioner:
+      pillars-from-files:
+        opencontrail.sls: tests/pillar/vrouter.sls
+  - name: vrouter40
+    provisioner:
+      pillars-from-files:
+        opencontrail.sls: tests/pillar/vrouter40.sls
 
 # vim: ft=yaml sw=2 ts=2 sts=2 tw=125
diff --git a/.travis.yml b/.travis.yml
index 7ed0bdb..51efa5a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,19 +18,43 @@
   - bundle install
 
 env:
-  - PLATFORM=trevorj/salty-whales:trusty
-  - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc323
-  - OC_REPO=oc323
-  - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc40 OC_VERSION=4_0
-  - OC_REPO=oc40 OC_VERSION=4_0
+  # - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc311 SUITE=single
+  - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc311 SUITE=analytics
+  - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc311 SUITE=control
+  # - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc311 SUITE=cluster
+  # - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc311 SUITE=tor
+  - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc311 SUITE=vrouter
+  # - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc323 SUITE=single
+  - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc323 SUITE=analytics
+  - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc323 SUITE=control
+  # - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc323 SUITE=cluster
+  # - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc323 SUITE=tor
+  - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc323 SUITE=vrouter
+  # - PLATFORM=trevorj/salty-whales:xenial OC_REPO=oc323 SUITE=single
+  - PLATFORM=trevorj/salty-whales:xenial OC_REPO=oc323 SUITE=analytics
+  - PLATFORM=trevorj/salty-whales:xenial OC_REPO=oc323 SUITE=control
+  # - PLATFORM=trevorj/salty-whales:xenial OC_REPO=oc323 SUITE=cluster
+  # - PLATFORM=trevorj/salty-whales:xenial OC_REPO=oc323 SUITE=tor
+  - PLATFORM=trevorj/salty-whales:xenial OC_REPO=oc323 SUITE=vrouter
+  # - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc40 SUITE=single40
+  - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc40 SUITE=analytics40
+  - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc40 SUITE=control40
+  # - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc40 SUITE=cluster40
+  # - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc40 SUITE=tor40
+  - PLATFORM=trevorj/salty-whales:trusty OC_REPO=oc40 SUITE=vrouter40
+  # - PLATFORM=trevorj/salty-whales:xenial OC_REPO=oc40 SUITE=single40
+  - PLATFORM=trevorj/salty-whales:xenial OC_REPO=oc40 SUITE=analytics40
+  - PLATFORM=trevorj/salty-whales:xenial OC_REPO=oc40 SUITE=control40
+  # - PLATFORM=trevorj/salty-whales:xenial OC_REPO=oc40 SUITE=cluster40
+  # - PLATFORM=trevorj/salty-whales:xenial OC_REPO=oc40 SUITE=tor40
+  - PLATFORM=trevorj/salty-whales:xenial OC_REPO=oc40 SUITE=vrouter40
 
 before_script:
   - set -o pipefail
   - make test | tail
 
 script:
-  - test ! -e .kitchen.yml || bundle exec kitchen converge $SUITE || true
-  - test ! -e .kitchen.yml || bundle exec kitchen verify $SUITE -t tests/integration
+  - KITCHEN_LOCAL_YAML=.kitchen.travis.yml bundle exec kitchen test -t tests/integration
 
 notifications:
   webhooks:
diff --git a/README.rst b/README.rst
index 4fa2d74..54e9502 100644
--- a/README.rst
+++ b/README.rst
@@ -591,6 +591,21 @@
         gateway_mode: server
 
 
+Set up metadata secret for the Vrouter
+-------------------------------------
+
+In order to get cloud-init within the instance to properly fetch 
+instance metadata, metadata_proxy_secret in the Vrouter agent config
+should match the value in nova.conf. The administrator should define
+it in the pillar:
+
+.. code-block:: yaml
+
+    opencontrail:
+      compute:
+        metadata:
+          secret: opencontrail
+
 Keystone v3
 -----------
 
diff --git a/_modules/contrail.py b/_modules/contrail.py
index 3719653..f03ee33 100644
--- a/_modules/contrail.py
+++ b/_modules/contrail.py
@@ -146,6 +146,9 @@
     vnc_client = _auth(**kwargs)
     gsc_obj = _get_config(vnc_client)
     vrouter_objs = virtual_router_list(**kwargs)
+    router_types = ['tor-agent', 'tor-service-node', 'embedded']
+    if router_type not in router_types:
+        router_type = None
     if name in vrouter_objs:
         vrouter = virtual_router_get(name)
         vrouter_obj = vnc_client._object_read('virtual-router', id=vrouter[name]['uuid'])
diff --git a/opencontrail/files/2.2/contrail-vrouter-agent.conf b/opencontrail/files/2.2/contrail-vrouter-agent.conf
index 0e4f1fc..0aa2672 100644
--- a/opencontrail/files/2.2/contrail-vrouter-agent.conf
+++ b/opencontrail/files/2.2/contrail-vrouter-agent.conf
@@ -123,6 +123,9 @@
 [METADATA]
 # Shared secret for metadata proxy service (Optional)
 # metadata_proxy_secret=contrail
+{%- if compute.metadata is defined %}
+metadata_proxy_secret={{ compute.metadata.secret }}
+{%- endif %}
 
 [NETWORKS]
 # control-channel IP address used by WEB-UI to connect to vnswad to fetch
diff --git a/opencontrail/files/3.0/contrail-vrouter-agent.conf b/opencontrail/files/3.0/contrail-vrouter-agent.conf
index 75bfd4d..f4b5b8d 100644
--- a/opencontrail/files/3.0/contrail-vrouter-agent.conf
+++ b/opencontrail/files/3.0/contrail-vrouter-agent.conf
@@ -4,7 +4,7 @@
 #
 
 [CONTROL-NODE]
-# IP address to be used to connect to control-node. Maximum of 2 IP addresses 
+# IP address to be used to connect to control-node. Maximum of 2 IP addresses
 # (separated by a space) can be provided. If no IP is configured then the
 # value provided by discovery service will be used. (Optional)
 # server=10.0.0.1 10.0.0.2
@@ -19,6 +19,9 @@
 
 # Agent mode : can be vrouter / tsn / tor (default is vrouter)
 # agent_mode=
+{%- if compute.get('tor', {}).get('enabled', False) %}
+agent_mode = tsn
+{%- endif %}
 
 # Enable/disable debug logging. Possible values are 0 (disable) and 1 (enable)
 # debug=0
@@ -55,7 +58,7 @@
 # Local log file name
 log_file=/var/log/contrail/contrail-vrouter-agent.log
 
-# Log severity levels. Possible values are SYS_EMERG, SYS_ALERT, SYS_CRIT, 
+# Log severity levels. Possible values are SYS_EMERG, SYS_ALERT, SYS_CRIT,
 # SYS_ERR, SYS_WARN, SYS_NOTICE, SYS_INFO and SYS_DEBUG. Default is SYS_DEBUG
 log_level=SYS_NOTICE
 
@@ -81,16 +84,13 @@
 # DHCP relay mode (true or false) to determine if a DHCP request in fabric
 # interface with an unconfigured IP should be relayed or not
 # dhcp_relay_mode=
-{%- if compute.get('tor', {}).get('enabled', False) %}
-agent_mode = tsn
-{%- endif %}
 
 {%- if compute.gateway_mode is defined %}
 gateway_mode={{ compute.gateway_mode }}
 {%- endif %}
 
 [DISCOVERY]
-# If COLLECTOR and/or CONTROL-NODE and/or DNS is not specified this section is 
+# If COLLECTOR and/or CONTROL-NODE and/or DNS is not specified this section is
 # mandatory. Else this section is optional
 
 # IP address and port of discovery server
@@ -140,6 +140,9 @@
 [METADATA]
 # Shared secret for metadata proxy service (Optional)
 # metadata_proxy_secret=contrail
+{%- if compute.metadata is defined %}
+metadata_proxy_secret={{ compute.metadata.secret }}
+{%- endif %}
 
 [NETWORKS]
 # control-channel IP address used by WEB-UI to connect to vnswad to fetch
@@ -177,7 +180,7 @@
 # (like metadata...)
 #compute_node_address = 10.204.216.28
 
-# We can have multiple gateway sections with different indices in the 
+# We can have multiple gateway sections with different indices in the
 # following format
 # [GATEWAY-0]
 # Name of the routing_instance for which the gateway is being configured
@@ -187,7 +190,7 @@
 # interface=vgw
 
 # Virtual network ip blocks for which gateway service is required. Each IP
-# block is represented as ip/prefix. Multiple IP blocks are represented by 
+# block is represented as ip/prefix. Multiple IP blocks are represented by
 # separating each with a space
 # ip_blocks=1.1.1.1/24
 
@@ -199,7 +202,7 @@
 # interface=vgw1
 
 # Virtual network ip blocks for which gateway service is required. Each IP
-# block is represented as ip/prefix. Multiple IP blocks are represented by 
+# block is represented as ip/prefix. Multiple IP blocks are represented by
 # separating each with a space
 # ip_blocks=2.2.1.0/24 2.2.2.0/24
 
diff --git a/opencontrail/files/4.0/contrail-vrouter-agent.conf b/opencontrail/files/4.0/contrail-vrouter-agent.conf
index f23e22b..f8c6933 100644
--- a/opencontrail/files/4.0/contrail-vrouter-agent.conf
+++ b/opencontrail/files/4.0/contrail-vrouter-agent.conf
@@ -196,6 +196,9 @@
 [METADATA]
 # Shared secret for metadata proxy service (Optional)
 # metadata_proxy_secret=contrail
+{%- if compute.metadata is defined %}
+metadata_proxy_secret={{ compute.metadata.secret }}
+{%- endif %}
 
 # Metadata proxy port on which agent listens (Optional)
 # metadata_proxy_port=
diff --git a/opencontrail/files/telegraf.conf b/opencontrail/files/telegraf.conf
new file mode 100644
index 0000000..a1faefa
--- /dev/null
+++ b/opencontrail/files/telegraf.conf
@@ -0,0 +1,19 @@
+[[inputs.contrail]]
+{%- if values.interval is defined %}
+  interval = "{{ values.interval }}"
+{%- endif %}
+  ifmap_count = {{ values.ifmap_count|default("false")|lower }}
+{%- for tag_name, tag_value in values.get('checks', {}).iteritems() %}
+  {%- if tag_value.url is defined and tag_value.xml_element is defined %}
+  [[inputs.contrail.checks]]
+    url = "{{ tag_value.url }}"
+    xml_element = "{{ tag_value.xml_element }}"
+    name = "{{ tag_name }}"
+      {%- if tag_value.result_type is defined %}
+    result_type = "{{ tag_value.result_type }}"
+      {%- endif %}
+      {%- if tag_value.state is defined %}
+    state = "{{ tag_value.state }}"
+      {%- endif %}
+  {%- endif %}
+{%- endfor %}
diff --git a/opencontrail/meta/telegraf.yml b/opencontrail/meta/telegraf.yml
index e43dc93..51f7a40 100644
--- a/opencontrail/meta/telegraf.yml
+++ b/opencontrail/meta/telegraf.yml
@@ -111,8 +111,11 @@
   {%- endif %}
   {%- if control.get('enabled', False) or compute.get('enabled', False) %}
     contrail:
+      template: opencontrail/files/telegraf.conf
     {%- if control.get('enabled', False) %}
-      ifmap_count: "true"
+      # ifmap_count is always disabled because it puts too much load on the IF-MAP server
+      # and the metric is pretty much useless.
+      ifmap_count: "false"
     {%- endif %}
       checks:
     {%- if control.get('enabled', False) %}
diff --git a/tests/pillar/analytics4_0.sls b/tests/pillar/analytics40.sls
similarity index 100%
rename from tests/pillar/analytics4_0.sls
rename to tests/pillar/analytics40.sls
diff --git a/tests/pillar/cluster4_0.sls b/tests/pillar/cluster40.sls
similarity index 100%
rename from tests/pillar/cluster4_0.sls
rename to tests/pillar/cluster40.sls
diff --git a/tests/pillar/control4_0.sls b/tests/pillar/control40.sls
similarity index 100%
rename from tests/pillar/control4_0.sls
rename to tests/pillar/control40.sls
diff --git a/tests/pillar/single4_0.sls b/tests/pillar/single40.sls
similarity index 100%
rename from tests/pillar/single4_0.sls
rename to tests/pillar/single40.sls
diff --git a/tests/pillar/vrouter4_0.sls b/tests/pillar/vrouter40.sls
similarity index 100%
rename from tests/pillar/vrouter4_0.sls
rename to tests/pillar/vrouter40.sls