Merge "Add redis password parameter"
diff --git a/README.rst b/README.rst
index f90f2fb..2a6883c 100644
--- a/README.rst
+++ b/README.rst
@@ -122,6 +122,11 @@
           address: 127.0.0.1
         master:
           host: 127.0.0.1
+        contrail_cache:
+          engine: redis
+          host: 127.0.0.1
+          port: 6379
+          password: guest
         discovery:
           host: 127.0.0.1
         data_ttl: 2
@@ -168,6 +173,7 @@
         cache:
           engine: redis
           host: 127.0.0.1
+          password: guest
           port: 6379
         members:
         - host: 127.0.0.1
@@ -280,6 +286,11 @@
           address: 127.0.0.1
         master:
           host: 127.0.0.1
+        contrail_cache:
+          engine: redis
+          host: 127.0.0.1
+          port: 6379
+          password: guest
         discovery:
           host: 127.0.0.1
         data_ttl: 1
@@ -332,6 +343,7 @@
         cache:
           engine: redis
           host: 127.0.0.1
+          password: guest
           port: 6379
         members:
         - host: 127.0.0.1
@@ -473,6 +485,7 @@
         cache:
           engine: redis
           host: 127.0.0.1
+          password: guest
           port: 6379
         members:
         - host: 127.0.0.1
@@ -515,6 +528,11 @@
         enabled: true
         bind:
           address: 127.0.0.1
+        contrail_cache:
+          engine: redis
+          host: 127.0.0.1
+          password: guest
+          port: 6379
         master:
           host: 127.0.0.1
         discovery:
diff --git a/metadata/service/control/analytics.yml b/metadata/service/control/analytics.yml
index 51e3694..b51a1fe 100644
--- a/metadata/service/control/analytics.yml
+++ b/metadata/service/control/analytics.yml
@@ -9,6 +9,7 @@
     opencontrail_identity_version: '2.0'
     keystone_admin_password: 'none'
     keystone_service_token: 'none'
+    redis_password: 'none'
     openstack_region: RegionOne
   opencontrail:
     common:
@@ -32,6 +33,11 @@
         port: 9081
       master:
         host: ${_param:cluster_local_address}
+      contrail_cache:
+        engine: redis
+        host: ${_param:cluster_local_address}
+        port: 6379
+        password: ${_param:redis_password}
       discovery:
         host: ${_param:network_vip_address}
       data_ttl: 1
diff --git a/metadata/service/control/cluster.yml b/metadata/service/control/cluster.yml
index aae62cf..d98a19e 100644
--- a/metadata/service/control/cluster.yml
+++ b/metadata/service/control/cluster.yml
@@ -9,6 +9,7 @@
     opencontrail_identity_version: '2.0'
     keystone_admin_password: 'none'
     keystone_service_token: 'none'
+    redis_password: 'none'
     openstack_region: RegionOne
   opencontrail:
     common:
@@ -101,6 +102,11 @@
         port: 9081
       master:
         host: ${_param:cluster_local_address}
+      contrail_cache:
+        engine: redis
+        host: ${_param:cluster_local_address}
+        port: 6379
+        password: ${_param:redis_password}
       discovery:
         host: ${_param:cluster_vip_address}
       data_ttl: 1
@@ -167,6 +173,7 @@
         engine: redis
         host: ${_param:cluster_local_address}
         port: 6379
+        password: ${_param:redis_password}
       members:
       - host: ${_param:cluster_node01_address}
         id: 1
diff --git a/metadata/service/control/control.yml b/metadata/service/control/control.yml
index 7cb3521..d033ccf 100644
--- a/metadata/service/control/control.yml
+++ b/metadata/service/control/control.yml
@@ -10,6 +10,7 @@
     keystone_admin_password: 'none'
     keystone_service_token: 'none'
     openstack_region: RegionOne
+    redis_password: 'none'
   opencontrail:
     common:
       version: ${_param:opencontrail_version}
@@ -132,6 +133,7 @@
       cache:
         engine: redis
         host: ${_param:cluster_local_address}
+        password: ${_param:redis_password}
         port: 6379
       members:
       - host: ${_param:cluster_node01_address}
diff --git a/metadata/service/control/single.yml b/metadata/service/control/single.yml
index f17d610..a63f28a 100644
--- a/metadata/service/control/single.yml
+++ b/metadata/service/control/single.yml
@@ -10,6 +10,7 @@
     keystone_admin_password: 'none'
     keystone_service_token: 'none'
     openstack_region: RegionOne
+    redis_password: 'none'
   opencontrail:
     common:
       version: ${_param:opencontrail_version}
@@ -85,6 +86,11 @@
         port: 9081
       master:
         host: ${_param:single_address}
+      contrail_cache:
+        engine: redis
+        host: ${_param:single_address}
+        port: 6379
+        password: ${_param:redis_password}
       discovery:
         host: ${_param:single_address}
       data_ttl: 1
@@ -141,6 +147,7 @@
         engine: redis
         host: ${_param:single_address}
         port: 6379
+        password: ${_param:redis_password}
       members:
       - host: ${_param:single_address}
         id: 1
diff --git a/opencontrail/files/4.0/config.global.js b/opencontrail/files/4.0/config.global.js
index e420435..2dd1b64 100644
--- a/opencontrail/files/4.0/config.global.js
+++ b/opencontrail/files/4.0/config.global.js
@@ -261,7 +261,7 @@
 {%- else %}
 config.redis_dump_file = '/var/lib/redis/dump-webui.rdb';
 {%- endif %}
-config.redis_password = '';
+config.redis_password = '{{ web.cache.get("password", "") }}';
 
 /* Cassandra Server */
 config.cassandra = {};
diff --git a/opencontrail/files/4.0/contrail-alarm-gen.conf b/opencontrail/files/4.0/contrail-alarm-gen.conf
index e0c51a3..87ada20 100644
--- a/opencontrail/files/4.0/contrail-alarm-gen.conf
+++ b/opencontrail/files/4.0/contrail-alarm-gen.conf
@@ -30,6 +30,9 @@
 [REDIS]
 redis_server_port=6379
 redis_uve_list = {% for member in collector.database.members %}{{ member.host }}:6379 {% endfor %}
+{%- if collector.get('contrail_cache', {}).get('password') %}
+redis_password = {{ collector.contrail_cache.password }}
+{%- endif %}
 
 [SANDESH]
 #sandesh_ssl_enable=False
diff --git a/opencontrail/files/4.0/contrail-analytics-api.conf b/opencontrail/files/4.0/contrail-analytics-api.conf
index 98544ae..6743e22 100644
--- a/opencontrail/files/4.0/contrail-analytics-api.conf
+++ b/opencontrail/files/4.0/contrail-analytics-api.conf
@@ -33,6 +33,9 @@
 [REDIS]
 redis_query_port = 6379
 redis_uve_list = {% for member in collector.database.members %}{{ member.host }}:6379 {% endfor %}
+{%- if collector.get('contrail_cache', {}).get('password') %}
+redis_password = {{ collector.contrail_cache.password }}
+{%- endif %}
 
 [SANDESH]
 #sandesh_ssl_enable=False
diff --git a/opencontrail/files/4.0/contrail-collector.conf b/opencontrail/files/4.0/contrail-collector.conf
index 35f89cf..a8c8136 100644
--- a/opencontrail/files/4.0/contrail-collector.conf
+++ b/opencontrail/files/4.0/contrail-collector.conf
@@ -115,3 +115,6 @@
 [REDIS]
 port=6379
 server=127.0.0.1
+{%- if collector.get('contrail_cache', {}).get('password') %}
+password={{ collector.contrail_cache.password }}
+{%- endif %}
diff --git a/opencontrail/files/4.0/contrail-query-engine.conf b/opencontrail/files/4.0/contrail-query-engine.conf
index 3cc9ef6..1e797bb 100644
--- a/opencontrail/files/4.0/contrail-query-engine.conf
+++ b/opencontrail/files/4.0/contrail-query-engine.conf
@@ -31,6 +31,9 @@
 [REDIS]
 port=6379
 server=127.0.0.1
+{%- if collector.get('contrail_cache', {}).get('password') %}
+password={{ collector.contrail_cache.password }}
+{%- endif %}
 
 [SANDESH]
 # sandesh_ssl_enable=false
diff --git a/opencontrail/files/4.0/redis.conf b/opencontrail/files/4.0/redis.conf
index db9c433..3439922 100644
--- a/opencontrail/files/4.0/redis.conf
+++ b/opencontrail/files/4.0/redis.conf
@@ -193,6 +193,9 @@
 # refuse the slave request.
 #
 # masterauth <master-password>
+{%- if collector.get('contrail_cache', {}).get("password") %}
+masterauth {{ collector.contrail_cache.password }}
+{%- endif %}
 
 # When a slave loses its connection with the master, or when the replication
 # is still in progress, the slave can act in two different ways:
@@ -329,6 +332,9 @@
 # use a very strong password otherwise it will be very easy to break.
 #
 # requirepass foobared
+{%- if collector.get('contrail_cache', {}).get("password") %}
+requirepass {{ collector.contrail_cache.password }}
+{%- endif %}
 
 # Command renaming.
 #